[pypy-svn] r62861 - in pypy/trunk/pypy/translator: c platform

afa at codespeak.net afa at codespeak.net
Wed Mar 11 17:13:19 CET 2009


Author: afa
Date: Wed Mar 11 17:13:16 2009
New Revision: 62861

Modified:
   pypy/trunk/pypy/translator/c/gc.py
   pypy/trunk/pypy/translator/c/genc.py
   pypy/trunk/pypy/translator/platform/windows.py
Log:
When translating with --gc=boehm, use the compilation flags we configured before.


Modified: pypy/trunk/pypy/translator/c/gc.py
==============================================================================
--- pypy/trunk/pypy/translator/c/gc.py	(original)
+++ pypy/trunk/pypy/translator/c/gc.py	Wed Mar 11 17:13:16 2009
@@ -7,6 +7,7 @@
 from pypy.rpython.memory.gctransform import \
      refcounting, boehm, framework, llvmgcroot, asmgcroot
 from pypy.rpython.lltypesystem import lltype, llmemory
+from pypy.translator.tool.cbuild import ExternalCompilationInfo
 
 class BasicGcPolicy(object):
     requires_stackless = False
@@ -36,16 +37,17 @@
     def struct_after_definition(self, defnode):
         return []
 
-    def gc_libraries(self):
-        return []
+    def compilation_info(self):
+        if not self.db:
+            return ExternalCompilationInfo()
 
-    def pre_pre_gc_code(self): # code that goes before include g_prerequisite.h
         gct = self.db.gctransformer
-        yield '/* using %s */' % (gct.__class__.__name__,)
-        yield '#define MALLOC_ZERO_FILLED %d' % (gct.malloc_zero_filled,)
-
-    def pre_gc_code(self):
-        return ['typedef void *GC_hidden_pointer;']
+        return ExternalCompilationInfo(
+            pre_include_bits=['/* using %s */' % (gct.__class__.__name__,),
+                              '#define MALLOC_ZERO_FILLED %d' % (gct.malloc_zero_filled,),
+                              ],
+            post_include_bits=['typedef void *GC_hidden_pointer;']
+            )
 
     def gc_startup_code(self):
         return []
@@ -193,25 +195,26 @@
     def rtti_node_factory(self):
         return BoehmGcRuntimeTypeInfo_OpaqueNode
 
-    def gc_libraries(self):
-        if sys.platform == 'win32':
-            return ['gc_pypy']
-        return ['gc']
+    def compilation_info(self):
+        eci = BasicGcPolicy.compilation_info(self)
 
-    def pre_pre_gc_code(self):
-        for line in BasicGcPolicy.pre_pre_gc_code(self):
-            yield line
+        from pypy.rpython.tool.rffi_platform import check_boehm
+        eci = eci.merge(check_boehm())
+
+        pre_include_bits = []
         if sys.platform == "linux2":
-            yield "#define _REENTRANT 1"
-            yield "#define GC_LINUX_THREADS 1"
+            pre_include_bits += ["#define _REENTRANT 1",
+                                 "#define GC_LINUX_THREADS 1"]
         if sys.platform != "win32":
             # GC_REDIRECT_TO_LOCAL is not supported on Win32 by gc6.8
-            yield "#define GC_REDIRECT_TO_LOCAL 1"
-        yield '#include <gc/gc.h>'
-        yield '#define USING_BOEHM_GC'
+            pre_include_bits += ["#define GC_REDIRECT_TO_LOCAL 1"]
 
-    def pre_gc_code(self):
-        return []
+        eci = eci.merge(ExternalCompilationInfo(
+            pre_include_bits=pre_include_bits,
+            post_include_bits=['#define USING_BOEHM_GC'],
+            ))
+
+        return eci
 
     def gc_startup_code(self):
         if sys.platform == 'win32':
@@ -263,7 +266,6 @@
 
 class NoneGcPolicy(BoehmGcPolicy):
 
-    gc_libraries = RefcountingGcPolicy.gc_libraries.im_func
     gc_startup_code = RefcountingGcPolicy.gc_startup_code.im_func
 
 

Modified: pypy/trunk/pypy/translator/c/genc.py
==============================================================================
--- pypy/trunk/pypy/translator/c/genc.py	(original)
+++ pypy/trunk/pypy/translator/c/genc.py	Wed Mar 11 17:13:16 2009
@@ -168,8 +168,7 @@
 
     def collect_compilation_info(self, db):
         # we need a concrete gcpolicy to do this
-        self.eci = self.eci.merge(ExternalCompilationInfo(
-            libraries=db.gcpolicy.gc_libraries()))
+        self.eci = self.eci.merge(db.gcpolicy.compilation_info())
 
         all = []
         for node in self.db.globalcontainers():
@@ -317,6 +316,15 @@
             export_symbols.append('malloc_counters')
         extsymeci = ExternalCompilationInfo(export_symbols=export_symbols)
         self.eci = self.eci.merge(extsymeci)
+
+        if sys.platform == 'win32':
+            self.eci = self.eci.merge(ExternalCompilationInfo(
+                library_dirs = [py.path.local(sys.exec_prefix).join('LIBs'),
+                                py.path.local(sys.executable).dirpath(),
+                                ],
+                ))
+
+
         files = [self.c_source_filename] + self.extrafiles
         self.translator.platform.compile(files, self.eci, standalone=False)
         self._compiled = True
@@ -772,15 +780,9 @@
 
     print >> fi, '#define Py_BUILD_CORE  /* for Windows: avoid pulling libs in */'
     print >> fi, '#include "pyconfig.h"'
-    for line in database.gcpolicy.pre_pre_gc_code():
-        print >> fi, line
-
-    eci.write_c_header(fi)
-
     print >> fi, '#include "src/g_prerequisite.h"'
 
-    for line in database.gcpolicy.pre_gc_code():
-        print >> fi, line
+    eci.write_c_header(fi)
 
     fi.close()
 
@@ -830,15 +832,10 @@
         print >> fi, '#define %s %s' % (key, value)
 
     print >> fi, '#include "pyconfig.h"'
-    for line in database.gcpolicy.pre_pre_gc_code():
-        print >> fi, line
-
     print >> fi, '#include "src/g_prerequisite.h"'
 
-    for line in database.gcpolicy.pre_gc_code():
-        print >> fi, line
-
     eci.write_c_header(fi)
+
     fi.close()
 
     if database.translator is None or database.translator.rtyper is None:

Modified: pypy/trunk/pypy/translator/platform/windows.py
==============================================================================
--- pypy/trunk/pypy/translator/platform/windows.py	(original)
+++ pypy/trunk/pypy/translator/platform/windows.py	Wed Mar 11 17:13:16 2009
@@ -119,11 +119,6 @@
         return ['%s.lib' % (lib,) for lib in libraries]
 
     def _libdirs(self, library_dirs):
-        if self.add_cpython_dirs:
-            library_dirs = library_dirs + (
-                py.path.local(sys.exec_prefix).join('libs'),
-                py.path.local(sys.executable).dirpath(),
-                )
         return ['/LIBPATH:%s' % (ldir,) for ldir in library_dirs]
 
     def _linkfiles(self, link_files):



More information about the Pypy-commit mailing list