-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
rust: Add a -C default-linker-libraries
option
#54675
Conversation
This commit adds a new codegen option for the compiler which disables rustc's passing of `-nodefaultlibs` by default on relevant platforms. Sometimes Rust is linked with C code which fails to link with `-nodefaultlibs` and is unnecessarily onerous to get linking correctly with `-nodefaultlibs`. An example of this is that when you compile C code with sanitizers and then pass `-fsanitize=address` to the linker, it's incompatible with `-nodefaultlibs` also being passed to the linker. In these situations it's easiest to turn off Rust's default passing of `-nodefaultlibs`, which was more ideological to start with than anything! Preserving the default is somewhat important but having this be opt-in shouldn't cause any breakage. Closes rust-lang#54237
r? @varkor (rust_highfive has picked a reviewer for you, use r? to override) |
@bors r+ |
📌 Commit 6f4b378 has been approved by |
rust: Add a `-C default-linker-libraries` option This commit adds a new codegen option for the compiler which disables rustc's passing of `-nodefaultlibs` by default on relevant platforms. Sometimes Rust is linked with C code which fails to link with `-nodefaultlibs` and is unnecessarily onerous to get linking correctly with `-nodefaultlibs`. An example of this is that when you compile C code with sanitizers and then pass `-fsanitize=address` to the linker, it's incompatible with `-nodefaultlibs` also being passed to the linker. In these situations it's easiest to turn off Rust's default passing of `-nodefaultlibs`, which was more ideological to start with than anything! Preserving the default is somewhat important but having this be opt-in shouldn't cause any breakage. Closes #54237
☀️ Test successful - status-appveyor, status-travis |
I found this PR while investiguating a bug reported in Meson: mesonbuild/meson#12877. I think using |
some background is contained here: #11937 |
This commit adds a new codegen option for the compiler which disables
rustc's passing of
-nodefaultlibs
by default on relevant platforms.Sometimes Rust is linked with C code which fails to link with
-nodefaultlibs
and is unnecessarily onerous to get linking correctlywith
-nodefaultlibs
.An example of this is that when you compile C code with sanitizers and
then pass
-fsanitize=address
to the linker, it's incompatible with-nodefaultlibs
also being passed to the linker.In these situations it's easiest to turn off Rust's default passing of
-nodefaultlibs
, which was more ideological to start with thananything! Preserving the default is somewhat important but having this
be opt-in shouldn't cause any breakage.
Closes #54237