-
Notifications
You must be signed in to change notification settings - Fork 211
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
Question: whose responsibility is it to provide builtins used by C code? #217
Comments
I'd personally expect these to come from libgcc, not compiler-builtins. This crate is in general targeted only at Rust's needs, not C's. |
In the case of #201, the musl libc is shipped as part of the compiler. In that case it should be the responsibility of the compiler to provide the necessary symbols for linking the provided libc. I agree with alex though, this should be done by linking in libgcc or libcompiler-rt. |
Ok, so rustc should add libgcc to the linker commandline for all targets that use gcc or ld linker flavor? What happens when someone wants to use compiler-rt instead, do we add a flag to rustc allowing the user to specify the c-builtins library, if and when that is needed? |
I don't personally think that rustc should do this, but rather a user should explicitly request libgcc. |
@alexcrichton Do you mean via |
Yeah that's what I'd personally expect. |
An alternative could be to add the |
Link to libgcc when statically linking musl On some architectures (e.g. aarch64) musl depends on some libgcc functions (`__addtf3`, `__multf3`, `__subtf3`) for `long double` arithmetic that it uses internally. Unfortunately we don't provide these functions in compiler-builtins, so we instead need to get them from libgcc. Fixes: rust-lang/rust#46651 rust-lang/compiler-builtins#201 rust-lang/compiler-builtins#217
I think this is resolved by rust-lang/libc#1034. We will link to libgcc when we provide a statically linked libc as part of the libc crate (musl), but otherwise leave it to the dynamic linker to find |
👍 |
If you link some C code into your rust executable (e.g., libc) and that code uses some builtins that aren't needed by Rust (e.g., long double builtins), whose responsibility is it to provide them? This crate or something else?
In other words, should this crate provide C builtins or, if the target is linker_flavour is gcc or ld, should libgcc be added to the list of things linked?
CC @alexcrichton @japaric
Related #201
The text was updated successfully, but these errors were encountered: