[pypy-commit] pypy osx-shared: Introduce a RPATH_FLAGS variable to factor out the platform dependent rpath flags

larstiq noreply at buildbot.pypy.org
Wed Dec 31 07:59:48 CET 2014


Author: Wouter van Heyst <wouter.pypy at richtlijn.be>
Branch: osx-shared
Changeset: r75178:b4dea196a719
Date: 2014-12-22 20:35 +0200
http://bitbucket.org/pypy/pypy/changeset/b4dea196a719/

Log:	Introduce a RPATH_FLAGS variable to factor out the platform
	dependent rpath flags

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
@@ -140,6 +140,11 @@
         rel_libdirs = [rpyrel(libdir) for libdir in
                        self.preprocess_library_dirs(eci.library_dirs)]
 
+        if os.platform == 'darwin':
+            rpath_flags = ['-Wl,-rpath', '-Wl, at executable_path']
+        else:
+            rpath_flags = ['-Wl,-rpath=\'$$ORIGIN/\'']
+
         m.comment('automatically generated makefile')
         definitions = [
             ('RPYDIR', '"%s"' % rpydir),
@@ -158,6 +163,7 @@
             ('CC', self.cc),
             ('CC_LINK', eci.use_cpp_linker and 'g++' or '$(CC)'),
             ('LINKFILES', eci.link_files),
+            ('RPATH_FLAGS', rpath_flags),
             ]
         for args in definitions:
             m.definition(*args)
@@ -180,13 +186,8 @@
                    'int $(PYPY_MAIN_FUNCTION)(int, char*[]); '
                    'int main(int argc, char* argv[]) '
                    '{ return $(PYPY_MAIN_FUNCTION)(argc, argv); }" > $@')
-            if sys.platform == 'darwin':
-                m.rule('$(DEFAULT_TARGET)', ['$(TARGET)', 'main.o'],
-                       ['$(CC_LINK) $(LDFLAGS_LINK) main.o -L. -l$(SHARED_IMPORT_LIB) -o $@',
-                        'install_name_tool -add_rpath @executable_path $@'])
-            else:
-                m.rule('$(DEFAULT_TARGET)', ['$(TARGET)', 'main.o'],
-                   '$(CC_LINK) $(LDFLAGS_LINK) main.o -L. -l$(SHARED_IMPORT_LIB) -o $@ -Wl,-rpath=\'$$ORIGIN/\'')
+            m.rule('$(DEFAULT_TARGET)', ['$(TARGET)', 'main.o'],
+                   '$(CC_LINK) $(LDFLAGS_LINK) main.o -L. -l$(SHARED_IMPORT_LIB) -o $@ $(RPATH_FLAGS)')
 
         return m
 


More information about the pypy-commit mailing list