Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 599918
Collapse All | Expand All

(-)pypy2-v5.6.0-src/lib-python/2.7/distutils/cygwinccompiler.py (-3 / +18 lines)
Lines 120-127 Link Here
120
        # dllwrap 2.10.90 is buggy
120
        # dllwrap 2.10.90 is buggy
121
        if self.ld_version >= "2.10.90":
121
        if self.ld_version >= "2.10.90":
122
            self.linker_dll = "gcc"
122
            self.linker_dll = "gcc"
123
            self.linker_dll_cxx = "g++"
123
        else:
124
        else:
124
            self.linker_dll = "dllwrap"
125
            self.linker_dll = "dllwrap"
126
            self.linker_dll_cxx = "dllwrap"
125
127
126
        # ld_version >= "2.13" support -shared so use it instead of
128
        # ld_version >= "2.13" support -shared so use it instead of
127
        # -mdll -static
129
        # -mdll -static
Lines 135-143 Link Here
135
        self.set_executables(compiler='gcc -mcygwin -O -Wall',
137
        self.set_executables(compiler='gcc -mcygwin -O -Wall',
136
                             compiler_so='gcc -mcygwin -mdll -O -Wall',
138
                             compiler_so='gcc -mcygwin -mdll -O -Wall',
137
                             compiler_cxx='g++ -mcygwin -O -Wall',
139
                             compiler_cxx='g++ -mcygwin -O -Wall',
140
                             compiler_so_cxx='g++ -mcygwin -mdll -O -Wall',
138
                             linker_exe='gcc -mcygwin',
141
                             linker_exe='gcc -mcygwin',
139
                             linker_so=('%s -mcygwin %s' %
142
                             linker_so=('%s -mcygwin %s' %
140
                                        (self.linker_dll, shared_option)))
143
                                        (self.linker_dll, shared_option)),
144
                             linker_exe_cxx='g++ -mcygwin',
145
                             linker_so_cxx=('%s -mcygwin %s' %
146
                                            (self.linker_dll_cxx, shared_option)))
141
147
142
        # cygwin and mingw32 need different sets of libraries
148
        # cygwin and mingw32 need different sets of libraries
143
        if self.gcc_version == "2.91.57":
149
        if self.gcc_version == "2.91.57":
Lines 163-170 Link Here
163
                raise CompileError, msg
169
                raise CompileError, msg
164
        else: # for other files use the C-compiler
170
        else: # for other files use the C-compiler
165
            try:
171
            try:
166
                self.spawn(self.compiler_so + cc_args + [src, '-o', obj] +
172
                if self.detect_language(src) == 'c++':
167
                           extra_postargs)
173
                    self.spawn(self.compiler_so_cxx + cc_args + [src, '-o', obj] +
174
                               extra_postargs)
175
                else:
176
                    self.spawn(self.compiler_so + cc_args + [src, '-o', obj] +
177
                               extra_postargs)
168
            except DistutilsExecError, msg:
178
            except DistutilsExecError, msg:
169
                raise CompileError, msg
179
                raise CompileError, msg
170
180
Lines 330-338 Link Here
330
        self.set_executables(compiler='gcc%s -O -Wall' % no_cygwin,
340
        self.set_executables(compiler='gcc%s -O -Wall' % no_cygwin,
331
                             compiler_so='gcc%s -mdll -O -Wall' % no_cygwin,
341
                             compiler_so='gcc%s -mdll -O -Wall' % no_cygwin,
332
                             compiler_cxx='g++%s -O -Wall' % no_cygwin,
342
                             compiler_cxx='g++%s -O -Wall' % no_cygwin,
343
                             compiler_so_cxx='g++%s -mdll -O -Wall' % no_cygwin,
333
                             linker_exe='gcc%s' % no_cygwin,
344
                             linker_exe='gcc%s' % no_cygwin,
334
                             linker_so='%s%s %s %s'
345
                             linker_so='%s%s %s %s'
335
                                    % (self.linker_dll, no_cygwin,
346
                                    % (self.linker_dll, no_cygwin,
347
                                       shared_option, entry_point),
348
                             linker_exe_cxx='g++%s' % no_cygwin,
349
                             linker_so_cxx='%s%s %s %s'
350
                                    % (self.linker_dll_cxx, no_cygwin,
336
                                       shared_option, entry_point))
351
                                       shared_option, entry_point))
337
        # Maybe we should also append -mthreads, but then the finished
352
        # Maybe we should also append -mthreads, but then the finished
338
        # dlls need another dll (mingwm10.dll see Mingw32 docs)
353
        # dlls need another dll (mingwm10.dll see Mingw32 docs)
(-)pypy2-v5.6.0-src/lib-python/2.7/distutils/cygwinccompiler.py.orig (+466 lines)
Line 0 Link Here
1
"""distutils.cygwinccompiler
2
3
Provides the CygwinCCompiler class, a subclass of UnixCCompiler that
4
handles the Cygwin port of the GNU C compiler to Windows.  It also contains
5
the Mingw32CCompiler class which handles the mingw32 port of GCC (same as
6
cygwin in no-cygwin mode).
7
"""
8
9
# problems:
10
#
11
# * if you use a msvc compiled python version (1.5.2)
12
#   1. you have to insert a __GNUC__ section in its config.h
13
#   2. you have to generate an import library for its dll
14
#      - create a def-file for python??.dll
15
#      - create an import library using
16
#             dlltool --dllname python15.dll --def python15.def \
17
#                       --output-lib libpython15.a
18
#
19
#   see also http://starship.python.net/crew/kernr/mingw32/Notes.html
20
#
21
# * We put export_symbols in a def-file, and don't use
22
#   --export-all-symbols because it doesn't worked reliable in some
23
#   tested configurations. And because other windows compilers also
24
#   need their symbols specified this no serious problem.
25
#
26
# tested configurations:
27
#
28
# * cygwin gcc 2.91.57/ld 2.9.4/dllwrap 0.2.4 works
29
#   (after patching python's config.h and for C++ some other include files)
30
#   see also http://starship.python.net/crew/kernr/mingw32/Notes.html
31
# * mingw32 gcc 2.95.2/ld 2.9.4/dllwrap 0.2.4 works
32
#   (ld doesn't support -shared, so we use dllwrap)
33
# * cygwin gcc 2.95.2/ld 2.10.90/dllwrap 2.10.90 works now
34
#   - its dllwrap doesn't work, there is a bug in binutils 2.10.90
35
#     see also http://sources.redhat.com/ml/cygwin/2000-06/msg01274.html
36
#   - using gcc -mdll instead dllwrap doesn't work without -static because
37
#     it tries to link against dlls instead their import libraries. (If
38
#     it finds the dll first.)
39
#     By specifying -static we force ld to link against the import libraries,
40
#     this is windows standard and there are normally not the necessary symbols
41
#     in the dlls.
42
#   *** only the version of June 2000 shows these problems
43
# * cygwin gcc 3.2/ld 2.13.90 works
44
#   (ld supports -shared)
45
# * mingw gcc 3.2/ld 2.13 works
46
#   (ld supports -shared)
47
48
# This module should be kept compatible with Python 2.1.
49
50
__revision__ = "$Id$"
51
52
import os,sys,copy
53
from distutils.ccompiler import gen_preprocess_options, gen_lib_options
54
from distutils.unixccompiler import UnixCCompiler
55
from distutils.file_util import write_file
56
from distutils.errors import DistutilsExecError, CompileError, UnknownFileError
57
from distutils import log
58
59
def get_msvcr():
60
    """Include the appropriate MSVC runtime library if Python was built
61
    with MSVC 7.0 or later.
62
    """
63
    msc_pos = sys.version.find('MSC v.')
64
    if msc_pos != -1:
65
        msc_ver = sys.version[msc_pos+6:msc_pos+10]
66
        if msc_ver == '1300':
67
            # MSVC 7.0
68
            return ['msvcr70']
69
        elif msc_ver == '1310':
70
            # MSVC 7.1
71
            return ['msvcr71']
72
        elif msc_ver == '1400':
73
            # VS2005 / MSVC 8.0
74
            return ['msvcr80']
75
        elif msc_ver == '1500':
76
            # VS2008 / MSVC 9.0
77
            return ['msvcr90']
78
        elif msc_ver == '1600':
79
            # VS2010 / MSVC 10.0
80
            return ['msvcr100']
81
        else:
82
            raise ValueError("Unknown MS Compiler version %s " % msc_ver)
83
84
85
class CygwinCCompiler (UnixCCompiler):
86
87
    compiler_type = 'cygwin'
88
    obj_extension = ".o"
89
    static_lib_extension = ".a"
90
    shared_lib_extension = ".dll"
91
    static_lib_format = "lib%s%s"
92
    shared_lib_format = "%s%s"
93
    exe_extension = ".exe"
94
95
    def __init__ (self, verbose=0, dry_run=0, force=0):
96
97
        UnixCCompiler.__init__ (self, verbose, dry_run, force)
98
99
        (status, details) = check_config_h()
100
        self.debug_print("Python's GCC status: %s (details: %s)" %
101
                         (status, details))
102
        if status is not CONFIG_H_OK:
103
            self.warn(
104
                "Python's pyconfig.h doesn't seem to support your compiler. "
105
                "Reason: %s. "
106
                "Compiling may fail because of undefined preprocessor macros."
107
                % details)
108
109
        self.gcc_version, self.ld_version, self.dllwrap_version = \
110
            get_versions()
111
        self.debug_print(self.compiler_type + ": gcc %s, ld %s, dllwrap %s\n" %
112
                         (self.gcc_version,
113
                          self.ld_version,
114
                          self.dllwrap_version) )
115
116
        # ld_version >= "2.10.90" and < "2.13" should also be able to use
117
        # gcc -mdll instead of dllwrap
118
        # Older dllwraps had own version numbers, newer ones use the
119
        # same as the rest of binutils ( also ld )
120
        # dllwrap 2.10.90 is buggy
121
        if self.ld_version >= "2.10.90":
122
            self.linker_dll = "gcc"
123
        else:
124
            self.linker_dll = "dllwrap"
125
126
        # ld_version >= "2.13" support -shared so use it instead of
127
        # -mdll -static
128
        if self.ld_version >= "2.13":
129
            shared_option = "-shared"
130
        else:
131
            shared_option = "-mdll -static"
132
133
        # Hard-code GCC because that's what this is all about.
