Author: Armin Rigo <[email protected]>
Branch:
Changeset: r91939:8fcad79f230c
Date: 2017-07-20 07:53 +0000
http://bitbucket.org/pypy/pypy/changeset/8fcad79f230c/
Log: Merged in smihnea/pypy_nopax/nopax (pull request #551)
Adding nopax option for system that use PaX
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
@@ -22,12 +22,23 @@
linklibs = ['tcl', 'tk']
libdirs = []
else:
+ # On some Linux distributions, the tcl and tk libraries are
+ # stored in /usr/include, so we must check this case also
+ found = False
for _ver in ['', '8.6', '8.5', '']:
incdirs = ['/usr/include/tcl' + _ver]
linklibs = ['tcl' + _ver, 'tk' + _ver]
libdirs = []
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
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/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]')
@@ -458,7 +459,7 @@
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)')
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
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit