[pypy-svn] r59112 - in pypy/branch/cbuild-refactor/pypy: config translator/c translator/c/test translator/platform translator/platform/test translator/tool

fijal at codespeak.net fijal at codespeak.net
Wed Oct 15 17:51:36 CEST 2008


Author: fijal
Date: Wed Oct 15 17:51:34 2008
New Revision: 59112

Added:
   pypy/branch/cbuild-refactor/pypy/translator/platform/distutils_platform.py   (contents, props changed)
   pypy/branch/cbuild-refactor/pypy/translator/platform/test/test_distutils.py   (contents, props changed)
   pypy/branch/cbuild-refactor/pypy/translator/platform/windows.py   (contents, props changed)
Modified:
   pypy/branch/cbuild-refactor/pypy/config/translationoption.py
   pypy/branch/cbuild-refactor/pypy/translator/c/genc.py
   pypy/branch/cbuild-refactor/pypy/translator/c/test/test_genc.py
   pypy/branch/cbuild-refactor/pypy/translator/c/test/test_typed.py
   pypy/branch/cbuild-refactor/pypy/translator/platform/__init__.py
   pypy/branch/cbuild-refactor/pypy/translator/platform/linux.py
   pypy/branch/cbuild-refactor/pypy/translator/platform/test/test_platform.py
   pypy/branch/cbuild-refactor/pypy/translator/tool/cbuild.py
Log:
Delete as much stuff as possible from genc. Create distutils platform, which
is a default if we don't know what to do.


Modified: pypy/branch/cbuild-refactor/pypy/config/translationoption.py
==============================================================================
--- pypy/branch/cbuild-refactor/pypy/config/translationoption.py	(original)
+++ pypy/branch/cbuild-refactor/pypy/config/translationoption.py	Wed Oct 15 17:51:34 2008
@@ -13,6 +13,8 @@
 
 PLATFORMS = [
     'maemo',
+    'host',
+    'distutils',
 ]
 
 translation_optiondescription = OptionDescription(
@@ -360,13 +362,15 @@
     set_platform(config.translation.platform, config.translation.cc)
 
 def get_platform(config):
-    # XXX use config
     opt = config.translation.platform
     if opt == 'maemo':
         from pypy.translator.platform.maemo import Maemo
         return Maemo(config.translation.cc)
     elif opt == 'host':
         from pypy.translator.platform import host
-        return host
+        return host.__class__(config.translation.cc)
+    elif opt == 'distutils':
+        from pypy.translator.platform.distutils_platform import DistutilsPlatform
+        return DistutilsPlatform(config.translation.cc)
     else:
         raise ValueError(opt)

Modified: pypy/branch/cbuild-refactor/pypy/translator/c/genc.py
==============================================================================
--- pypy/branch/cbuild-refactor/pypy/translator/c/genc.py	(original)
+++ pypy/branch/cbuild-refactor/pypy/translator/c/genc.py	Wed Oct 15 17:51:34 2008
@@ -6,8 +6,7 @@
 from pypy.translator.c.extfunc import pre_include_code_lines
 from pypy.translator.llsupport.wrapper import new_wrapper
 from pypy.translator.gensupp import uniquemodulename, NameManager
-from pypy.translator.tool.cbuild import so_ext, ExternalCompilationInfo
-from pypy.translator.tool.cbuild import import_module_from_directory
+from pypy.translator.tool.cbuild import ExternalCompilationInfo
 from pypy.translator.tool.cbuild import check_under_under_thread
 from pypy.rpython.lltypesystem import lltype
 from pypy.tool.udir import udir
@@ -16,6 +15,15 @@
 from pypy.rpython.typesystem import getfunctionptr
 from pypy.translator.c import gc
 
+def import_module_from_directory(dir, modname):
+    file, pathname, description = imp.find_module(modname, [str(dir)])
+    try:
+        mod = imp.load_module(modname, file, pathname, description)
+    finally:
+        if file:
+            file.close()
+    return mod
+
 class ProfOpt(object):
     #XXX assuming gcc style flags for now
     name = "profopt"
@@ -315,7 +323,7 @@
 
 _rpython_startup = _lib.RPython_StartupCode
 _rpython_startup()
-""" % {'so_name': self.c_source_filename.new(ext=so_ext),
+""" % {'so_name': self.c_source_filename.new(ext=self.translator.platform.so_ext),
        'c_entrypoint_name': wrapped_entrypoint_c_name,
        'nargs': len(lltype.typeOf(entrypoint_ptr).TO.ARGS)}
         modfile.write(CODE)

Modified: pypy/branch/cbuild-refactor/pypy/translator/c/test/test_genc.py
==============================================================================
--- pypy/branch/cbuild-refactor/pypy/translator/c/test/test_genc.py	(original)
+++ pypy/branch/cbuild-refactor/pypy/translator/c/test/test_genc.py	Wed Oct 15 17:51:34 2008
@@ -9,7 +9,6 @@
 from pypy.objspace.flow.model import Constant, Variable, SpaceOperation
 from pypy.objspace.flow.model import Block, Link, FunctionGraph
 from pypy.tool.udir import udir
-from pypy.translator.tool.cbuild import make_module_from_c
 from pypy.translator.gensupp import uniquemodulename
 from pypy.translator.backendopt.all import backend_optimizations
 from pypy.translator.interactive import Translation

Modified: pypy/branch/cbuild-refactor/pypy/translator/c/test/test_typed.py
==============================================================================
--- pypy/branch/cbuild-refactor/pypy/translator/c/test/test_typed.py	(original)
+++ pypy/branch/cbuild-refactor/pypy/translator/c/test/test_typed.py	Wed Oct 15 17:51:34 2008
@@ -10,11 +10,6 @@
 from pypy.translator.translator import TranslationContext
 from pypy.rlib.rarithmetic import r_uint, r_ulonglong, r_longlong, intmask
 
-# XXX this tries to make compiling faster for full-scale testing
-from pypy.translator.tool import cbuild
-cbuild.enable_fast_compilation()
-
-
 class CompilationTestCase:
 
     def annotatefunc(self, func, argtypes=None):

Modified: pypy/branch/cbuild-refactor/pypy/translator/platform/__init__.py
==============================================================================
--- pypy/branch/cbuild-refactor/pypy/translator/platform/__init__.py	(original)
+++ pypy/branch/cbuild-refactor/pypy/translator/platform/__init__.py	Wed Oct 15 17:51:34 2008
@@ -3,12 +3,28 @@
 platform.
 """
 
-import sys, py
+import sys, py, os
 
 from pypy.tool.ansi_print import ansi_log
 log = py.log.Producer("platform")
 py.log.setconsumer("platform", ansi_log)
 
+from subprocess import PIPE, Popen
+
+def _run_subprocess(executable, args, env=None):
+    if isinstance(args, str):
+        args = str(executable) + ' ' + args
+        shell = True
+    else:
+        if args is None:
+            args = [str(executable)]
+        else:
+            args = [str(executable)] + args
+        shell = False
+    pipe = Popen(args, stdout=PIPE, stderr=PIPE, shell=shell, env=env)
+    stdout, stderr = pipe.communicate()
+    return pipe.returncode, stdout, stderr
+
 class CompilationError(Exception):
     def __init__(self, out, err):
         self.out = out
@@ -32,8 +48,10 @@
     def compile(self, cfiles, eci, outputfilename=None, standalone=True):
         raise NotImplementedError("Pure abstract baseclass")
 
-    def execute(self, file_to_exec, args=None, env=None):
-        raise NotImplementedError("Pure abstract baseclass")
+    def execute(self, executable, args=None, env=None):
+        returncode, stdout, stderr = _run_subprocess(str(executable), args,
+                                                     env)
+        return ExecutionResult(returncode, stdout, stderr)
 
     def gen_makefile(self, cfiles, eci, exe_name=None, path=None):
         raise NotImplementedError("Pure abstract baseclass")
@@ -69,9 +87,13 @@
 elif sys.platform == 'darwin':
     from pypy.translator.platform.darwin import Darwin
     host = Darwin()
+elif os.name == 'nt':
+    from pypy.translator.platform.windows import Windows
+    host = Windows()
 else:
-    xxx
-    
+    # pray
+    from pypy.translator.platform.distutils_platform import DistutilsPlatform
+    host = DistutilsPlatform()
 
 platform = host
 
@@ -83,6 +105,9 @@
     elif new_platform == 'maemo':
         from pypy.translator.platform.maemo import Maemo
         platform = Maemo(cc)
+    elif new_platform == 'distutils':
+        from pypy.translator.platform.distutils_platform import DistutilsPlatform
+        platform = DistutilsPlatform()
     else:
         raise NotImplementedError("platform = %s" % (new_platform,))
         

Added: pypy/branch/cbuild-refactor/pypy/translator/platform/distutils_platform.py
==============================================================================
--- (empty file)
+++ pypy/branch/cbuild-refactor/pypy/translator/platform/distutils_platform.py	Wed Oct 15 17:51:34 2008
@@ -0,0 +1,153 @@
+
+from pypy.translator.platform import Platform, log, CompilationError
+import py, sys, os
+from pypy.translator.tool import stdoutcapture
+
+def log_spawned_cmd(spawn):
+    def spawn_and_log(cmd, *args, **kwds):
+        log.execute(' '.join(cmd))
+        return spawn(cmd, *args, **kwds)
+    return spawn_and_log
+
+CFLAGS = ['-O3']
+
+class DistutilsPlatform(Platform):
+    """ This is a generic distutils platform. I hope it'll go away at some
+    point soon completely
+    """
+    def __init__(self, cc=None):
+        self.cc = cc
+    
+    def _ensure_correct_math(self):
+        if self.name != 'win32':
+            return # so far
+        from distutils import sysconfig
+        gcv = sysconfig.get_config_vars()
+        opt = gcv.get('OPT') # not always existent
+        if opt and '/Op' not in opt:
+            opt += '/Op'
+        gcv['OPT'] = opt
+    
+    def compile(self, cfilenames, eci, outputfilename=None, standalone=True):
+        self._ensure_correct_math()
+        self.cfilenames = cfilenames
+        if standalone:
+            ext = ''
+        else:
+            ext = so_ext
+        self.standalone = standalone
+        self.libraries = list(eci.libraries)
+        self.include_dirs = list(eci.include_dirs)
+        self.library_dirs = list(eci.library_dirs)
+        self.compile_extra = list(eci.compile_extra)
+        self.link_extra = list(eci.link_extra)
+        self.frameworks = list(eci.frameworks)
+        if not self.name in ('win32', 'darwin'): # xxx
+            if 'm' not in self.libraries:
+                self.libraries.append('m')
+            self.compile_extra += CFLAGS + ['-fomit-frame-pointer']
+            if 'pthread' not in self.libraries:
+                self.libraries.append('pthread')
+            if self.name != 'sunos5': 
+                self.compile_extra += ['-pthread']
+                self.link_extra += ['-pthread']
+            else:
+                self.compile_extra += ['-pthreads']
+                self.link_extra += ['-lpthread']
+        if self.name == 'win32':
+            self.link_extra += ['/DEBUG'] # generate .pdb file
+        if self.name == 'darwin':
+            # support Fink & Darwinports
+            for s in ('/sw/', '/opt/local/'):
+                if s + 'include' not in self.include_dirs and \
+                   os.path.exists(s + 'include'):
+                    self.include_dirs.append(s + 'include')
+                if s + 'lib' not in self.library_dirs and \
+                   os.path.exists(s + 'lib'):
+                    self.library_dirs.append(s + 'lib')
+            self.compile_extra += CFLAGS + ['-fomit-frame-pointer']
+            for framework in self.frameworks:
+                self.link_extra += ['-framework', framework]
+
+        if outputfilename is None:
+            self.outputfilename = py.path.local(cfilenames[0]).new(ext=ext)
+        else:
+            self.outputfilename = py.path.local(outputfilename)
+        self.eci = eci
+        import distutils.errors
+        basename = self.outputfilename.new(ext='')
+        data = ''
+        try:
+            saved_environ = os.environ.copy()
+            try:
+                c = stdoutcapture.Capture(mixed_out_err = True)
+                self._build()
+            finally:
+                # workaround for a distutils bugs where some env vars can
+                # become longer and longer every time it is used
+                for key, value in saved_environ.items():
+                    if os.environ.get(key) != value:
+                        os.environ[key] = value
+                foutput, foutput = c.done()
+                data = foutput.read()
+                if data:
+                    fdump = basename.new(ext='errors').open("w")
+                    fdump.write(data)
+                    fdump.close()
+        except (distutils.errors.CompileError,
+                distutils.errors.LinkError), e:
+            data = data.rstrip()
+            if data:
+                data += '\n'
+            data += str(e)
+            raise CompilationError('', data)
+        except:
+            print >>sys.stderr, data
+            raise
+        return self.outputfilename
+
+    def _build(self):
+        from distutils.ccompiler import new_compiler
+        from distutils import sysconfig
+        compiler = new_compiler(force=1)
+        if self.cc is not None:
+            for c in '''compiler compiler_so compiler_cxx
+                        linker_exe linker_so'''.split():
+                compiler.executables[c][0] = self.cc
+        if not self.standalone:
+            sysconfig.customize_compiler(compiler) # XXX
+        compiler.spawn = log_spawned_cmd(compiler.spawn)
+        objects = []
+        for cfile in self.cfilenames:
+            cfile = py.path.local(cfile)
+            compile_extra = self.compile_extra[:]
+            # -frandom-seed is only to try to be as reproducable as possible
+            if 0 and self.fix_gcc_random_seed:
+                compile_extra.append('-frandom-seed=%s' % (cfile.basename,))
+                # XXX horrible workaround for a bug of profiling in gcc on
+                # OS X with functions containing a direct call to fork()
+                if '/*--no-profiling-for-this-file!--*/' in cfile.read():
+                    compile_extra = [arg for arg in compile_extra
+                                     if not arg.startswith('-fprofile-')]
+
+            old = cfile.dirpath().chdir()
+            try:
+                res = compiler.compile([cfile.basename],
+                                       include_dirs=self.eci.include_dirs,
+                                       extra_preargs=compile_extra)
+                assert len(res) == 1
+                cobjfile = py.path.local(res[0])
+                assert cobjfile.check()
+                objects.append(str(cobjfile))
+            finally:
+                old.chdir()
+
+        if self.standalone:
+            cmd = compiler.link_executable
+        else:
+            cmd = compiler.link_shared_object
+        cmd(objects, str(self.outputfilename),
+            libraries=self.eci.libraries,
+            extra_preargs=self.link_extra,
+            library_dirs=self.eci.library_dirs)
+

Modified: pypy/branch/cbuild-refactor/pypy/translator/platform/linux.py
==============================================================================
--- pypy/branch/cbuild-refactor/pypy/translator/platform/linux.py	(original)
+++ pypy/branch/cbuild-refactor/pypy/translator/platform/linux.py	Wed Oct 15 17:51:34 2008
@@ -1,24 +1,9 @@
 
 import py, os
 from pypy.translator.platform import Platform, CompilationError, ExecutionResult
-from pypy.translator.platform import log
-from subprocess import PIPE, Popen
+from pypy.translator.platform import log, _run_subprocess
 from pypy.tool import autopath
 
-def _run_subprocess(executable, args, env=None):
-    if isinstance(args, str):
-        args = str(executable) + ' ' + args
-        shell = True
-    else:
-        if args is None:
-            args = [str(executable)]
-        else:
-            args = [str(executable)] + args
-        shell = False
-    pipe = Popen(args, stdout=PIPE, stderr=PIPE, shell=shell, env=env)
-    stdout, stderr = pipe.communicate()
-    return pipe.returncode, stdout, stderr
-
 class Definition(object):
     def __init__(self, name, value):
         self.name = name
@@ -192,11 +177,6 @@
         self._execute_c_compiler(cc, args, exe_name)
         return exe_name
 
-    def execute(self, executable, args=None, env=None):
-        returncode, stdout, stderr = _run_subprocess(str(executable), args,
-                                                     env)
-        return ExecutionResult(returncode, stdout, stderr)
-
     def gen_makefile(self, cfiles, eci, exe_name=None, path=None):
         cfiles = [py.path.local(f) for f in cfiles]
         cfiles += [py.path.local(f) for f in eci.separate_module_files]

Added: pypy/branch/cbuild-refactor/pypy/translator/platform/test/test_distutils.py
==============================================================================
--- (empty file)
+++ pypy/branch/cbuild-refactor/pypy/translator/platform/test/test_distutils.py	Wed Oct 15 17:51:34 2008
@@ -0,0 +1,10 @@
+
+from pypy.translator.platform.test.test_platform import TestPlatform as BasicTest
+from pypy.translator.platform.distutils_platform import DistutilsPlatform
+import py
+
+class TestDistutils(BasicTest):
+    platform = DistutilsPlatform()
+
+    def test_nice_errors(self):
+        py.test.skip("Unsupported")

Modified: pypy/branch/cbuild-refactor/pypy/translator/platform/test/test_platform.py
==============================================================================
--- pypy/branch/cbuild-refactor/pypy/translator/platform/test/test_platform.py	(original)
+++ pypy/branch/cbuild-refactor/pypy/translator/platform/test/test_platform.py	Wed Oct 15 17:51:34 2008
@@ -1,7 +1,8 @@
 
 import py, sys
 from pypy.tool.udir import udir
-from pypy.translator.platform import host, CompilationError, Platform
+from pypy.translator.platform import CompilationError, Platform
+from pypy.translator.platform import host
 from pypy.translator.tool.cbuild import ExternalCompilationInfo
 
 class TestPlatform(object):

Added: pypy/branch/cbuild-refactor/pypy/translator/platform/windows.py
==============================================================================
--- (empty file)
+++ pypy/branch/cbuild-refactor/pypy/translator/platform/windows.py	Wed Oct 15 17:51:34 2008
@@ -0,0 +1,7 @@
+
+from pypy.translator.platform.distutils_platform import DistutilsPlatform
+
+class Windows(DistutilsPlatform):
+    name = "win32"
+    so_ext = 'dll'
+

Modified: pypy/branch/cbuild-refactor/pypy/translator/tool/cbuild.py
==============================================================================
--- pypy/branch/cbuild-refactor/pypy/translator/tool/cbuild.py	(original)
+++ pypy/branch/cbuild-refactor/pypy/translator/tool/cbuild.py	Wed Oct 15 17:51:34 2008
@@ -1,7 +1,6 @@
 import autopath
 
 import os, sys, inspect, re, imp
-from pypy.translator.tool import stdoutcapture
 from pypy.tool.autopath import pypydir
 from pypy.translator.platform import host
 
@@ -280,227 +279,6 @@
         d['separate_module_sources'] = ()
         return ExternalCompilationInfo(**d)
 
-if sys.platform == 'win32':
-    so_ext = '.dll'
-else:
-    so_ext = '.so'
-
-def compiler_command():
-    # e.g. for tcc, you might set this to
-    #    "tcc -shared -o %s.so %s.c"
-    return os.getenv('PYPY_CC')
-
-def enable_fast_compilation():
-    if sys.platform == 'win32':
-        dash = '/'
-    else:
-        dash = '-'
-    from distutils import sysconfig
-    gcv = sysconfig.get_config_vars()
-    opt = gcv.get('OPT') # not always existent
-    if opt:
-        opt = re.sub('%sO\d+' % dash, '%sO0' % dash, opt)
-    else:
-        opt = '%sO0' % dash
-    gcv['OPT'] = opt
-
-def ensure_correct_math():
-    if sys.platform != 'win32':
-        return # so far
-    from distutils import sysconfig
-    gcv = sysconfig.get_config_vars()
-    opt = gcv.get('OPT') # not always existent
-    if opt and '/Op' not in opt:
-        opt += '/Op'
-    gcv['OPT'] = opt
-
-def next_unique_name(modbasename, tmpdir):
-    modname = modbasename
-    while 1:
-        if not tmpdir.join(modname + so_ext).check():
-            break
-        num += 1
-        modname = '%s_%d' % (modbasename, num)
-    return modname
-
-def compile_c_module(cfiles, modbasename, eci, tmpdir=None):
-    eci = eci.convert_sources_to_files()
-    cfiles.extend(eci.separate_module_files)
-    compiler = CCompiler(cfiles, eci, standalone=False)
-    compiler.build()
-    return str(compiler.outputfilename)
-
-def make_module_from_c(cfile, eci):
-    cfile = py.path.local(cfile)
-    modname = cfile.purebasename
-    compile_c_module([cfile], modname, eci)
-    return import_module_from_directory(cfile.dirpath(), modname)
-
-def import_module_from_directory(dir, modname):
-    file, pathname, description = imp.find_module(modname, [str(dir)])
-    try:
-        mod = imp.load_module(modname, file, pathname, description)
-    finally:
-        if file:
-            file.close()
-    return mod
-
-
-def log_spawned_cmd(spawn):
-    def spawn_and_log(cmd, *args, **kwds):
-        log.execute(' '.join(cmd))
-        return spawn(cmd, *args, **kwds)
-    return spawn_and_log
-
-
-class CompilationError(Exception):
-    pass
-
-class CCompiler:
-    fix_gcc_random_seed = False
-
-    def __init__(self, cfilenames, eci, outputfilename=None,
-                 compiler_exe=None, profbased=None, standalone=True):
-        XXX
-        self.cfilenames = cfilenames
-        if standalone:
-            ext = ''
-        else:
-            ext = so_ext
-        self.standalone = standalone
-        self.libraries = list(eci.libraries)
-        self.include_dirs = list(eci.include_dirs)
-        self.library_dirs = list(eci.library_dirs)
-        self.compile_extra = list(eci.compile_extra)
-        self.link_extra = list(eci.link_extra)
-        self.frameworks = list(eci.frameworks)
-        if compiler_exe is not None:
-            self.compiler_exe = compiler_exe
-        else:
-            self.compiler_exe = eci.platform.get_compiler()
-        self.profbased = profbased
-        if not sys.platform in ('win32', 'darwin'): # xxx
-            if 'm' not in self.libraries:
-                self.libraries.append('m')
-            self.compile_extra += CFLAGS + ['-fomit-frame-pointer']
-            if 'pthread' not in self.libraries:
-                self.libraries.append('pthread')
-            if sys.platform != 'sunos5': 
-                self.compile_extra += ['-pthread']
-                self.link_extra += ['-pthread']
-            else:
-                self.compile_extra += ['-pthreads']
-                self.link_extra += ['-lpthread']
-        if sys.platform == 'win32':
-            self.link_extra += ['/DEBUG'] # generate .pdb file
-        if sys.platform == 'darwin':
-            # support Fink & Darwinports
-            for s in ('/sw/', '/opt/local/'):
-                if s + 'include' not in self.include_dirs and \
-                   os.path.exists(s + 'include'):
-                    self.include_dirs.append(s + 'include')
-                if s + 'lib' not in self.library_dirs and \
-                   os.path.exists(s + 'lib'):
-                    self.library_dirs.append(s + 'lib')
-            self.compile_extra += CFLAGS + ['-fomit-frame-pointer']
-            for framework in self.frameworks:
-                self.link_extra += ['-framework', framework]
-
-        if outputfilename is None:
-            self.outputfilename = py.path.local(cfilenames[0]).new(ext=ext)
-        else:
-            self.outputfilename = py.path.local(outputfilename)
-        self.eci = eci
-
-    def build(self, noerr=False):
-        import distutils.errors
-        basename = self.outputfilename.new(ext='')
-        data = ''
-        try:
-            saved_environ = os.environ.copy()
-            try:
-                c = stdoutcapture.Capture(mixed_out_err = True)
-                if self.profbased is None:
-                    self._build()
-                else:
-                    ProfDriver, args = self.profbased
-                    profdrv = ProfDriver(self)
-                    dolog = getattr(log, profdrv.name)
-                    dolog(args)
-                    profdrv.first()
-                    dolog('Gathering profile data from: %s %s' % (
-                           str(self.outputfilename), args))
-                    profdrv.probe(str(self.outputfilename),args)
-                    profdrv.after()
-            finally:
-                # workaround for a distutils bugs where some env vars can
-                # become longer and longer every time it is used
-                for key, value in saved_environ.items():
-                    if os.environ.get(key) != value:
-                        os.environ[key] = value
-                foutput, foutput = c.done()
-                data = foutput.read()
-                if data:
-                    fdump = basename.new(ext='errors').open("w")
-                    fdump.write(data)
-                    fdump.close()
-        except (distutils.errors.CompileError,
-                distutils.errors.LinkError), e:
-            data = data.rstrip()
-            if data:
-                data += '\n'
-            data += str(e)
-            raise CompilationError(data)
-        except:
-            if not noerr:
-                print >>sys.stderr, data
-            raise
-
-    def _build(self):
-        from distutils.ccompiler import new_compiler
-        from distutils import sysconfig
-        compiler = new_compiler(force=1)
-        if self.compiler_exe is not None:
-            for c in '''compiler compiler_so compiler_cxx
-                        linker_exe linker_so'''.split():
-                compiler.executables[c][0] = self.compiler_exe
-        if not self.standalone:
-            sysconfig.customize_compiler(compiler) # XXX
-        compiler.spawn = log_spawned_cmd(compiler.spawn)
-        objects = []
-        for cfile in self.cfilenames:
-            cfile = py.path.local(cfile)
-            compile_extra = self.compile_extra[:]
-            # -frandom-seed is only to try to be as reproducable as possible
-            if self.fix_gcc_random_seed:
-                compile_extra.append('-frandom-seed=%s' % (cfile.basename,))
-                # XXX horrible workaround for a bug of profiling in gcc on
-                # OS X with functions containing a direct call to fork()
-                if '/*--no-profiling-for-this-file!--*/' in cfile.read():
-                    compile_extra = [arg for arg in compile_extra
-                                     if not arg.startswith('-fprofile-')]
-
-            old = cfile.dirpath().chdir()
-            try:
-                res = compiler.compile([cfile.basename],
-                                       include_dirs=self.eci.include_dirs,
-                                       extra_preargs=compile_extra)
-                assert len(res) == 1
-                cobjfile = py.path.local(res[0])
-                assert cobjfile.check()
-                objects.append(str(cobjfile))
-            finally:
-                old.chdir()
-
-        if self.standalone:
-            cmd = compiler.link_executable
-        else:
-            cmd = compiler.link_shared_object
-        cmd(objects, str(self.outputfilename),
-            libraries=self.eci.libraries,
-            extra_preargs=self.link_extra,
-            library_dirs=self.eci.library_dirs)
-
 def check_under_under_thread():
     xxx
     from pypy.tool.udir import udir



More information about the Pypy-commit mailing list