Skip to content

Rpath is not supported on AIX #109525

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

Merged
merged 1 commit into from
Jun 4, 2023
Merged
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
2 changes: 1 addition & 1 deletion src/bootstrap/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1554,7 +1554,7 @@ impl<'a> Builder<'a> {
// flesh out rpath support more fully in the future.
rustflags.arg("-Zosx-rpath-install-name");
Some("-Wl,-rpath,@loader_path/../lib")
} else if !target.contains("windows") {
} else if !target.contains("windows") && !target.contains("aix") {
Copy link
Member

@bjorn3 bjorn3 Mar 25, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You will have to put librustc_driver.so and libstd.so in bin/ instead of lib/ for AIX too then, right? Or does AIX not look for dynamic libraries in the same directory as the executable?

Copy link
Contributor Author

@bzEq bzEq Mar 28, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does AIX not look for dynamic libraries in the same directory as the executable?

It doesn't.

It's very unfortunate that AIX doesn't support rpath and $ORIGIN directive.
We are currently using launch scripts to wrap executables. To be more specific, in tree

.
├── bin
│   ├── .cargo
│   ├── cargo
│   ├── .rustc
│   └── rustc
└── lib
    ├── librustc_driver.a
    └── libstd.a

bin/cargo and bin/rustc are wrappers, where we implement something like

EXEC_DIR=`/usr/bin/dirname $0`
EXEC=`/usr/bin/basename $0`
BASE=`/usr/lib/instl/realpath "${EXEC_DIR}/../"`
export LIBPATH="${BASE}/lib":"${LIBPATH:-/usr/lib:/lib}"
exec "${EXEC_DIR}/.${EXEC}" "$@"

I guess using rustup to generate rustc and cargo can also mitigate this issue.

rustflags.arg("-Clink-args=-Wl,-z,origin");
Some("-Wl,-rpath,$ORIGIN/../lib")
} else {
Expand Down