134
        # XXX optimization, warnings etc. should be customizable.
135
        self.set_executables(compiler='gcc -mcygwin -O -Wall',
136
                             compiler_so='gcc -mcygwin -mdll -O -Wall',
137
                             compiler_cxx='g++ -mcygwin -O -Wall',
138
                             linker_exe='gcc -mcygwin',
139
                             linker_so=('%s -mcygwin %s' %
140
                                        (self.linker_dll, shared_option)))
141
142
        # cygwin and mingw32 need different sets of libraries
143
        if self.gcc_version == "2.91.57":
144
            # cygwin shouldn't need msvcrt, but without the dlls will crash
145
            # (gcc version 2.91.57) -- perhaps something about initialization
146
            self.dll_libraries=["msvcrt"]
147
            self.warn(
148
                "Consider upgrading to a newer version of gcc")
149
        else:
150
            # Include the appropriate MSVC runtime library if Python was built
151
            # with MSVC 7.0 or later.
152
            self.dll_libraries = get_msvcr()
153
154
    # __init__ ()
155
156
157
    def _compile(self, obj, src, ext, cc_args, extra_postargs, pp_opts):
158
        if ext == '.rc' or ext == '.res':
159
            # gcc needs '.res' and '.rc' compiled to object files !!!
160
            try:
161
                self.spawn(["windres", "-i", src, "-o", obj])
162
            except DistutilsExecError, msg:
163
                raise CompileError, msg
164
        else: # for other files use the C-compiler
165
            try:
166
                self.spawn(self.compiler_so + cc_args + [src, '-o', obj] +
167
                           extra_postargs)
168
            except DistutilsExecError, msg:
169
                raise CompileError, msg
170
171
    def link (self,
172
              target_desc,
173
              objects,
174
              output_filename,
175
              output_dir=None,
176
              libraries=None,
177
              library_dirs=None,
178
              runtime_library_dirs=None,
179
              export_symbols=None,
180
              debug=0,
181
              extra_preargs=None,
182
              extra_postargs=None,
183
              build_temp=None,
184
              target_lang=None):
185
186
        # use separate copies, so we can modify the lists
187
        extra_preargs = copy.copy(extra_preargs or [])
188
        libraries = copy.copy(libraries or [])
189
        objects = copy.copy(objects or [])
190
191
        # Additional libraries
192
        libraries.extend(self.dll_libraries)
193
194
        # handle export symbols by creating a def-file
195
        # with executables this only works with gcc/ld as linker
196
        if ((export_symbols is not None) and
197
            (target_desc != self.EXECUTABLE or self.linker_dll == "gcc")):
198
            # (The linker doesn't do anything if output is up-to-date.
199
            # So it would probably better to check if we really need this,
200
            # but for this we had to insert some unchanged parts of
201
            # UnixCCompiler, and this is not what we want.)
202
203
            # we want to put some files in the same directory as the
204
            # object files are, build_temp doesn't help much
205
            # where are the object files
206
            temp_dir = os.path.dirname(objects[0])
207
            # name of dll to give the helper files the same base name
208
            (dll_name, dll_extension) = os.path.splitext(
209
                os.path.basename(output_filename))
210
211
            # generate the filenames for these files
212
            def_file = os.path.join(temp_dir, dll_name + ".def")
213
            lib_file = os.path.join(temp_dir, 'lib' + dll_name + ".a")
214
215
            # Generate .def file
216
            contents = [
217
                "LIBRARY %s" % os.path.basename(output_filename),
218
                "EXPORTS"]
219
            for sym in export_symbols:
220
                contents.append(sym)
221
            self.execute(write_file, (def_file, contents),
222
                         "writing %s" % def_file)
223
224
            # next add options for def-file and to creating import libraries
225
226
            # dllwrap uses different options than gcc/ld
227
            if self.linker_dll == "dllwrap":
228
                extra_preargs.extend(["--output-lib", lib_file])
229
                # for dllwrap we have to use a special option
230
                extra_preargs.extend(["--def", def_file])
231
            # we use gcc/ld here and can be sure ld is >= 2.9.10
232
            else:
233
                # doesn't work: bfd_close build\...\libfoo.a: Invalid operation
234
                #extra_preargs.extend(["-Wl,--out-implib,%s" % lib_file])
235
                # for gcc/ld the def-file is specified as any object files
236
                objects.append(def_file)
237
238
        #end: if ((export_symbols is not None) and
239
        #        (target_desc != self.EXECUTABLE or self.linker_dll == "gcc")):
240
241
        # who wants symbols and a many times larger output file
242
        # should explicitly switch the debug mode on
243
        # otherwise we let dllwrap/ld strip the output file
244
        # (On my machine: 10KB < stripped_file < ??100KB
245
        #   unstripped_file = stripped_file + XXX KB
246
        #  ( XXX=254 for a typical python extension))
247
        if not debug:
248
            extra_preargs.append("-s")
249
250
        UnixCCompiler.link(self,
251
                           target_desc,
252
                           objects,
253
                           output_filename,
254
                           output_dir,
255
                           libraries,
256
                           library_dirs,
257
                           runtime_library_dirs,
258
                           None, # export_symbols, we do this in our def-file
259
                           debug,
260
                           extra_preargs,
261
                           extra_postargs,
262
                           build_temp,
263
                           target_lang)
264
265
    # link ()
266
267
    # -- Miscellaneous methods -----------------------------------------
268
269
    # overwrite the one from CCompiler to support rc and res-files
270
    def object_filenames (self,
271
                          source_filenames,
272
                          strip_dir=0,
273
                          output_dir=''):
274
        if output_dir is None: output_dir = ''
275
        obj_names = []
276
        for src_name in source_filenames:
277
            # use normcase to make sure '.rc' is really '.rc' and not '.RC'
278
            (base, ext) = os.path.splitext (os.path.normcase(src_name))
279
            if ext not in (self.src_extensions + ['.rc','.res']):
280
                raise UnknownFileError, \
281
                      "unknown file type '%s' (from '%s')" % \
282
                      (ext, src_name)
283
            if strip_dir:
284
                base = os.path.basename (base)
285
            if ext == '.res' or ext == '.rc':
286
                # these need to be compiled to object files
287
                obj_names.append (os.path.join (output_dir,
288
                                            base + ext + self.obj_extension))
289
            else:
290
                obj_names.append (os.path.join (output_dir,
291
                                            base + self.obj_extension))
292
        return obj_names
293
294
    # object_filenames ()
295
296
# class CygwinCCompiler
297
298
299
# the same as cygwin plus some additional parameters
300
class Mingw32CCompiler (CygwinCCompiler):
301
302
    compiler_type = 'mingw32'
303
304
    def __init__ (self,
305
                  verbose=0,
306
                  dry_run=0,
307
                  force=0):
308
309
        CygwinCCompiler.__init__ (self, verbose, dry_run, force)
310
311
        # ld_version >= "2.13" support -shared so use it instead of
312
        # -mdll -static
313
        if self.ld_version >= "2.13":
314
            shared_option = "-shared"
315
        else:
316
            shared_option = "-mdll -static"
317
318
        # A real mingw32 doesn't need to specify a different entry point,
319
        # but cygwin 2.91.57 in no-cygwin-mode needs it.
320
        if self.gcc_version <= "2.91.57":
321
            entry_point = '--entry _DllMain@12'
322
        else:
323
            entry_point = ''
324
325
        if self.gcc_version < '4' or is_cygwingcc():
326
            no_cygwin = ' -mno-cygwin'
327
        else:
328
            no_cygwin = ''
329
330
        self.set_executables(compiler='gcc%s -O -Wall' % no_cygwin,
331
                             compiler_so='gcc%s -mdll -O -Wall' % no_cygwin,
332
                             compiler_cxx='g++%s -O -Wall' % no_cygwin,
333
                             linker_exe='gcc%s' % no_cygwin,
334
                             linker_so='%s%s %s %s'
335
                                    % (self.linker_dll, no_cygwin,
336
                                       shared_option, entry_point))
337
        # Maybe we should also append -mthreads, but then the finished
338
        # dlls need another dll (mingwm10.dll see Mingw32 docs)
339
        # (-mthreads: Support thread-safe exception handling on `Mingw32')
340
341
        # no additional libraries needed
342
        self.dll_libraries=[]
343
344
        # Include the appropriate MSVC runtime library if Python was built
345
        # with MSVC 7.0 or later.
346
        self.dll_libraries = get_msvcr()
347
348
    # __init__ ()
349
350
# class Mingw32CCompiler
351
352
# Because these compilers aren't configured in Python's pyconfig.h file by
353
# default, we should at least warn the user if he is using a unmodified
354
# version.
355
356
CONFIG_H_OK = "ok"
357
CONFIG_H_NOTOK = "not ok"
358
CONFIG_H_UNCERTAIN = "uncertain"
359
360
def check_config_h():
361
362
    """Check if the current Python installation (specifically, pyconfig.h)
363
    appears amenable to building extensions with GCC.  Returns a tuple
364
    (status, details), where 'status' is one of the following constants:
365
      CONFIG_H_OK
366
        all is well, go ahead and compile
367
      CONFIG_H_NOTOK
368
        doesn't look good
369
      CONFIG_H_UNCERTAIN
370
        not sure -- unable to read pyconfig.h
371
    'details' is a human-readable string explaining the situation.
372
373
    Note there are two ways to conclude "OK": either 'sys.version' contains
374
    the string "GCC" (implying that this Python was built with GCC), or the
375
    installed "pyconfig.h" contains the string "__GNUC__".
376
    """
377
378
    # XXX since this function also checks sys.version, it's not strictly a
379
    # "pyconfig.h" check -- should probably be renamed...
380
381
    from distutils import sysconfig
382
    import string
383
    # if sys.version contains GCC then python was compiled with
384
    # GCC, and the pyconfig.h file should be OK
385
    if string.find(sys.version,"GCC") >= 0:
386
        return (CONFIG_H_OK, "sys.version mentions 'GCC'")
387
388
    fn = sysconfig.get_config_h_filename()
389
    try:
390
        # It would probably better to read single lines to search.
391
        # But we do this only once, and it is fast enough
392
        f = open(fn)
393
        try:
394
            s = f.read()
395
        finally:
396
            f.close()
397
398
    except IOError, exc:
399
        # if we can't read this file, we cannot say it is wrong
400
        # the compiler will complain later about this file as missing
401
        return (CONFIG_H_UNCERTAIN,
402
                "couldn't read '%s': %s" % (fn, exc.strerror))
403
404
    else:
405
        # "pyconfig.h" contains an "#ifdef __GNUC__" or something similar
406
        if string.find(s,"__GNUC__") >= 0:
407
            return (CONFIG_H_OK, "'%s' mentions '__GNUC__'" % fn)
408
        else:
409
            return (CONFIG_H_NOTOK, "'%s' does not mention '__GNUC__'" % fn)
410
411
412
413
def get_versions():
414
    """ Try to find out the versions of gcc, ld and dllwrap.
415
        If not possible it returns None for it.
416
    """
417
    from distutils.version import LooseVersion
418
    from distutils.spawn import find_executable
419
    import re
420
421
    gcc_exe = find_executable('gcc')
422
    if gcc_exe:
423
        out = os.popen(gcc_exe + ' -dumpversion','r')
424
        out_string = out.read()
425
        out.close()
426
        result = re.search('(\d+\.\d+(\.\d+)*)',out_string)
427
        if result:
428
            gcc_version = LooseVersion(result.group(1))
429
        else:
430
            gcc_version = None
431
    else:
432
        gcc_version = None
433
    ld_exe = find_executable('ld')
434
    if ld_exe:
435
        out = os.popen(ld_exe + ' -v','r')
436
        out_string = out.read()
437
        out.close()
438
        result = re.search('(\d+\.\d+(\.\d+)*)',out_string)
439
        if result:
440
            ld_version = LooseVersion(result.group(1))
441
        else:
442
            ld_version = None
443
    else:
444
        ld_version = None
445
    dllwrap_exe = find_executable('dllwrap')
446
    if dllwrap_exe:
447
        out = os.popen(dllwrap_exe + ' --version','r')
448
        out_string = out.read()
449
        out.close()
450
        result = re.search(' (\d+\.\d+(\.\d+)*)',out_string)
451
        if result:
452
            dllwrap_version = LooseVersion(result.group(1))
453
        else:
454
            dllwrap_version = None
455
    else:
456
        dllwrap_version = None
457
    return (gcc_version, ld_version, dllwrap_version)
458
459
def is_cygwingcc():
460
    '''Try to determine if the gcc that would be used is from cygwin.'''
461
    out = os.popen('gcc -dumpmachine', 'r')
462
    out_string = out.read()
463
    out.close()
464
    # out_string is the target triplet cpu-vendor-os
465
    # Cygwin's gcc sets the os to 'cygwin'
466
    return out_string.strip().endswith('cygwin')
(-)pypy2-v5.6.0-src/lib-python/2.7/distutils/emxccompiler.py (-3 / +11 lines)
Lines 65-72 Link Here
65
        # XXX optimization, warnings etc. should be customizable.
65
        # XXX optimization, warnings etc. should be customizable.
66
        self.set_executables(compiler='gcc -Zomf -Zmt -O3 -fomit-frame-pointer -mprobe -Wall',
66
        self.set_executables(compiler='gcc -Zomf -Zmt -O3 -fomit-frame-pointer -mprobe -Wall',
67
                             compiler_so='gcc -Zomf -Zmt -O3 -fomit-frame-pointer -mprobe -Wall',
67
                             compiler_so='gcc -Zomf -Zmt -O3 -fomit-frame-pointer -mprobe -Wall',
68
                             compiler_cxx='g++ -Zomf -Zmt -O3 -fomit-frame-pointer -mprobe -Wall',
69
                             compiler_so_cxx='g++ -Zomf -Zmt -O3 -fomit-frame-pointer -mprobe -Wall',
68
                             linker_exe='gcc -Zomf -Zmt -Zcrtdll',
70
                             linker_exe='gcc -Zomf -Zmt -Zcrtdll',
69
                             linker_so='gcc -Zomf -Zmt -Zcrtdll -Zdll')
71
                             linker_so='gcc -Zomf -Zmt -Zcrtdll -Zdll',
72
                             linker_exe_cxx='g++ -Zomf -Zmt -Zcrtdll',
73
                             linker_so_cxx='g++ -Zomf -Zmt -Zcrtdll -Zdll')
70
74
71
        # want the gcc library statically linked (so that we don't have
75
        # want the gcc library statically linked (so that we don't have
72
        # to distribute a version dependent on the compiler we have)
76
        # to distribute a version dependent on the compiler we have)
Lines 83-90 Link Here
83
                raise CompileError, msg
87
                raise CompileError, msg
84
        else: # for other files use the C-compiler
88
        else: # for other files use the C-compiler
85
            try:
89
            try:
86
                self.spawn(self.compiler_so + cc_args + [src, '-o', obj] +
90
                if self.detect_language(src) == 'c++':
87
                           extra_postargs)
91
                    self.spawn(self.compiler_so_cxx + cc_args + [src, '-o', obj] +
92
                               extra_postargs)
93
                else:
94
                    self.spawn(self.compiler_so + cc_args + [src, '-o', obj] +
95
                               extra_postargs)
88
            except DistutilsExecError, msg:
96
            except DistutilsExecError, msg:
89
                raise CompileError, msg
97
                raise CompileError, msg
90
98
(-)pypy2-v5.6.0-src/lib-python/2.7/distutils/sysconfig_cpython.py (-6 / +20 lines)
Lines 171-180 Link Here
171
                _osx_support.customize_compiler(_config_vars)
171
                _osx_support.customize_compiler(_config_vars)
172
                _config_vars['CUSTOMIZED_OSX_COMPILER'] = 'True'
172
                _config_vars['CUSTOMIZED_OSX_COMPILER'] = 'True'
173
173
174
        (cc, cxx, opt, cflags, ccshared, ldshared, so_ext, ar, ar_flags) = \
174
        (cc, cxx, ccshared, ldshared, ldcxxshared, so_ext, ar, ar_flags) = \
175
            get_config_vars('CC', 'CXX', 'OPT', 'CFLAGS',
175
            get_config_vars('CC', 'CXX', 'CCSHARED', 'LDSHARED', 'LDCXXSHARED',
176
                            'CCSHARED', 'LDSHARED', 'SO', 'AR',
176
                            'SO', 'AR', 'ARFLAGS')
177
                            'ARFLAGS')
177
178
        cflags = ''
179
        cxxflags = ''
178
180
179
        if 'CC' in os.environ:
181
        if 'CC' in os.environ:
180
            newcc = os.environ['CC']
182
            newcc = os.environ['CC']
Lines 189-207 Link Here
189
            cxx = os.environ['CXX']
191
            cxx = os.environ['CXX']
190
        if 'LDSHARED' in os.environ:
192
        if 'LDSHARED' in os.environ:
191
            ldshared = os.environ['LDSHARED']
193
            ldshared = os.environ['LDSHARED']
194
        if 'LDCXXSHARED' in os.environ:
195
            ldcxxshared = os.environ['LDCXXSHARED']
192
        if 'CPP' in os.environ:
196
        if 'CPP' in os.environ:
193
            cpp = os.environ['CPP']
197
            cpp = os.environ['CPP']
194
        else:
198
        else:
195
            cpp = cc + " -E"           # not always
199
            cpp = cc + " -E"           # not always
196
        if 'LDFLAGS' in os.environ:
200
        if 'LDFLAGS' in os.environ:
197
            ldshared = ldshared + ' ' + os.environ['LDFLAGS']
201
            ldshared = ldshared + ' ' + os.environ['LDFLAGS']
202
            ldcxxshared = ldcxxshared + ' ' + os.environ['LDFLAGS']
198
        if 'CFLAGS' in os.environ:
203
        if 'CFLAGS' in os.environ:
199
            cflags = opt + ' ' + os.environ['CFLAGS']
204
            cflags = os.environ['CFLAGS']
200
            ldshared = ldshared + ' ' + os.environ['CFLAGS']
205
            ldshared = ldshared + ' ' + os.environ['CFLAGS']
206
        if 'CXXFLAGS' in os.environ:
207
            cxxflags = os.environ['CXXFLAGS']
208
            ldcxxshared = ldcxxshared + ' ' + os.environ['CXXFLAGS']
201
        if 'CPPFLAGS' in os.environ:
209
        if 'CPPFLAGS' in os.environ:
202
            cpp = cpp + ' ' + os.environ['CPPFLAGS']
210
            cpp = cpp + ' ' + os.environ['CPPFLAGS']
203
            cflags = cflags + ' ' + os.environ['CPPFLAGS']
211
            cflags = cflags + ' ' + os.environ['CPPFLAGS']
212
            cxxflags = cxxflags + ' ' + os.environ['CPPFLAGS']
204
            ldshared = ldshared + ' ' + os.environ['CPPFLAGS']
213
            ldshared = ldshared + ' ' + os.environ['CPPFLAGS']
214
            ldcxxshared = ldcxxshared + ' ' + os.environ['CPPFLAGS']
205
        if 'AR' in os.environ:
215
        if 'AR' in os.environ:
206
            ar = os.environ['AR']
216
            ar = os.environ['AR']
207
        if 'ARFLAGS' in os.environ:
217
        if 'ARFLAGS' in os.environ:
Lines 210-222 Link Here
210
            archiver = ar + ' ' + ar_flags
220
            archiver = ar + ' ' + ar_flags
211
221
212
        cc_cmd = cc + ' ' + cflags
222
        cc_cmd = cc + ' ' + cflags
223
        cxx_cmd = cxx + ' ' + cxxflags
213
        compiler.set_executables(
224
        compiler.set_executables(
214
            preprocessor=cpp,
225
            preprocessor=cpp,
215
            compiler=cc_cmd,
226
            compiler=cc_cmd,
216
            compiler_so=cc_cmd + ' ' + ccshared,
227
            compiler_so=cc_cmd + ' ' + ccshared,
217
            compiler_cxx=cxx,
228
            compiler_cxx=cxx_cmd,
229
            compiler_so_cxx=cxx_cmd + ' ' + ccshared,
218
            linker_so=ldshared,
230
            linker_so=ldshared,
219
            linker_exe=cc,
231
            linker_exe=cc,
232
            linker_so_cxx=ldcxxshared,
233
            linker_exe_cxx=cxx,
220
            archiver=archiver)
234
            archiver=archiver)
221
235
222
        compiler.shared_lib_extension = so_ext
236
        compiler.shared_lib_extension = so_ext
(-)pypy2-v5.6.0-src/lib-python/2.7/distutils/sysconfig_pypy.py (-12 / +49 lines)
Lines 126-144 Link Here
126
        setattr(compiler, executable, command)
126
        setattr(compiler, executable, command)
127
127
128
    if compiler.compiler_type == "unix":
128
    if compiler.compiler_type == "unix":
129
        compiler.compiler_so.extend(['-O2', '-fPIC', '-Wimplicit'])
129
        cc = ' '.join(compiler.compiler)
130
        cxx = ' '.join(compiler.compiler_cxx)
131
        ldshared = ' '.join(compiler.linker_so)
132
        ldcxxshared = ' '.join(compiler.linker_so_cxx)
133
134
        cflags = ''
135
        cxxflags = ''
136
        ccshared = '-fPIC'
137
138
        if 'CC' in os.environ:
139
            cc = os.environ['CC']
140
        if 'CXX' in os.environ:
141
            cxx = os.environ['CXX']
142
        if 'LDSHARED' in os.environ:
143
            ldshared = os.environ['LDSHARED']
144
        if 'LDCXXSHARED' in os.environ:
145
            ldcxxshared = os.environ['LDCXXSHARED']
146
        if 'CPP' in os.environ:
147
            cpp = os.environ['CPP']
148
        else:
149
            cpp = cc + " -E"           # not always
150
        if 'CPPFLAGS' in os.environ:
151
            cpp = cpp + ' ' + os.environ['CPPFLAGS']
152
            cflags = cflags + ' ' + os.environ['CPPFLAGS']
153
            cxxflags = cxxflags + ' ' + os.environ['CPPFLAGS']
154
            ldshared = ldshared + ' ' + os.environ['CPPFLAGS']
155
            ldcxxshared = ldcxxshared + ' ' + os.environ['CPPFLAGS']
156
        if 'CFLAGS' in os.environ:
157
            cflags = os.environ['CFLAGS']
158
            ldshared = ldshared + ' ' + os.environ['CFLAGS']
159
        if 'CXXFLAGS' in os.environ:
160
            cxxflags = os.environ['CXXFLAGS']
161
            ldcxxshared = ldcxxshared + ' ' + os.environ['CXXFLAGS']
162
        if 'LDFLAGS' in os.environ:
163
            ldshared = ldshared + ' ' + os.environ['LDFLAGS']
164
            ldcxxshared = ldcxxshared + ' ' + os.environ['LDFLAGS']
165
166
        cc_cmd = cc + ' ' + cflags
167
        cxx_cmd = cxx + ' ' + cxxflags
168
        compiler.set_executables(
169
            preprocessor=cpp,
170
            compiler=cc_cmd,
171
            compiler_so=cc_cmd + ' ' + ccshared,
172
            compiler_cxx=cxx_cmd,
173
            compiler_so_cxx=cxx_cmd + ' ' + ccshared,
174
            linker_so=ldshared,
175
            linker_exe=cc,
176
            linker_so_cxx=ldcxxshared,
177
            linker_exe_cxx=cxx)
130
        compiler.shared_lib_extension = get_config_var('SO')
178
        compiler.shared_lib_extension = get_config_var('SO')
131
        if "CPPFLAGS" in os.environ:
132
            cppflags = shlex.split(os.environ["CPPFLAGS"])
133
            for executable in ('compiler', 'compiler_so', 'linker_so'):
134
                customize(executable, cppflags)
135
        if "CFLAGS" in os.environ:
136
            cflags = shlex.split(os.environ["CFLAGS"])
137
            for executable in ('compiler', 'compiler_so', 'linker_so'):
138
                customize(executable, cflags)
139
        if "LDFLAGS" in os.environ:
140
            ldflags = shlex.split(os.environ["LDFLAGS"])
141
            customize('linker_so', ldflags)
