[pypy-commit] pypy PyPy_profopt_enabled: PyPy 5.8.0 functional profopt. Precleanup

Dodan pypy.commits at gmail.com
Wed May 24 12:07:20 EDT 2017


Author: Dodan Mihai <mihai.dodan at gmail.com>
Branch: PyPy_profopt_enabled
Changeset: r91398:8fe61093e999
Date: 2017-05-03 13:23 +0300
http://bitbucket.org/pypy/pypy/changeset/8fe61093e999/

Log:	PyPy 5.8.0 functional profopt. Precleanup

diff --git a/pypy/goal/targetpypystandalone.py b/pypy/goal/targetpypystandalone.py
--- a/pypy/goal/targetpypystandalone.py
+++ b/pypy/goal/targetpypystandalone.py
@@ -264,11 +264,11 @@
                 raise Exception("Cannot use the --output option with PyPy "
                                 "when --shared is on (it is by default). "
                                 "See issue #1971.")
-            if (config.translation.profopt is not None
-                    and not config.translation.noprofopt):
-                raise Exception("Cannot use the --profopt option "
-                                "when --shared is on (it is by default). "
-                                "See issue #2398.")
+            # if (config.translation.profopt is not None
+            #         and not config.translation.noprofopt):
+            #     raise Exception("Cannot use the --profopt option "
+            #                     "when --shared is on (it is by default). "
+            #                     "See issue #2398.")
         if sys.platform == 'win32':
             libdir = thisdir.join('..', '..', 'libs')
             libdir.ensure(dir=1)
diff --git a/rpython/config/translationoption.py b/rpython/config/translationoption.py
--- a/rpython/config/translationoption.py
+++ b/rpython/config/translationoption.py
@@ -142,7 +142,7 @@
     BoolOption("verbose", "Print extra information", default=False,
                cmdline="--verbose"),
     StrOption("cc", "Specify compiler to use for compiling generated C", cmdline="--cc"),
-    StrOption("profopt", "Specify profile based optimization script",
+    BoolOption("profopt", "Specify profile based optimization script",
               cmdline="--profopt"),
     BoolOption("noprofopt", "Don't use profile based optimization",
                default=False, cmdline="--no-profopt", negation=False),
diff --git a/rpython/translator/c/genc.py b/rpython/translator/c/genc.py
--- a/rpython/translator/c/genc.py
+++ b/rpython/translator/c/genc.py
@@ -87,11 +87,11 @@
     def _do_profbased(self):
         ProfDriver, args = self.profbased
         profdrv = ProfDriver(self)
-        dolog = getattr(log, profdrv.name)
+        # dolog = getattr(log, profdrv.name)
         dolog(args)
         exename = profdrv.first()
-        dolog('Gathering profile data from: %s %s' % (
-            str(exename), args))
+        # dolog('Gathering profile data from: %s %s' % (
+        #     str(exename), args))
         profdrv.probe(exename, args)
         return profdrv.after()
 
@@ -391,6 +391,8 @@
         shared = self.config.translation.shared
 
         extra_opts = []
+        if self.config.translation.profopt and not self.config.translation.noprofopt:
+            extra_opts += ["profopt"]
         if self.config.translation.make_jobs != 1:
             extra_opts += ['-j', str(self.config.translation.make_jobs)]
         if self.config.translation.lldebug:
@@ -420,11 +422,14 @@
             shared=self.config.translation.shared,
             config=self.config)
 
-        if self.has_profopt():
-            profopt = self.config.translation.profopt
-            mk.definition('ABS_TARGET', str(targetdir.join('$(TARGET)')))
-            mk.definition('DEFAULT_TARGET', 'profopt')
-            mk.definition('PROFOPT', profopt)
+
+        #if self.has_profopt():
+        #     profopt = self.config.translation.profopt
+        #     mk.definition('ABS_TARGET', str(targetdir.join('$(TARGET)')))
+        #     mk.definition('DEFAULT_TARGET', 'profopt')
+        #     mk.definition('PROFOPT', profopt)
+        # I have commented this out because I have made another rule with other definitions explained below
+
 
         rules = [
             ('debug', '', '$(MAKE) CFLAGS="$(DEBUGFLAGS) -DRPY_ASSERT" debug_target'),
@@ -433,15 +438,30 @@
             ('llsafer', '', '$(MAKE) CFLAGS="-O2 -DRPY_LL_ASSERT" $(DEFAULT_TARGET)'),
             ('lldebug', '', '$(MAKE) CFLAGS="$(DEBUGFLAGS) -DRPY_ASSERT -DRPY_LL_ASSERT" debug_target'),
             ('profile', '', '$(MAKE) CFLAGS="-g -O1 -pg $(CFLAGS) -fno-omit-frame-pointer" LDFLAGS="-pg $(LDFLAGS)" $(DEFAULT_TARGET)'),
-            ]
-        if self.has_profopt():
-            rules.append(
-                ('profopt', '', [
-                '$(MAKENOPROF)',
-                '$(MAKE) CFLAGS="-fprofile-generate $(CFLAGS)" LDFLAGS="-fprofile-generate $(LDFLAGS)" $(TARGET)',
-                'cd $(RPYDIR)/translator/goal && $(ABS_TARGET) $(PROFOPT)',
+        ]
+        # if self.has_profopt():
+
+        #added a new target for profopt, because it requires -lgcov to compile successfully when -shared is used as an argument
+        # PROFOPT_Tar
+
+        mk.definition('PROFOPT_TARGET','pypy-c')
+        mk.rule('$(PROFOPT_TARGET)', '$(TARGET) main.o',
+                     '$(CC_LINK) $(LDFLAGS_LINK) main.o -L. -l$(SHARED_IMPORT_LIB) -o $@ $(RPATH_FLAGS) -lgcov')
+        rules.append(
+            ('profopt', '', [
+                '$(MAKE) CFLAGS="-fprofile-generate -fPIC $(CFLAGS) -fno-lto"  LDFLAGS="-fprofile-generate $(LDFLAGS) -fno-lto" $(PROFOPT_TARGET)',
+                'rm -f $(RPYDIR)/../pypy/goal/libpypy-c.so || true',
+                'cp -f libpypy-c.so $(RPYDIR)/../pypy/goal/ || true',
+                'rm -f $(RPYDIR)/../pypy/goal/pypy-c',
+                'cp -f pypy-c $(RPYDIR)/../pypy/goal/',
+                '$(RPYDIR)/../pypy/goal/pypy-c $(RPYDIR)/../pypy/goal/regrtest/regrtest.py --pgo -x test_asyncore test_gdb test_multiprocessing test_subprocess || true',
                 '$(MAKE) clean_noprof',
-                '$(MAKE) CFLAGS="-fprofile-use $(CFLAGS)" LDFLAGS="-fprofile-use $(LDFLAGS)" $(TARGET)']))
+                '$(MAKE) CFLAGS="-fprofile-use -fprofile-correction -fPIC $(CFLAGS) -fno-lto"  LDFLAGS="-fprofile-use $(LDFLAGS) -fno-lto" $(PROFOPT_TARGET)',
+                'rm -f $(RPYDIR)/../pypy/goal/libpypy-c.so || true',
+                'cp -f libpypy-c.so $(RPYDIR)/../pypy/goal/ || true',
+                'rm -f $(RPYDIR)/../pypy/goal/pypy-c',
+                'cp -f pypy-c $(RPYDIR)/../pypy/goal/']))
+
         for rule in rules:
             mk.rule(*rule)
 


More information about the pypy-commit mailing list