Skip to content

Commit

Permalink
Merge pull request #214 from haampie/feature/use-wl-rpath-instead-of-…
Browse files Browse the repository at this point in the history
…wl-r

GNU: use -Wl,-rpath,<dir> instead of -Wl,-R<dir>
  • Loading branch information
jaraco authored Feb 13, 2024
2 parents 0f23a0e + 91cb327 commit 4504c68
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 10 deletions.
20 changes: 16 additions & 4 deletions distutils/tests/test_unixccompiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,10 @@ def gcv(v):
return 'yes'

sysconfig.get_config_var = gcv
assert self.cc.rpath_foo() == '-Wl,--enable-new-dtags,-R/foo'
assert self.cc.rpath_foo() == [
'-Wl,--enable-new-dtags',
'-Wl,-rpath,/foo',
]

def gcv(v):
if v == 'CC':
Expand All @@ -162,7 +165,10 @@ def gcv(v):
return 'yes'

sysconfig.get_config_var = gcv
assert self.cc.rpath_foo() == '-Wl,--enable-new-dtags,-R/foo'
assert self.cc.rpath_foo() == [
'-Wl,--enable-new-dtags',
'-Wl,-rpath,/foo',
]

# GCC non-GNULD
sys.platform = 'bar'
Expand All @@ -187,7 +193,10 @@ def gcv(v):
return 'yes'

sysconfig.get_config_var = gcv
assert self.cc.rpath_foo() == '-Wl,--enable-new-dtags,-R/foo'
assert self.cc.rpath_foo() == [
'-Wl,--enable-new-dtags',
'-Wl,-rpath,/foo',
]

# non-GCC GNULD
sys.platform = 'bar'
Expand All @@ -199,7 +208,10 @@ def gcv(v):
return 'yes'

sysconfig.get_config_var = gcv
assert self.cc.rpath_foo() == '-Wl,--enable-new-dtags,-R/foo'
assert self.cc.rpath_foo() == [
'-Wl,--enable-new-dtags',
'-Wl,-rpath,/foo',
]

# non-GCC non-GNULD
sys.platform = 'bar'
Expand Down
13 changes: 7 additions & 6 deletions distutils/unixccompiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -310,13 +310,14 @@ def runtime_library_dir_option(self, dir):
"-L" + dir,
]

# For all compilers, `-Wl` is the presumed way to
# pass a compiler option to the linker and `-R` is
# the way to pass an RPATH.
# For all compilers, `-Wl` is the presumed way to pass a
# compiler option to the linker
if sysconfig.get_config_var("GNULD") == "yes":
# GNU ld needs an extra option to get a RUNPATH
# instead of just an RPATH.
return "-Wl,--enable-new-dtags,-R" + dir
return [
# Force RUNPATH instead of RPATH
"-Wl,--enable-new-dtags",
"-Wl,-rpath," + dir,
]
else:
return "-Wl,-R" + dir

Expand Down

0 comments on commit 4504c68

Please sign in to comment.