142
179
143
180
144
from sysconfig_cpython import (
181
from sysconfig_cpython import (
(-)pypy2-v5.6.0-src/lib-python/2.7/distutils/unixccompiler.py (-26 / +29 lines)
Lines 55-68 Link Here
55
    # are pretty generic; they will probably have to be set by an outsider
55
    # are pretty generic; they will probably have to be set by an outsider
56
    # (eg. using information discovered by the sysconfig about building
56
    # (eg. using information discovered by the sysconfig about building
57
    # Python extensions).
57
    # Python extensions).
58
    executables = {'preprocessor' : None,
58
    executables = {'preprocessor'    : None,
59
                   'compiler'     : ["cc"],
59
                   'compiler'        : ["cc"],
60
                   'compiler_so'  : ["cc"],
60
                   'compiler_so'     : ["cc"],
61
                   'compiler_cxx' : ["c++"],  # pypy: changed, 'cc' is bogus
61
                   'compiler_cxx'    : ["c++"],
62
                   'linker_so'    : ["cc", "-shared"],
62
                   'compiler_so_cxx' : ["c++"],
63
                   'linker_exe'   : ["cc"],
63
                   'linker_so'       : ["cc", "-shared"],
64
                   'archiver'     : ["ar", "-cr"],
64
                   'linker_exe'      : ["cc"],
65
                   'ranlib'       : None,
65
                   'linker_so_cxx'   : ["c++", "-shared"],
66
                   'linker_exe_cxx'  : ["c++"],
67
                   'archiver'        : ["ar", "-cr"],
68
                   'ranlib'          : None,
66
                  }
69
                  }
67
70
68
    if sys.platform[:6] == "darwin":
71
    if sys.platform[:6] == "darwin":
Lines 129-140 Link Here
129
132
130
    def _compile(self, obj, src, ext, cc_args, extra_postargs, pp_opts):
133
    def _compile(self, obj, src, ext, cc_args, extra_postargs, pp_opts):
131
        compiler_so = self.compiler_so
134
        compiler_so = self.compiler_so
135
        compiler_so_cxx = self.compiler_so_cxx
132
        if sys.platform == 'darwin':
136
        if sys.platform == 'darwin':
133
            compiler_so = _osx_support.compiler_fixup(compiler_so,
137
            compiler_so = _osx_support.compiler_fixup(compiler_so,
134
                                                    cc_args + extra_postargs)
138
                                                    cc_args + extra_postargs)
139
            compiler_so_cxx = _osx_support.compiler_fixup(compiler_so_cxx,
140
                                                    cc_args + extra_postargs)
135
        try:
141
        try:
136
            self.spawn(compiler_so + cc_args + [src, '-o', obj] +
142
            if self.detect_language(src) == 'c++':
137
                       extra_postargs)
143
                self.spawn(compiler_so_cxx + cc_args + [src, '-o', obj] +
144
                           extra_postargs)
145
            else:
146
                self.spawn(compiler_so + cc_args + [src, '-o', obj] +
147
                           extra_postargs)
138
        except DistutilsExecError, msg:
148
        except DistutilsExecError, msg:
139
            raise CompileError, msg
149
            raise CompileError, msg
140
150
Lines 191-213 Link Here
191
                ld_args.extend(extra_postargs)
201
                ld_args.extend(extra_postargs)
192
            self.mkpath(os.path.dirname(output_filename))
202
            self.mkpath(os.path.dirname(output_filename))
193
            try:
203
            try:
194
                if target_desc == CCompiler.EXECUTABLE:
204
                if target_lang == "c++":
195
                    linker = self.linker_exe[:]
205
                    if target_desc == CCompiler.EXECUTABLE:
206
                        linker = self.linker_exe_cxx[:]
207
                    else:
208
                        linker = self.linker_so_cxx[:]
196
                else:
209
                else:
197
                    linker = self.linker_so[:]
210
                    if target_desc == CCompiler.EXECUTABLE:
198
                if target_lang == "c++" and self.compiler_cxx:
211
                        linker = self.linker_exe[:]
199
                    # skip over environment variable settings if /usr/bin/env
212
                    else:
200
                    # is used to set up the linker's environment.
213
                        linker = self.linker_so[:]
201
                    # This is needed on OSX. Note: this assumes that the
202
                    # normal and C++ compiler have the same environment
203
                    # settings.
204
                    i = 0
205
                    if os.path.basename(linker[0]) == "env":
206
                        i = 1
207
                        while '=' in linker[i]:
208
                            i = i + 1
209
210
                    linker[i] = self.compiler_cxx[i]
211
214
212
                if sys.platform == 'darwin':
215
                if sys.platform == 'darwin':
213
                    linker = _osx_support.compiler_fixup(linker, ld_args)
216
                    linker = _osx_support.compiler_fixup(linker, ld_args)
(-)pypy2-v5.6.0-src/lib-python/2.7/_osx_support.py (-5 / +5 lines)
Lines 14-26 Link Here
14
# configuration variables that may contain universal build flags,
14
# configuration variables that may contain universal build flags,
15
# like "-arch" or "-isdkroot", that may need customization for
15
# like "-arch" or "-isdkroot", that may need customization for
16
# the user environment
16
# the user environment
17
_UNIVERSAL_CONFIG_VARS = ('CFLAGS', 'LDFLAGS', 'CPPFLAGS', 'BASECFLAGS',
17
_UNIVERSAL_CONFIG_VARS = ('CFLAGS', 'CXXFLAGS', 'LDFLAGS', 'CPPFLAGS',
18
                            'BLDSHARED', 'LDSHARED', 'CC', 'CXX',
18
                          'BASECFLAGS', 'BLDSHARED', 'LDSHARED', 'LDCXXSHARED',
19
                            'PY_CFLAGS', 'PY_LDFLAGS', 'PY_CPPFLAGS',
19
                          'CC', 'CXX', 'PY_CFLAGS', 'PY_LDFLAGS',
20
                            'PY_CORE_CFLAGS')
20
                          'PY_CPPFLAGS', 'PY_CORE_CFLAGS')
21
21
22
# configuration variables that may contain compiler calls
22
# configuration variables that may contain compiler calls
23
_COMPILER_CONFIG_VARS = ('BLDSHARED', 'LDSHARED', 'CC', 'CXX')
23
_COMPILER_CONFIG_VARS = ('BLDSHARED', 'LDSHARED', 'LDCXXSHARED', 'CC', 'CXX')
24
24
25
# prefix added to original configuration variable names
25
# prefix added to original configuration variable names
26
_INITPRE = '_OSX_SUPPORT_INITIAL_'
26
_INITPRE = '_OSX_SUPPORT_INITIAL_'

Return to bug 599918