[pypy-commit] pypy nopax: nopax autodetection

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


Author: Mihnea Saracin <mihnea.saracin at rinftech.com>
Branch: nopax
Changeset: r91934:af2f69738d56
Date: 2017-06-06 10:25 +0300
http://bitbucket.org/pypy/pypy/changeset/af2f69738d56/

Log:	nopax autodetection

diff --git a/lib_pypy/_tkinter/tklib_build.py b/lib_pypy/_tkinter/tklib_build.py
--- a/lib_pypy/_tkinter/tklib_build.py
+++ b/lib_pypy/_tkinter/tklib_build.py
@@ -32,13 +32,13 @@
         if os.path.isdir(incdirs[0]):
             found = True
             break
-        if not found:
-            for _ver in ['8.6', '8.5', '']:
-                incdirs = ['/usr/include']
-                linklibs = ['tcl' + _ver, 'tk' + _ver]
-                libdirs=[]
-                if os.path.isfile(''.join(['/usr/lib/lib', linklibs[1], '.so'])):
-                    break
+    if not found:
+        for _ver in ['8.6', '8.5', '']:
+            incdirs = ['/usr/include']
+            linklibs = ['tcl' + _ver, 'tk' + _ver]
+            libdirs=[]
+            if os.path.isfile(''.join(['/usr/lib/lib', linklibs[1], '.so'])):
+                break
 
 config_ffi = FFI()
 config_ffi.cdef("""
diff --git a/rpython/config/support.py b/rpython/config/support.py
--- a/rpython/config/support.py
+++ b/rpython/config/support.py
@@ -35,3 +35,15 @@
         return int(count)
     except (OSError, ValueError):
         return 1
+
+def detect_pax():
+    """
+    Function to determine if your system comes with PAX protection.
+    """
+    if sys.platform.startswith('linux'):
+        # we need a running process PID and 1 is always running
+        with open("/proc/1/status") as fd:
+            data = fd.read()
+        if 'PaX' in data:
+            return True
+    return False
diff --git a/rpython/config/translationoption.py b/rpython/config/translationoption.py
--- a/rpython/config/translationoption.py
+++ b/rpython/config/translationoption.py
@@ -4,6 +4,7 @@
 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,7 +147,7 @@
               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=False,
+               default=detect_pax(),
                cmdline="--nopax"),
     BoolOption("instrument", "internal: turn instrumentation on",
                default=False, cmdline=None),


More information about the pypy-commit mailing list