[pypy-commit] pypy nopax: Merged in palecsandru/pypy_nopax_1/nopax_update1 (pull request #1)

smihnea pypy.commits at gmail.com
Thu Jul 20 03:53:49 EDT 2017


Author: Mihnea Saracin <mihnea.saracin at rinftech.com>
Branch: nopax
Changeset: r91937:b7a22c99849e
Date: 2017-06-20 11:42 +0000
http://bitbucket.org/pypy/pypy/changeset/b7a22c99849e/

Log:	Merged in palecsandru/pypy_nopax_1/nopax_update1 (pull request #1)

	updates after review

	Approved-by: Mihnea Saracin <mihnea.saracin at rinftech.com>

diff --git a/rpython/config/translationoption.py b/rpython/config/translationoption.py
--- a/rpython/config/translationoption.py
+++ b/rpython/config/translationoption.py
@@ -4,7 +4,6 @@
 from rpython.config.config import ChoiceOption, StrOption, Config, ConflictConfigError
 from rpython.config.config import ConfigError
 from rpython.config.support import detect_number_of_processors
-from rpython.config.support import detect_pax
 from rpython.translator.platform import platform as compiler
 
 
@@ -146,9 +145,6 @@
     BoolOption("profopt", "Enable profile guided optimization. Defaults to enabling this for PyPy. For other training workloads, please specify them in profoptargs",
               cmdline="--profopt", default=False),
     StrOption("profoptargs", "Absolute path to the profile guided optimization training script + the necessary arguments of the script", cmdline="--profoptargs", default=None),
-    BoolOption("nopax", "Use this in case your system comes with a PAX protection. --nopax will disable it for pypy, so that it can use the jit. Requires paxmark to be installed",
-               default=detect_pax(),
-               cmdline="--nopax"),
     BoolOption("instrument", "internal: turn instrumentation on",
                default=False, cmdline=None),
     BoolOption("countmallocs", "Count mallocs and frees", default=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
@@ -14,6 +14,7 @@
 from rpython.translator.gensupp import uniquemodulename, NameManager
 from rpython.translator.tool.cbuild import ExternalCompilationInfo
 
+
 _CYGWIN = sys.platform == 'cygwin'
 
 _CPYTHON_RE = py.std.re.compile('^Python 2.[567]')
@@ -333,8 +334,6 @@
         extra_opts = []
         if self.config.translation.profopt:
             extra_opts += ["profopt"]
-        if self.config.translation.nopax:
-            extra_opts += ["nopax"]
         if self.config.translation.make_jobs != 1:
             extra_opts += ['-j', str(self.config.translation.make_jobs)]
         if self.config.translation.lldebug:
@@ -386,7 +385,7 @@
                 raise Exception("No profoptargs specified, neither in the command line, nor in the target. If the target is not PyPy, please specify profoptargs")
             if self.config.translation.shared:
                 mk.rule('$(PROFOPT_TARGET)', '$(TARGET) main.o',
-                         '$(CC_LINK) $(LDFLAGS_LINK) main.o -L. -l$(SHARED_IMPORT_LIB) -o $@ $(RPATH_FLAGS) -lgcov')
+                         ['$(CC_LINK) $(LDFLAGS_LINK) main.o -L. -l$(SHARED_IMPORT_LIB) -o $@ $(RPATH_FLAGS) -lgcov', '$(MAKE) postcompile BIN=$(PROFOPT_TARGET)'])
             else:
                 mk.definition('PROFOPT_TARGET', '$(TARGET)')
 
@@ -398,15 +397,6 @@
                     '$(MAKE) CFLAGS="-fprofile-use -fprofile-correction -fPIC $(CFLAGS) -fno-lto"  LDFLAGS="-fprofile-use $(LDFLAGS) -fno-lto" $(PROFOPT_TARGET)',
                 ]))
 
-        # No-pax code
-        if self.config.translation.nopax:
-            mk.definition('PAX_TARGET', '%s' % (exe_name))
-            rules.append(('$(PAX_TARGET)', '$(TARGET) main.o', [
-                          '$(CC_LINK) $(LDFLAGS_LINK) main.o -L. -l$(SHARED_IMPORT_LIB) -o $@ $(RPATH_FLAGS)',
-                          'attr -q -s pax.flags -V m $(PAX_TARGET)']))
-            mk.rule('nopax', '',
-                    '$(MAKE) CFLAGS="$(CFLAGS) $(CFLAGSEXTRA)" LDFLAGS="$(LDFLAGS)" $(PAX_TARGET)')
-
         for rule in rules:
             mk.rule(*rule)
 
diff --git a/rpython/translator/platform/posix.py b/rpython/translator/platform/posix.py
--- a/rpython/translator/platform/posix.py
+++ b/rpython/translator/platform/posix.py
@@ -3,6 +3,7 @@
 import py, os, sys
 
 from rpython.translator.platform import Platform, log, _run_subprocess
+from rpython.config.support import detect_pax
 
 import rpython
 rpydir = str(py.path.local(rpython.__file__).join('..'))
@@ -196,9 +197,17 @@
         for args in definitions:
             m.definition(*args)
 
+        # Post compile rule to be executed after a TARGET is ran
+        #
+        # Some processing might be necessary on the resulting binary,
+        # which is received in $(BIN) parameter
+        postcompile_rule = ('postcompile', '', ['true'])
+        if detect_pax():
+            postcompile_rule[2].append('attr -q -s pax.flags -V m $(BIN)')
+
         rules = [
             ('all', '$(DEFAULT_TARGET)', []),
-            ('$(TARGET)', '$(OBJECTS)', '$(CC_LINK) $(LDFLAGSEXTRA) -o $@ $(OBJECTS) $(LIBDIRS) $(LIBS) $(LINKFILES) $(LDFLAGS)'),
+            ('$(TARGET)', '$(OBJECTS)', ['$(CC_LINK) $(LDFLAGSEXTRA) -o $@ $(OBJECTS) $(LIBDIRS) $(LIBS) $(LINKFILES) $(LDFLAGS)', '$(MAKE) postcompile BIN=$(TARGET)']),
             ('%.o', '%.c', '$(CC) $(CFLAGS) $(CFLAGSEXTRA) -o $@ -c $< $(INCLUDEDIRS)'),
             ('%.o', '%.s', '$(CC) $(CFLAGS) $(CFLAGSEXTRA) -o $@ -c $< $(INCLUDEDIRS)'),
             ('%.o', '%.cxx', '$(CXX) $(CFLAGS) $(CFLAGSEXTRA) -o $@ -c $< $(INCLUDEDIRS)'),
@@ -207,6 +216,8 @@
         for rule in rules:
             m.rule(*rule)
 
+        m.rule(*postcompile_rule)
+
         if shared:
             m.definition('SHARED_IMPORT_LIB', libname),
             m.definition('PYPY_MAIN_FUNCTION', "pypy_main_startup")
@@ -216,7 +227,7 @@
                    'int main(int argc, char* argv[]) '
                    '{ return $(PYPY_MAIN_FUNCTION)(argc, argv); }" > $@')
             m.rule('$(DEFAULT_TARGET)', ['$(TARGET)', 'main.o'],
-                   '$(CC_LINK) $(LDFLAGS_LINK) main.o -L. -l$(SHARED_IMPORT_LIB) -o $@ $(RPATH_FLAGS)')
+                   ['$(CC_LINK) $(LDFLAGS_LINK) main.o -L. -l$(SHARED_IMPORT_LIB) -o $@ $(RPATH_FLAGS)', '$(MAKE) postcompile BIN=$(DEFAULT_TARGET)'])
 
         return m
 


More information about the pypy-commit mailing list