[pypy-svn] r56394 - in pypy/dist/pypy/translator: llvm tool

haypo at codespeak.net haypo at codespeak.net
Wed Jul 9 15:44:12 CEST 2008


Author: haypo
Date: Wed Jul  9 15:44:11 2008
New Revision: 56394

Modified:
   pypy/dist/pypy/translator/llvm/buildllvm.py
   pypy/dist/pypy/translator/tool/cbuild.py
Log:
Support CFLAGS environement variable to cbuild and buildllvm


Modified: pypy/dist/pypy/translator/llvm/buildllvm.py
==============================================================================
--- pypy/dist/pypy/translator/llvm/buildllvm.py	(original)
+++ pypy/dist/pypy/translator/llvm/buildllvm.py	Wed Jul  9 15:44:11 2008
@@ -15,6 +15,8 @@
         return False
     return True
 
+CFLAGS = os.getenv("CFLAGS") or "-O3"
+
 def exe_version(exe, cache={}):
     try:
         v =  cache[exe]
@@ -84,7 +86,7 @@
         use_gcc = self.genllvm.config.translation.llvm_via_c
         if use_gcc:
             self.cmds.append("llc %s.bc -march=c -f -o %s.c" % (base, base))
-            self.cmds.append("gcc %s.c -c -O3 -fomit-frame-pointer" % base)
+            self.cmds.append("gcc %s.c -c %s -fomit-frame-pointer" % (base, CFLAGS))
         else:
             model = ''
             if not standalone:
@@ -103,7 +105,7 @@
             assert filename.endswith(".c")
             objname = filename[:-2] + ".o"
             libraries.add(objname)
-            self.cmds.append("gcc %s -c %s -O3 -o %s" % (filename, include_opts, objname))
+            self.cmds.append("gcc %s -c %s %s -o %s" % (filename, include_opts, CFLAGS, objname))
 
         attrs = self.genllvm.eci._copy_attributes()
         attrs['libraries'] = tuple(libraries) + attrs['libraries']
@@ -112,13 +114,13 @@
 # XXX support profile?
 #             if (self.genllvm.config.translation.profopt is not None and
 #                 not self.genllvm.config.translation.noprofopt):
-#                 cmd = "gcc -fprofile-generate %s.c -c -O3 -pipe -o %s.o" % (base, base)
+#                 cmd = "gcc -fprofile-generate %s.c -c %s -pipe -o %s.o" % (base, CFLAGS, base)
 #                 self.cmds.append(cmd)
 #                 cmd = "gcc -fprofile-generate %s.o %s %s -lm -pipe -o %s_gen" % \
 #                       (base, gc_libs_path, gc_libs, exename)
 #                 self.cmds.append(cmd)
 #                 self.cmds.append("./%s_gen %s" % (exename, self.genllvm.config.translation.profopt))
-#                 cmd = "gcc -fprofile-use %s.c -c -O3 -pipe -o %s.o" % (b, b)
+#                 cmd = "gcc -fprofile-use %s.c -c %s -pipe -o %s.o" % (b, CFLAGS, b)
 #                 self.cmds.append(cmd)
 #                 cmd = "gcc -fprofile-use %s.o %s %s -lm -pipe -o %s" % \
 #                       (b, gc_libs_path, gc_libs, exename)
@@ -167,7 +169,7 @@
         out = base + ".so"
         if exename:
             out = exename
-        self.cmds.append("gcc -O3 %s.o %s -o %s" % (base, " ".join(compiler_opts), out))
+        self.cmds.append("gcc %s %s.o %s -o %s" % (CFLAGS, base, " ".join(compiler_opts), out))
 
     def make_module(self):
         base = self.setup()

Modified: pypy/dist/pypy/translator/tool/cbuild.py
==============================================================================
--- pypy/dist/pypy/translator/tool/cbuild.py	(original)
+++ pypy/dist/pypy/translator/tool/cbuild.py	Wed Jul  9 15:44:11 2008
@@ -12,6 +12,12 @@
 
 debug = 0
 
+CFLAGS = os.getenv("CFLAGS")
+if CFLAGS:
+    CFLAGS = CFLAGS.split()
+else:
+    CFLAGS = ['-O3']
+
 class ExternalCompilationInfo(object):
 
     _ATTRIBUTES = ['pre_include_bits', 'includes', 'include_dirs',
@@ -499,7 +505,7 @@
                 self.libraries.append('m')
             if 'pthread' not in self.libraries:
                 self.libraries.append('pthread')
-            self.compile_extra += ['-O3', '-fomit-frame-pointer', '-pthread']
+            self.compile_extra += CFLAGS + ['-fomit-frame-pointer', '-pthread']
             self.link_extra += ['-pthread']
         if sys.platform == 'win32':
             self.link_extra += ['/DEBUG'] # generate .pdb file
@@ -512,7 +518,7 @@
                 if s + 'lib' not in self.library_dirs and \
                    os.path.exists(s + 'lib'):
                     self.library_dirs.append(s + 'lib')
-            self.compile_extra += ['-O3', '-fomit-frame-pointer']
+            self.compile_extra += CFLAGS + ['-fomit-frame-pointer']
             for framework in self.frameworks:
                 self.link_extra += ['-framework', framework]
 



More information about the Pypy-commit mailing list