Skip to content

Cross compilation errors for x86_64-unknown-linux-musl from v1.72 #116348

Closed
@deepu105

Description

@deepu105

Code

The cargo build for x86_64-unknown-linux-musl target started failing with the below errors from Rust version 1.72 onwards (see backtrace for full error). The same codebase compiles without issues on 1.71. Issue seems to be around using the xcb library and all required libs are installed on the host

apt-get install -y -qq pkg-config libssl-dev libxcb1-dev libxcb-render0-dev libxcb-shape0-dev libxcb-xfixes0-dev xauth musl-tools

cargo build --release --target x86_64-unknown-linux-musl

# also tried
cargo rustc --release --target x86_64-unknown-linux-musl -- -lXau

Project codebase: https://github.com/kdash-rs/kdash. To reproduce, run this docker file on the cloned repo.

rustc 1.75.0-nightly (e0d7ed1f4 2023-10-01)
0.479    Compiling kdash v0.4.3 (/usr/src/kdash-temp)
120.8 error: linking with `cc` failed: exit status: 1
...
120.8   = note: /usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/12/../../../x86_64-linux-gnu/libxcb.a(xcb_util.o): in function `_xcb_open_tcp':
120.8           (.text+0x3f2): undefined reference to `__snprintf_chk'
120.8           /usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/12/../../../x86_64-linux-gnu/libxcb.a(xcb_util.o): in function `xcb_connect_to_display_with_auth_info':
120.8           (.text+0x6cc): undefined reference to `__snprintf_chk'
120.8           /usr/bin/ld: (.text+0x72e): undefined reference to `__strcpy_chk'
120.8           /usr/bin/ld: (.text+0x8c6): undefined reference to `__strcpy_chk'
120.8           /usr/bin/ld: (.text+0x9fe): undefined reference to `__strcpy_chk'
120.8           /usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/12/../../../x86_64-linux-gnu/libxcb.a(xcb_auth.o): in function `get_authptr':
120.8           (.text+0xaf): undefined reference to `__snprintf_chk'
120.8           /usr/bin/ld: (.text+0xfe): undefined reference to `XauGetBestAuthByAddr'
120.8           /usr/bin/ld: (.text+0x14f): undefined reference to `__snprintf_chk'
120.8           /usr/bin/ld: (.text+0x19a): undefined reference to `__snprintf_chk'
120.8           /usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/12/../../../x86_64-linux-gnu/libxcb.a(xcb_auth.o): in function `_xcb_get_auth_info':
120.8           (.text+0x316): undefined reference to `XauDisposeAuth'
120.8           /usr/bin/ld: (.text+0x552): undefined reference to `XdmcpWrap'
120.8           /usr/bin/ld: (.text+0x562): undefined reference to `XauDisposeAuth'
120.8           collect2: error: ld returned 1 exit status
120.8           
120.8   = note: some `extern` functions couldn't be found; some native libraries may need to be installed or have their path specified
120.8   = note: use the `-l` flag to specify native libraries to link
120.8   = 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)
120.8 
120.8 error: could not compile `kdash` (bin "kdash") due to previous error

I have tried to build this natively on alpine Linux and cross-compilation on arch Linux and fails in both.

Version it worked on

It most recently worked on: 1.71

Version with regression

1.72 stable

commit-hash: d5c2e9c342b358556da91d61ed4133f6f50fc0c3                                                                                                                                                                                                                  
commit-date: 2023-09-13                                                                                                                                                                                                                                                
host: x86_64-unknown-linux-gnu                                                                                                                                                                                                                                         
release: 1.72.1                                                                                                                                                                                                                                                        
LLVM version: 16.0.5

1.75 nightly

rustc 1.75.0-nightly (e0d7ed1f4 2023-10-01)                                                                                                                                                                                                                               
0.419 binary: rustc
commit-hash: e0d7ed1f453fb54578cc96dfea859b0e7be15016                                                                                                                                                                                                                  
commit-date: 2023-10-01                                                                                                                                                                                                                                                
host: x86_64-unknown-linux-gnu                                                                                                                                                                                                                                         
release: 1.75.0-nightly                                                                                                                                                                                                                                                
LLVM version: 17.0.2

Backtrace

Backtrace

[builder 13/13] RUN rustc --version --verbose && RUST_BACKTRACE=1 cargo rustc --release --target x86_64-unknown-linux-musl -- -lXau:                                                                                                                                         
0.419 rustc 1.75.0-nightly (e0d7ed1f4 2023-10-01)                                                                                                                                                                                                                               
0.419 binary: rustc                                                                                                                                                                                                                                                             
0.419 commit-hash: e0d7ed1f453fb54578cc96dfea859b0e7be15016                                                                                                                                                                                                                     
0.419 commit-date: 2023-10-01                                                                                                                                                                                                                                                   
0.419 host: x86_64-unknown-linux-gnu
0.419 release: 1.75.0-nightly
0.421 LLVM version: 17.0.2
0.602    Compiling kdash v0.4.3 (/usr/src/kdash-temp)
121.7 error: linking with `cc` failed: exit status: 1
121.7   |
121.7   = note: LC_ALL="C" PATH="/usr/local/rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/bin:/usr/local/rustup/toolchains/nightly-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/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-musl/lib/self-contained/rcrt1.o" "/usr/local/rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-musl/lib/self-contained/crti.o" "/usr/local/rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-musl/lib/self-contained/crtbeginS.o" "/tmp/rustcacwY7H/symbols.o" "/usr/src/kdash-temp/target/x86_64-unknown-linux-musl/release/deps/kdash-bf16b0078dfec89f.kdash.3a14523d29565840-cgu.0.rcgu.o" "-Wl,--as-needed" "-L" "/usr/src/kdash-temp/target/x86_64-unknown-linux-musl/release/deps" "-L" "/usr/src/kdash-temp/target/release/deps" "-L" "/usr/src/kdash-temp/target/x86_64-unknown-linux-musl/release/build/ring-ac80321802c4ed69/out" "-L" "/usr/src/kdash-temp/target/x86_64-unknown-linux-musl/release/build/openssl-sys-629f07187f0967c8/out/openssl-build/install/lib" "-L" "/usr/local/rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-musl/lib" "-Wl,-Bstatic" "-lXau" "-lxcb" "-lxcb-render" "-lxcb-shape" "-lxcb-xfixes" "/tmp/rustcacwY7H/libring-f3a6144b616625a2.rlib" "-lunwind" "-lc" "/usr/local/rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-musl/lib/libcompiler_builtins-8f02a7813ca6535d.rlib" "-Wl,-Bdynamic" "-Wl,--eh-frame-hdr" "-Wl,-z,noexecstack" "-nostartfiles" "-L" "/usr/local/rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-musl/lib" "-L" "/usr/local/rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-musl/lib/self-contained" "-o" "/usr/src/kdash-temp/target/x86_64-unknown-linux-musl/release/deps/kdash-bf16b0078dfec89f" "-Wl,--gc-sections" "-static-pie" "-Wl,-z,relro,-z,now" "-Wl,-O1" "-nodefaultlibs" "/usr/local/rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-musl/lib/self-contained/crtendS.o" "/usr/local/rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-musl/lib/self-contained/crtn.o"
121.7   = note: /usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/12/../../../x86_64-linux-gnu/libxcb.a(xcb_util.o): in function `_xcb_open_tcp':
121.7           (.text+0x3f2): undefined reference to `__snprintf_chk'
121.7           /usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/12/../../../x86_64-linux-gnu/libxcb.a(xcb_util.o): in function `xcb_connect_to_display_with_auth_info':
121.7           (.text+0x6cc): undefined reference to `__snprintf_chk'
121.7           /usr/bin/ld: (.text+0x72e): undefined reference to `__strcpy_chk'
121.7           /usr/bin/ld: (.text+0x8c6): undefined reference to `__strcpy_chk'
121.7           /usr/bin/ld: (.text+0x9fe): undefined reference to `__strcpy_chk'
121.7           /usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/12/../../../x86_64-linux-gnu/libxcb.a(xcb_auth.o): in function `get_authptr':
121.7           (.text+0xaf): undefined reference to `__snprintf_chk'
121.7           /usr/bin/ld: (.text+0xfe): undefined reference to `XauGetBestAuthByAddr'
121.7           /usr/bin/ld: (.text+0x14f): undefined reference to `__snprintf_chk'
121.7           /usr/bin/ld: (.text+0x19a): undefined reference to `__snprintf_chk'
121.7           /usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/12/../../../x86_64-linux-gnu/libxcb.a(xcb_auth.o): in function `_xcb_get_auth_info':
121.7           (.text+0x316): undefined reference to `XauDisposeAuth'
121.7           /usr/bin/ld: (.text+0x552): undefined reference to `XdmcpWrap'
121.7           /usr/bin/ld: (.text+0x562): undefined reference to `XauDisposeAuth'
121.7           collect2: error: ld returned 1 exit status
121.7           
121.7   = note: some `extern` functions couldn't be found; some native libraries may need to be installed or have their path specified
121.7   = note: use the `-l` flag to specify native libraries to link
121.7   = 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)
121.7 
121.7 error: could not compile `kdash` (bin "kdash") due to previous error
------
Dockerfile:31
--------------------
  29 |     RUN apt-get install -y -qq pkg-config libssl-dev libxcb1-dev libxcb-render0-dev libxcb-shape0-dev libxcb-xfixes0-dev xauth
  30 |     
  31 | >>> RUN rustc --version --verbose && RUST_BACKTRACE=1 cargo rustc --release --target x86_64-unknown-linux-musl -- -lXau
  32 |     
  33 |     # -----------------------------
--------------------
ERROR: failed to solve: process "/bin/sh -c rustc --version --verbose && RUST_BACKTRACE=1 cargo rustc --release --target x86_64-unknown-linux-musl -- -lXau" did not complete successfully: exit code: 101
make: *** [Makefile:37: docker] Error 1

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-linkageArea: linking into static, shared libraries and binariesC-bugCategory: This is a bug.E-needs-bisectionCall for participation: This issue needs bisection: https://github.com/rust-lang/cargo-bisect-rustcO-muslTarget: The musl libcregression-untriagedUntriaged performance or correctness regression.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions