You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
x11-dl fails to link when building a x86_64-unknown-linux-musl target on Ubuntu 20.04 when using rust 1.72+.
Notably:
It works with rust 1.71 and 1.70 on Ubuntu 20.04.
It doesn't work with rust 1.72+ on Ubuntu 20.04.
It works with rust 1.72+ on Ubuntu 22.04.
The error:
Updating crates.io index
Downloaded pkg-config v0.3.27
Downloaded x11-dl v2.21.0
Downloaded once_cell v1.19.0
Downloaded libc v0.2.151
Downloaded 4 crates (855.3 KB) in 0.23s
Compiling pkg-config v0.3.27
Compiling libc v0.2.151
Compiling once_cell v1.19.0
Compiling x11-dl v2.21.0
Compiling musl-regression v0.1.0 (/workspace)
error: linking with `cc` failed: exit status: 1
|
= note: LC_ALL="C" PATH="/usr/local/rustup/toolchains/1.72.1-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/bin:/usr/local/rustup/toolchains/1.72.1-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/bin/self-contained:/usr/local/cargo/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" VSLANG="1033" "cc" "-m64" "/usr/local/rustup/toolchains/1.72.1-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-musl/lib/self-contained/rcrt1.o" "/usr/local/rustup/toolchains/1.72.1-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-musl/lib/self-contained/crti.o" "/usr/local/rustup/toolchains/1.72.1-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-musl/lib/self-contained/crtbeginS.o" "/tmp/rustcSTX9Z1/symbols.o" "/workspace/target/x86_64-unknown-linux-musl/release/deps/musl_regression-77deb0674082954c.musl_regression.26b44efdc4f212ed-cgu.0.rcgu.o" "/workspace/target/x86_64-unknown-linux-musl/release/deps/musl_regression-77deb0674082954c.4s5t4glzt8py8l6f.rcgu.o" "-Wl,--as-needed" "-L" "/workspace/target/x86_64-unknown-linux-musl/release/deps" "-L" "/workspace/target/release/deps" "-L" "/usr/local/rustup/toolchains/1.72.1-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-musl/lib" "-Wl,-Bstatic" "/workspace/target/x86_64-unknown-linux-musl/release/deps/libx11_dl-d6b23cc6173e7d51.rlib" "-ldl" "/workspace/target/x86_64-unknown-linux-musl/release/deps/libonce_cell-759912b9dbe0886f.rlib" "/workspace/target/x86_64-unknown-linux-musl/release/deps/liblibc-8272ff1ad9665ed5.rlib" "/usr/local/rustup/toolchains/1.72.1-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-musl/lib/libstd-0db0d6d2ee994876.rlib" "/usr/local/rustup/toolchains/1.72.1-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-musl/lib/libpanic_unwind-7a2e60b0e9eb9056.rlib" "/usr/local/rustup/toolchains/1.72.1-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-musl/lib/libobject-4b607c04ea951a2c.rlib" "/usr/local/rustup/toolchains/1.72.1-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-musl/lib/libmemchr-949e448921b0c3f5.rlib" "/usr/local/rustup/toolchains/1.72.1-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-musl/lib/libaddr2line-e3f9689cd5b5a41d.rlib" "/usr/local/rustup/toolchains/1.72.1-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-musl/lib/libgimli-0e70cdfcb0031c33.rlib" "/usr/local/rustup/toolchains/1.72.1-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-musl/lib/librustc_demangle-57b59feaa1b70095.rlib" "/usr/local/rustup/toolchains/1.72.1-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-musl/lib/libstd_detect-e278f14bb4b6e96c.rlib" "/usr/local/rustup/toolchains/1.72.1-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-musl/lib/libhashbrown-45b0424662a80305.rlib" "/usr/local/rustup/toolchains/1.72.1-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-musl/lib/librustc_std_workspace_alloc-e02a79e2a5f7b177.rlib" "/usr/local/rustup/toolchains/1.72.1-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-musl/lib/libminiz_oxide-511090649e32436b.rlib" "/usr/local/rustup/toolchains/1.72.1-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-musl/lib/libadler-9bd99b6b25df938c.rlib" "/usr/local/rustup/toolchains/1.72.1-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-musl/lib/libunwind-e54d145a7d2f0d2e.rlib" "-lunwind" "/usr/local/rustup/toolchains/1.72.1-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-musl/lib/libcfg_if-10d3a2bbaae84d7e.rlib" "/usr/local/rustup/toolchains/1.72.1-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-musl/lib/liblibc-54153eb97d829261.rlib" "-lc" "/usr/local/rustup/toolchains/1.72.1-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-musl/lib/liballoc-3b448b3577f8ed49.rlib" "/usr/local/rustup/toolchains/1.72.1-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-musl/lib/librustc_std_workspace_core-0f8c166bfb10ec45.rlib" "/usr/local/rustup/toolchains/1.72.1-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-musl/lib/libcore-97c65677b477e100.rlib" "/usr/local/rustup/toolchains/1.72.1-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-musl/lib/libcompiler_builtins-263be272f87964bd.rlib" "-Wl,-Bdynamic" "-Wl,--eh-frame-hdr" "-Wl,-z,noexecstack" "-nostartfiles" "-L" "/usr/local/rustup/toolchains/1.72.1-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-musl/lib" "-L" "/usr/local/rustup/toolchains/1.72.1-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-musl/lib/self-contained" "-o" "/workspace/target/x86_64-unknown-linux-musl/release/deps/musl_regression-77deb0674082954c" "-Wl,--gc-sections" "-static-pie" "-Wl,-z,relro,-z,now" "-Wl,-O1" "-nodefaultlibs" "/usr/local/rustup/toolchains/1.72.1-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-musl/lib/self-contained/crtendS.o" "/usr/local/rustup/toolchains/1.72.1-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-musl/lib/self-contained/crtn.o"
= note: /usr/bin/ld: /workspace/target/x86_64-unknown-linux-musl/release/deps/libx11_dl-d6b23cc6173e7d51.rlib(x11_dl-d6b23cc6173e7d51.x11_dl.75b761a48188fd34-cgu.09.rcgu.o): in function `x11_dl::link::DynamicLibrary::open_multi':
x11_dl.75b761a48188fd34-cgu.09:(.text._ZN6x11_dl4link14DynamicLibrary10open_multi17h99db2284c86beb5aE+0x1e4): warning: Using 'dlopen' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
/usr/bin/ld: /usr/local/rustup/toolchains/1.72.1-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-musl/lib/self-contained/libc.a(dlerror.lo): in function `__get_tp':
/build/musl-cross-make/build/local/x86_64-linux-musl/obj_musl/../src_musl/arch/x86_64/pthread_arch.h:4: multiple definition of `dlerror'; /usr/lib/gcc/x86_64-linux-gnu/10/../../../x86_64-linux-gnu/libdl.a(dlerror.o):(.text+0x0): first defined here
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/10/../../../x86_64-linux-gnu/libdl.a(dlopen.o): in function `dlopen':
(.text+0x5): undefined reference to `__dlopen'
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/10/../../../x86_64-linux-gnu/libdl.a(dlclose.o): in function `dlclose':
(.text+0x1): undefined reference to `__dlclose'
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/10/../../../x86_64-linux-gnu/libdl.a(dlerror.o): in function `dlerror':
(.text+0x1): undefined reference to `__dlerror'
collect2: error: ld returned 1 exit status
= note: some `extern` functions couldn't be found; some native libraries may need to be installed or have their path specified
= note: use the `-l` flag to specify native libraries to link
= note: use the `cargo:rustc-link-lib` directive to specify the native libraries to link with Cargo (see https://doc.rust-lang.org/cargo/reference/build-scripts.html#cargorustc-link-libkindname)
error: could not compile `musl-regression` (bin "musl-regression") due to previous error
Reproducing
I was able to isolate this to the most simple case.
cargo new --bin musl-regression && \
cd musl-regression && \
cargo add x11-dl
x11-dl
fails to link when building ax86_64-unknown-linux-musl
target on Ubuntu 20.04 when using rust1.72+
.Notably:
1.71
and1.70
on Ubuntu 20.04.1.72+
on Ubuntu 20.04.1.72+
on Ubuntu 22.04.The error:
Reproducing
I was able to isolate this to the most simple case.
We're going to invoke different containers and call this command inside them:
rustup target add x86_64-unknown-linux-musl && cargo build --release --target=x86_64-unknown-linux-musl
The containers we're invoking:
The text was updated successfully, but these errors were encountered: