[pypy-svn] r65713 - in pypy/branch/pyjitpl5-experiments/pypy: jit/backend/llvm translator/platform translator/tool

arigo at codespeak.net arigo at codespeak.net
Wed Jun 10 11:38:26 CEST 2009


Author: arigo
Date: Wed Jun 10 11:38:23 2009
New Revision: 65713

Modified:
   pypy/branch/pyjitpl5-experiments/pypy/jit/backend/llvm/llvm_rffi.py
   pypy/branch/pyjitpl5-experiments/pypy/translator/platform/__init__.py
   pypy/branch/pyjitpl5-experiments/pypy/translator/platform/posix.py
   pypy/branch/pyjitpl5-experiments/pypy/translator/tool/cbuild.py
Log:
Finish to fix compilation of binaries using LLVM.  Hack hack hack...


Modified: pypy/branch/pyjitpl5-experiments/pypy/jit/backend/llvm/llvm_rffi.py
==============================================================================
--- pypy/branch/pyjitpl5-experiments/pypy/jit/backend/llvm/llvm_rffi.py	(original)
+++ pypy/branch/pyjitpl5-experiments/pypy/jit/backend/llvm/llvm_rffi.py	Wed Jun 10 11:38:23 2009
@@ -46,6 +46,7 @@
 
 compilation_info = compilation_info.merge(ExternalCompilationInfo(
     link_extra = [o1name, o2name],
+    use_cpp_linker = True,
     ))
 
 compilation_info._with_ctypes = ctypes_compilation_info

Modified: pypy/branch/pyjitpl5-experiments/pypy/translator/platform/__init__.py
==============================================================================
--- pypy/branch/pyjitpl5-experiments/pypy/translator/platform/__init__.py	(original)
+++ pypy/branch/pyjitpl5-experiments/pypy/translator/platform/__init__.py	Wed Jun 10 11:38:23 2009
@@ -121,8 +121,8 @@
         library_dirs = self._libdirs(eci.library_dirs)
         libraries = self._libs(eci.libraries)
         link_files = self._linkfiles(eci.link_files)
-        return (library_dirs + libraries + self.link_flags +
-                link_files + list(eci.link_extra))
+        return (library_dirs + self.link_flags +
+                link_files + list(eci.link_extra) + libraries)
 
     def _finish_linking(self, ofiles, eci, outputfilename, standalone):
         if outputfilename is None:
@@ -134,7 +134,11 @@
                 exe_name += '.' + self.exe_ext
         else:
             exe_name += '.' + self.so_ext
-        return self._link(self.cc, ofiles, self._link_args_from_eci(eci),
+        if eci.use_cpp_linker:
+            cc_link = 'g++'      # XXX hard-coded so far
+        else:
+            cc_link = self.cc
+        return self._link(cc_link, ofiles, self._link_args_from_eci(eci),
                           standalone, exe_name)
 
     # below are some detailed informations for platforms

Modified: pypy/branch/pyjitpl5-experiments/pypy/translator/platform/posix.py
==============================================================================
--- pypy/branch/pyjitpl5-experiments/pypy/translator/platform/posix.py	(original)
+++ pypy/branch/pyjitpl5-experiments/pypy/translator/platform/posix.py	Wed Jun 10 11:38:23 2009
@@ -86,14 +86,15 @@
             ('INCLUDEDIRS', self._includedirs(rel_includedirs)),
             ('CFLAGS', self.cflags + list(eci.compile_extra)),
             ('LDFLAGS', self.link_flags + list(eci.link_extra)),
-            ('CC', self.cc)
+            ('CC', self.cc),
+            ('CC_LINK', eci.use_cpp_linker and 'g++' or '$(CC)'),
             ]
         for args in definitions:
             m.definition(*args)
 
         rules = [
             ('all', '$(DEFAULT_TARGET)', []),
-            ('$(TARGET)', '$(OBJECTS)', '$(CC) $(LDFLAGS) -o $@ $(OBJECTS) $(LIBDIRS) $(LIBS)'),
+            ('$(TARGET)', '$(OBJECTS)', '$(CC_LINK) $(LDFLAGS) -o $@ $(OBJECTS) $(LIBDIRS) $(LIBS)'),
             ('%.o', '%.c', '$(CC) $(CFLAGS) -o $@ -c $< $(INCLUDEDIRS)'),
             ]
 

Modified: pypy/branch/pyjitpl5-experiments/pypy/translator/tool/cbuild.py
==============================================================================
--- pypy/branch/pyjitpl5-experiments/pypy/translator/tool/cbuild.py	(original)
+++ pypy/branch/pyjitpl5-experiments/pypy/translator/tool/cbuild.py	Wed Jun 10 11:38:23 2009
@@ -20,6 +20,7 @@
                    'export_symbols', 'compile_extra', 'link_extra',
                    'frameworks', 'link_files']
     _DUPLICATES_OK = ['compile_extra', 'link_extra']
+    _EXTRA_ATTRIBUTES = ['use_cpp_linker', 'platform']
 
     def __init__(self,
                  pre_include_bits        = [],
@@ -35,6 +36,7 @@
                  link_extra              = [],
                  frameworks              = [],
                  link_files              = [],
+                 use_cpp_linker          = False,
                  platform                = None):
         """
         pre_include_bits: list of pieces of text that should be put at the top
@@ -80,12 +82,16 @@
         link_files: list of file names which will be directly passed to the
         linker
 
+        use_cpp_linker: a flag to tell if g++ should be used instead of gcc
+        when linking (a bit custom so far)
+
         platform: an object that can identify the platform
         """
         for name in self._ATTRIBUTES:
             value = locals()[name]
             assert isinstance(value, (list, tuple))
             setattr(self, name, tuple(value))
+        self.use_cpp_linker = use_cpp_linker
         if platform is None:
             from pypy.translator.platform import platform
         self.platform = platform
@@ -155,8 +161,8 @@
     from_config_tool = classmethod(from_config_tool)
 
     def _value(self):
-        return tuple([getattr(self, x) for x in self._ATTRIBUTES]
-                     + [self.platform])
+        return tuple([getattr(self, x)
+                          for x in self._ATTRIBUTES + self._EXTRA_ATTRIBUTES])
 
     def __hash__(self):
         return hash(self._value())
@@ -170,10 +176,9 @@
 
     def __repr__(self):
         info = []
-        for attr in self._ATTRIBUTES:
+        for attr in self._ATTRIBUTES + self._EXTRA_ATTRIBUTES:
             val = getattr(self, attr)
             info.append("%s=%s" % (attr, repr(val)))
-        info.append("platform=%s" % repr(self.platform))
         return "<ExternalCompilationInfo (%s)>" % ", ".join(info)
 
     def merge(self, *others):
@@ -203,6 +208,10 @@
                             s.add(elem)
                             attr.append(elem)
                 attrs[name] = attr
+        use_cpp_linker = self.use_cpp_linker
+        for other in others:
+            use_cpp_linker = use_cpp_linker or other.use_cpp_linker
+        attrs['use_cpp_linker'] = use_cpp_linker
         for other in others:
             if other.platform != self.platform:
                 raise Exception("Mixing ECI for different platforms %s and %s"%
@@ -220,7 +229,7 @@
 
     def _copy_attributes(self):
         d = {}
-        for attr in self._ATTRIBUTES:
+        for attr in self._ATTRIBUTES + self._EXTRA_ATTRIBUTES:
             d[attr] = getattr(self, attr)
         return d
 



More information about the Pypy-commit mailing list