Skip to content

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

Merged
jaraco merged 4 commits into
pypa:mainfrom
haampie:feature/use-wl-rpath-instead-of-wl-r
Feb 13, 2024
Merged

jaraco merged 4 commits into
pypa:mainfrom
haampie:feature/use-wl-rpath-instead-of-wl-r

Conversation

@haampie

@haampie haampie commented Sep 26, 2023

Copy link
Copy Markdown
Contributor

The latter is supported in binutils for backwards compatibility, but in
general -R<path> is equivalent to --just-symbols=<path> when path
is a file; only when it's a directory, it's treated as -rpath=<path>.

Better avoid that ambiguity and use -rpath.

Also split -Wl,--enable-new-dtags and -Wl,-rpath,... into two
separate arguments, which is more common, and more likely to be parsed
correctly by compiler wrappers.

This commit does not attempt to add --enable-new-dtags to other
linkers than binutils ld/gold that support the flag.

The latter is supported in binutils for backwards compatibility, but in
general `-R<path>` is equivalent to `--just-symbols=<path>` when `path`
is a file; only when it's a directory, it's treated as `-rpath=<path>`.

Better avoid that ambiguity and use `-rpath`.

Also split `-Wl,--enable-new-dtags` and `-Wl,-rpath,...` into two
separate arguments, which is more common, and more likely to be parsed
correctly by compiler wrappers.

This commit does not attempt to add `--enable-new-dtags` to other
linkers than binutils ld/gold that support the flag.
@jaraco
jaraco force-pushed the main branch 3 times, most recently from 12769e5 to d23e28a Compare November 5, 2023 15:55
@jaraco jaraco closed this Feb 12, 2024
@jaraco jaraco reopened this Feb 12, 2024
@jaraco jaraco closed this Feb 13, 2024
@jaraco jaraco reopened this Feb 13, 2024
@jaraco

jaraco commented Feb 13, 2024 •

Copy link
Copy Markdown
Member

After fixing the linter failures, there's still a test failure at distutils/tests/test_unixccompiler.py:156:

>       assert self.cc.rpath_foo() == '-Wl,--enable-new-dtags,-R/foo'
E       AssertionError: assert ['-Wl,--enable-new-dtags', '-Wl,-rpath,/foo'] == '-Wl,--enable-new-dtags,-R/foo'
E        +  where ['-Wl,--enable-new-dtags', '-Wl,-rpath,/foo'] = <bound method compiler_wrapper.<locals>.CompilerWrapper.rpath_foo of <distutils.tests.test_unixccompiler.compiler_wrapper.<locals>.CompilerWrapper object at 0x11a03b920>>()
E        +    where <bound method compiler_wrapper.<locals>.CompilerWrapper.rpath_foo of <distutils.tests.test_unixccompiler.compiler_wrapper.<locals>.CompilerWrapper object at 0x11a03b920>> = <distutils.tests.test_unixccompiler.compiler_wrapper.<locals>.CompilerWrapper object at 0x11a03b920>.rpath_foo
E        +      where <distutils.tests.test_unixccompiler.compiler_wrapper.<locals>.CompilerWrapper object at 0x11a03b920> = <distutils.tests.test_unixccompiler.TestUnixCCompiler object at 0x118158c80>.cc

@jaraco jaraco closed this Feb 13, 2024
@jaraco jaraco reopened this Feb 13, 2024
@jaraco
jaraco merged commit 4504c68 into pypa:main Feb 13, 2024
jaraco added a commit that referenced this pull request Jul 31, 2026
consolidate_linker_args existed only to temporarily restore the old
single-string rpath return after #214 split it into a list,
giving downstream projects (mpi4py et al.) a window to adopt list
support. The "retain until 2025-04-31" window has long passed, so drop
the shim entirely and have UnixCCompiler.runtime_library_dir_option
return the ["-Wl,--enable-new-dtags", "-Wl,-rpath,<dir>"] list directly
for GNU ld.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants