Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GNU: use -Wl,-rpath,<dir> instead of -Wl,-R<dir> #214

Merged
merged 4 commits into from
Feb 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading