Open jesskfullwood opened 5 years ago
I have this issue too - I believe the issue is that liblibc
appears on the linker command line before any C libraries, which means that any parts of libc which are used by a C library, but not by the rust code will be missing.
Ah, that will be it! The breakage is due to changes in the grouping rules in PR #55659
cc @alexcrichton
Another casualty of rustc's bundling behaviour...
Is there a workaround for this? I guess manually build link-args
in .cargo/config?
My 'workaround' is to use the last working version, 1.31.0
. Would be interested in a proper workaround.
Note that this is affecting native aarch64 compilation on Alpine:
= note: /usr/lib/gcc/aarch64-alpine-linux-musl/10.2.1/../../../../aarch64-alpine-linux-musl/bin/ld: /root/sccache/src/target/aarch64-unknown-linux-musl/release/deps/libopenssl_sys-fcc8125410f43229.rlib(ssl_cert.o): in function `ssl_cert_free':
ssl_cert.c:(.text.ssl_cert_free+0x1c): undefined reference to `__aarch64_ldadd4_relax'
/usr/lib/gcc/aarch64-alpine-linux-musl/10.2.1/../../../../aarch64-alpine-linux-musl/bin/ld: /root/sccache/src/target/aarch64-unknown-linux-musl/release/deps/libopenssl_sys-fcc8125410f43229.rlib(ssl_lib.o): in function `SSL_CTX_up_ref':
ssl_lib.c:(.text.SSL_CTX_up_ref+0x14): undefined reference to `__aarch64_ldadd4_relax'
/usr/lib/gcc/aarch64-alpine-linux-musl/10.2.1/../../../../aarch64-alpine-linux-musl/bin/ld: /root/sccache/src/target/aarch64-unknown-linux-musl/release/deps/libopenssl_sys-fcc8125410f43229.rlib(ssl_lib.o): in function `SSL_CTX_free':
ssl_lib.c:(.text.SSL_CTX_free+0x1c): undefined reference to `__aarch64_ldadd4_relax'
/usr/lib/gcc/aarch64-alpine-linux-musl/10.2.1/../../../../aarch64-alpine-linux-musl/bin/ld: /root/sccache/src/target/aarch64-unknown-linux-musl/release/deps/libopenssl_sys-fcc8125410f43229.rlib(ssl_lib.o): in function `SSL_free':
ssl_lib.c:(.text.SSL_free+0x1c): undefined reference to `__aarch64_ldadd4_relax'
/usr/lib/gcc/aarch64-alpine-linux-musl/10.2.1/../../../../aarch64-alpine-linux-musl/bin/ld: /root/sccache/src/target/aarch64-unknown-linux-musl/release/deps/libopenssl_sys-fcc8125410f43229.rlib(ssl_sess.o): in function `SSL_SESSION_free':
ssl_sess.c:(.text.SSL_SESSION_free+0x1c): undefined reference to `__aarch64_ldadd4_relax'
/usr/lib/gcc/aarch64-alpine-linux-musl/10.2.1/../../../../aarch64-alpine-linux-musl/bin/ld: /root/sccache/src/target/aarch64-unknown-linux-musl/release/deps/libopenssl_sys-fcc8125410f43229.rlib(ssl_sess.o):ssl_sess.c:(.text.SSL_SESSION_up_ref+0x14): more undefined references to `__aarch64_ldadd4_relax' follow
/usr/lib/gcc/aarch64-alpine-linux-musl/10.2.1/../../../../aarch64-alpine-linux-musl/bin/ld: /root/sccache/src/target/aarch64-unknown-linux-musl/release/deps/libopenssl_sys-fcc8125410f43229.rlib(lhash.o): in function `getrn':
lhash.c:(.text.getrn+0x3c): undefined reference to `__aarch64_ldadd8_relax'
/usr/lib/gcc/aarch64-alpine-linux-musl/10.2.1/../../../../aarch64-alpine-linux-musl/bin/ld: lhash.c:(.text.getrn+0x94): undefined reference to `__aarch64_ldadd8_relax'
/usr/lib/gcc/aarch64-alpine-linux-musl/10.2.1/../../../../aarch64-alpine-linux-musl/bin/ld: lhash.c:(.text.getrn+0xac): undefined reference to `__aarch64_ldadd8_relax'
/usr/lib/gcc/aarch64-alpine-linux-musl/10.2.1/../../../../aarch64-alpine-linux-musl/bin/ld: /root/sccache/src/target/aarch64-unknown-linux-musl/release/deps/libopenssl_sys-fcc8125410f43229.rlib(lhash.o): in function `OPENSSL_LH_retrieve':
lhash.c:(.text.OPENSSL_LH_retrieve+0x48): undefined reference to `__aarch64_ldadd8_relax'
/usr/lib/gcc/aarch64-alpine-linux-musl/10.2.1/../../../../aarch64-alpine-linux-musl/bin/ld: lhash.c:(.text.OPENSSL_LH_retrieve+0x80): undefined reference to `__aarch64_ldadd8_relax'
/usr/lib/gcc/aarch64-alpine-linux-musl/10.2.1/../../../../aarch64-alpine-linux-musl/bin/ld: /root/sccache/src/target/aarch64-unknown-linux-musl/release/deps/libopenssl_sys-fcc8125410f43229.rlib(drbg_lib.o): in function `RAND_DRBG_instantiate':
drbg_lib.c:(.text.RAND_DRBG_instantiate+0x2d8): undefined reference to `__aarch64_ldadd4_relax'
/usr/lib/gcc/aarch64-alpine-linux-musl/10.2.1/../../../../aarch64-alpine-linux-musl/bin/ld: /root/sccache/src/target/aarch64-unknown-linux-musl/release/deps/libopenssl_sys-fcc8125410f43229.rlib(drbg_lib.o): in function `RAND_DRBG_reseed':
drbg_lib.c:(.text.RAND_DRBG_reseed+0x20c): undefined reference to `__aarch64_ldadd4_relax'
/usr/lib/gcc/aarch64-alpine-linux-musl/10.2.1/../../../../aarch64-alpine-linux-musl/bin/ld: /root/sccache/src/target/aarch64-unknown-linux-musl/release/deps/libopenssl_sys-fcc8125410f43229.rlib(rsa_lib.o): in function `RSA_free':
rsa_lib.c:(.text.RSA_free+0x1c): undefined reference to `__aarch64_ldadd4_relax'
/usr/lib/gcc/aarch64-alpine-linux-musl/10.2.1/../../../../aarch64-alpine-linux-musl/bin/ld: /root/sccache/src/target/aarch64-unknown-linux-musl/release/deps/libopenssl_sys-fcc8125410f43229.rlib(threads_pthread.o): in function `CRYPTO_atomic_add':
threads_pthread.c:(.text.CRYPTO_atomic_add+0x1c): undefined reference to `__aarch64_ldadd4_acq_rel'
/usr/lib/gcc/aarch64-alpine-linux-musl/10.2.1/../../../../aarch64-alpine-linux-musl/bin/ld: /root/sccache/src/target/aarch64-unknown-linux-musl/release/deps/libopenssl_sys-fcc8125410f43229.rlib(x509_lu.o): in function `X509_STORE_free':
x509_lu.c:(.text.X509_STORE_free+0x1c): undefined reference to `__aarch64_ldadd4_relax'
/usr/lib/gcc/aarch64-alpine-linux-musl/10.2.1/../../../../aarch64-alpine-linux-musl/bin/ld: /root/sccache/src/target/aarch64-unknown-linux-musl/release/deps/libopenssl_sys-fcc8125410f43229.rlib(x509_lu.o): in function `X509_STORE_up_ref':
x509_lu.c:(.text.X509_STORE_up_ref+0x14): undefined reference to `__aarch64_ldadd4_relax'
/usr/lib/gcc/aarch64-alpine-linux-musl/10.2.1/../../../../aarch64-alpine-linux-musl/bin/ld: /root/sccache/src/target/aarch64-unknown-linux-musl/release/deps/libopenssl_sys-fcc8125410f43229.rlib(x509_set.o): in function `X509_up_ref':
x509_set.c:(.text.X509_up_ref+0x14): undefined reference to `__aarch64_ldadd4_relax'
/usr/lib/gcc/aarch64-alpine-linux-musl/10.2.1/../../../../aarch64-alpine-linux-musl/bin/ld: /root/sccache/src/target/aarch64-unknown-linux-musl/release/deps/libopenssl_sys-fcc8125410f43229.rlib(x509cset.o): in function `X509_CRL_up_ref':
x509cset.c:(.text.X509_CRL_up_ref+0x14): undefined reference to `__aarch64_ldadd4_relax'
collect2: error: ld returned 1 exit status
Unsure if this is a duplicate issue, so I'll post it here: cc: @Nilstrieb (talked about it on discord)
I tried this code: (host: x86_64-unknown-linux-gnu
)
# .cargo/config.coml
[build]
target = "x86_64-unknown-linux-musl"
[target.x86_64-unknown-linux-musl]
rustflags = ["-C", "target-feature=-crt-static"]
// main.rs
fn main() {
println!("{}", std::hint::black_box(45.0f64).exp());
}
$ cargo run
I expected to see this happen: Compiles, prints a large number, and exits successfully.
Instead, this happened: A linker error:
in function `std::f64::<impl f64>::exp': <path elided>: undefined reference to `exp'
The error only happens with -C target-feature=-crt-static
. I do not get the error with no flags, or with -C target-feature=+crt-static
.
... where X is things like 'printf', i.e. symbols that clearly should exist.
This looks similar to other reported bugs, particularly https://github.com/rust-lang/rust/issues/58163, but this one a) used to work until Rust 1.32 and b) is not embedded/no-std.
Using my
nlopt
library to reproduce. You will needmusl
installed. I am running linux/ubuntu 18.04. Disclaimer: I am no expert and I may have completely messed up how linking etc is supposed to be done.It works on this nightly:
But barfs on the next nightly:
with the following: