-
Notifications
You must be signed in to change notification settings - Fork 13.1k
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
Option to disable -nodefaultlibs to the linker #54237
Labels
A-linkage
Area: linking into static, shared libraries and binaries
Comments
I literally just ran into this as well, though I assumed it was due to me using no_std. |
alexcrichton
added a commit
to alexcrichton/rust
that referenced
this issue
Sep 29, 2018
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
bors
added a commit
that referenced
this issue
Oct 1, 2018
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
This was referenced Sep 8, 2021
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Currently the compiler unconditionally passes
-nodefaultlibs
(or the platform equivalent) to the linker. Unfortunately though this actually causes linking to fail in some circumstances. Some investigation has shown that when compiled with-fsanitize=address
this has been seen to cause problems and cause link errors.While there may be more bugs to fix here on various sides, we should have an option to disable passing this flag!
The text was updated successfully, but these errors were encountered: