[pypy-svn] r55396 - in pypy/dist/pypy: rpython/module translator/c translator/tool
arigo at codespeak.net
arigo at codespeak.net
Thu May 29 16:16:38 CEST 2008
Author: arigo
Date: Thu May 29 16:16:37 2008
New Revision: 55396
Modified:
pypy/dist/pypy/rpython/module/ll_os.py
pypy/dist/pypy/translator/c/genc.py
pypy/dist/pypy/translator/tool/cbuild.py
Log:
XXX horrible workaround for a bug of profiling in gcc on
OS X with functions containing a direct call to fork()
Modified: pypy/dist/pypy/rpython/module/ll_os.py
==============================================================================
--- pypy/dist/pypy/rpython/module/ll_os.py (original)
+++ pypy/dist/pypy/rpython/module/ll_os.py Thu May 29 16:16:37 2008
@@ -1121,7 +1121,18 @@
@registering_if(os, 'fork')
def register_os_fork(self):
- os_fork = self.llexternal('fork', [], rffi.PID_T)
+ # XXX horrible workaround for a bug of profiling in gcc on
+ # OS X with functions containing a direct call to fork()
+ eci = ExternalCompilationInfo(
+ post_include_bits = ['pid_t _noprof_fork(void);'],
+ separate_module_sources = ['''
+ /*--no-profiling-for-this-file!--*/
+ pid_t _noprof_fork(void) {
+ return fork();
+ }
+ '''])
+ os_fork = self.llexternal('_noprof_fork', [], rffi.PID_T,
+ compilation_info = eci)
def fork_llimpl():
childpid = rffi.cast(lltype.Signed, os_fork())
Modified: pypy/dist/pypy/translator/c/genc.py
==============================================================================
--- pypy/dist/pypy/translator/c/genc.py (original)
+++ pypy/dist/pypy/translator/c/genc.py Thu May 29 16:16:37 2008
@@ -399,9 +399,20 @@
cc = self.config.translation.cc
else:
cc = 'gcc'
+ make_no_prof = ''
if self.has_profopt():
profopt = self.config.translation.profopt
default_target = 'profopt'
+ # XXX horrible workaround for a bug of profiling in gcc on
+ # OS X with functions containing a direct call to fork()
+ non_profilable = []
+ assert len(compiler.cfilenames) == len(ofiles)
+ for fn, oname in zip(compiler.cfilenames, ofiles):
+ fn = py.path.local(fn)
+ if '/*--no-profiling-for-this-file!--*/' in fn.read():
+ non_profilable.append(oname)
+ if non_profilable:
+ make_no_prof = '$(MAKE) %s' % (' '.join(non_profilable),)
else:
profopt = ''
default_target = '$(TARGET)'
@@ -445,6 +456,7 @@
else:
print >> f, 'TFLAGS = ' + ''
print >> f, 'PROFOPT = ' + profopt
+ print >> f, 'MAKENOPROF = ' + make_no_prof
print >> f, 'CC = ' + cc
print >> f
print >> f, MAKEFILE.strip()
@@ -913,6 +925,7 @@
ABS_TARGET = $(shell python -c "import sys,os; print os.path.abspath(sys.argv[1])" $(TARGET))
profopt:
+\t$(MAKENOPROF) # these files must be compiled without profiling
\t$(MAKE) CFLAGS="-fprofile-generate $(CFLAGS)" LDFLAGS="-fprofile-generate $(LDFLAGS)" $(TARGET)
\tcd $(PYPYDIR)/translator/goal && $(ABS_TARGET) $(PROFOPT)
\t$(MAKE) clean_noprof
Modified: pypy/dist/pypy/translator/tool/cbuild.py
==============================================================================
--- pypy/dist/pypy/translator/tool/cbuild.py (original)
+++ pypy/dist/pypy/translator/tool/cbuild.py Thu May 29 16:16:37 2008
@@ -578,10 +578,15 @@
for cfile in self.cfilenames:
cfile = py.path.local(cfile)
compile_extra = self.compile_extra[:]
- # -frandom-seed is an attempted workaround for a bug with
- # -fprofile-generate and -fprofile-use
+ # -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],
More information about the Pypy-commit
mailing list