Skip to content
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

Missing intrinsic functions on aarch64/armv7 musl #985

Closed
4 of 11 tasks
NobodyXu opened this issue Jul 29, 2022 · 8 comments
Closed
4 of 11 tasks

Missing intrinsic functions on aarch64/armv7 musl #985

NobodyXu opened this issue Jul 29, 2022 · 8 comments
Labels
A-musl Area: musl libc targets upstream

Comments

@NobodyXu
Copy link

NobodyXu commented Jul 29, 2022

Checklist

Describe your issue

When using -Z build-std=std,panic_abort -Z build-std-features=panic_immediate_abort on nightly, the CI for armv7-unknown-linux-musleabihf failed with:

error: linking with `arm-linux-musleabihf-gcc` failed: exit status: 1
  |
  = note: "arm-linux-musleabihf-gcc" "/rust/lib/rustlib/armv7-unknown-linux-musleabihf/lib/self-contained/crt1.o" "/rust/lib/rustlib/armv7-unknown-linux-musleabihf/lib/self-contained/crti.o" "/rust/lib/rustlib/armv7-unknown-linux-musleabihf/lib/self-contained/crtbegin.o" "/tmp/rustchhh9b4/symbols.o" "/target/armv7-unknown-linux-musleabihf/release/deps/cargo_binstall-3e50bf6da12c20a5.cargo_binstall.a21ddfed-cgu.0.rcgu.o" "-Wl,--as-needed" "-L" "/target/armv7-unknown-linux-musleabihf/release/deps" "-L" "/target/release/deps" "-L" "/target/armv7-unknown-linux-musleabihf/release/build/bzip2-sys-c8079e4346e62d12/out/lib" "-L" "/target/armv7-unknown-linux-musleabihf/release/build/ring-ebc6c8a01f6ba0cc/out" "-L" "/target/armv7-unknown-linux-musleabihf/release/build/libz-ng-sys-f0f6c53a33219098/out/lib" "-L" "/target/armv7-unknown-linux-musleabihf/release/build/lzma-sys-b43b0fc572ecbfdb/out" "-L" "/target/armv7-unknown-linux-musleabihf/release/build/zstd-sys-2590e47ee852bb0f/out" "-L" "/rust/lib/rustlib/armv7-unknown-linux-musleabihf/lib" "-Wl,-Bstatic" "/tmp/rustchhh9b4/libzstd_sys-f7d06c8757472495.rlib" "/tmp/rustchhh9b4/liblzma_sys-2e2684a73a1d7334.rlib" "/tmp/rustchhh9b4/liblibz_ng_sys-3508004d4f9f58ad.rlib" "/tmp/rustchhh9b4/libbzip2_sys-d3cb4d953a9c8aa6.rlib" "/tmp/rustchhh9b4/libring-4ed7a44158b48a92.rlib" "-Wl,--start-group" "-lunwind" "-lc" "-Wl,--end-group" "/target/armv7-unknown-linux-musleabihf/release/deps/libcompiler_builtins-6e6f29f70316d02a.rlib" "-Wl,-Bdynamic" "-Wl,--eh-frame-hdr" "-Wl,-znoexecstack" "-nostartfiles" "-L" "/rust/lib/rustlib/armv7-unknown-linux-musleabihf/lib" "-L" "/rust/lib/rustlib/armv7-unknown-linux-musleabihf/lib/self-contained" "-o" "/target/armv7-unknown-linux-musleabihf/release/deps/cargo_binstall-3e50bf6da12c20a5" "-Wl,--gc-sections" "-static" "-no-pie" "-Wl,-zrelro,-znow" "-Wl,--strip-all" "-nodefaultlibs" "/rust/lib/rustlib/armv7-unknown-linux-musleabihf/lib/self-contained/crtend.o" "/rust/lib/rustlib/armv7-unknown-linux-musleabihf/lib/self-contained/crtn.o"
  = note: /usr/local/bin/../lib/gcc/arm-linux-musleabihf/9.2.0/../../../../arm-linux-musleabihf/bin/ld: /tmp/rustchhh9b4/liblibz_ng_sys-3508004d4f9f58ad.rlib(compare256_neon.c.o): in function `compare256_neon_static':
          compare256_neon.c:(.text.compare256_neon_static+0x28): undefined reference to `__ctzdi2'
          /usr/local/bin/../lib/gcc/arm-linux-musleabihf/9.2.0/../../../../arm-linux-musleabihf/bin/ld: compare256_neon.c:(.text.compare256_neon_static+0x42): undefined reference to `__ctzdi2'
          collect2: error: ld returned 1 exit status
          
  = help: 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 `cargo-binstall` due to previous error
Error: Process completed with exit code 101.

And the CI for aarch64-unknown-linux-musl failed with similar error.

What target(s) are you cross-compiling for?

aarch64-unknown-linux-musl, armv7-unknown-linux-musleabihf

Which operating system is the host (e.g computer cross is on) running?

  • macOS
  • Windows
  • Linux / BSD
  • other OS (specify in description)

What architecture is the host?

  • x86_64 / AMD64
  • arm32
  • arm64 (including Mac M1)

What container engine is cross using?

  • docker
  • podman
  • other container engine (specify in description)

cross version

cross 0.2.4 (4645d93 2022-07-10)

Example

cross seems to have missing intrinsic functions on aarch64/armv7 musl build when using build-std features:

cross build --target aarch64-unknown-linux-musl --profile release -Z build-std=std,panic_abort -Z build-std-features=panic_immediate_abort

It only happens if we have the build-std configurations.

Additional information / notes

This might be related to #896

This issue was discovered in cargo-bins/cargo-binstall#256 .

@Emilgardis Emilgardis added the A-musl Area: musl libc targets label Jul 29, 2022
@Alexhuszagh
Copy link
Contributor

Alexhuszagh commented Jul 29, 2022

Interestingly, this doesn't seem to reproduce in a simple package with a C++ dependency:

$ cross +nightly --version
cross 0.2.4 (678e3d7 2022-07-29)
[cross] warning: using newer rustc `1.63.0-nightly (fee3a459d 2022-06-05)` for the target. Current active rustc on the host is `rustc 1.61.0 (fe5b13d68 2022-05-18)`.
 > Update with `rustup update`
[cross] note: Falling back to `cargo` on the host.
cargo 1.63.0-nightly (38472bc19 2022-05-31)

$ git clone https://github.com/cross-rs/rust-cpp-hello-word
$ cd rust-cpp-hello-word

$ cross +nightly build --target armv7-unknown-linux-musleabihf -Z build-std=std,panic_abort -Z build-std-features=panic_immediate_abort
[cross] warning: using newer rustc `1.63.0-nightly (fee3a459d 2022-06-05)` for the target. Current active rustc on the host is `rustc 1.61.0 (fe5b13d68 2022-05-18)`.
 > Update with `rustup update`
   Compiling core v0.0.0 (/home/ahusz/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core)
   Compiling std v0.0.0 (/home/ahusz/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std)
   Compiling rustc-std-workspace-core v1.99.0 (/home/ahusz/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/rustc-std-workspace-core)
   Compiling compiler_builtins v0.1.73
   Compiling libc v0.2.126
   Compiling alloc v0.0.0 (/home/ahusz/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/alloc)
   Compiling cfg-if v0.1.10
   Compiling rustc-demangle v0.1.21
   Compiling unwind v0.0.0 (/home/ahusz/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/unwind)
   Compiling rustc-std-workspace-alloc v1.99.0 (/home/ahusz/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/rustc-std-workspace-alloc)
   Compiling panic_abort v0.0.0 (/home/ahusz/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/panic_abort)
   Compiling panic_unwind v0.0.0 (/home/ahusz/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/panic_unwind)
   Compiling std_detect v0.1.5 (/home/ahusz/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/stdarch/crates/std_detect)
   Compiling hashbrown v0.12.0
   Compiling proc_macro v0.0.0 (/home/ahusz/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/proc_macro)
   Compiling hellopp v0.1.0 (/mnt/c/Users/ahusz/git/rust-cpp-hello-word)
    Finished dev [unoptimized + debuginfo] target(s) in 31.84s

This does fail however for aarch64-unknown-linux-musl:

error: linking with `aarch64-linux-musl-gcc.sh` failed: exit status: 1
  |
  = note: "aarch64-linux-musl-gcc.sh" "/home/ahusz/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/aarch64-unknown-linux-musl/lib/self-contained/crt1.o" "/home/ahusz/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/aarch64-unknown-linux-musl/lib/self-contained/crti.o" "/home/ahusz/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/aarch64-unknown-linux-musl/lib/self-contained/crtbegin.o" "/tmp/rustcgsdU4c/symbols.o" "/target/aarch64-unknown-linux-musl/debug/deps/hellopp-e18a46c88e8651c0.17yj6cbrqsa7ydok.rcgu.o" "/target/aarch64-unknown-linux-musl/debug/deps/hellopp-e18a46c88e8651c0.31ozsu1nxvk40u8p.rcgu.o" "/target/aarch64-unknown-linux-musl/debug/deps/hellopp-e18a46c88e8651c0.3jb6c2penqwbl1tw.rcgu.o" "/target/aarch64-unknown-linux-musl/debug/deps/hellopp-e18a46c88e8651c0.43s4nhow0bh4mdu7.rcgu.o" "/target/aarch64-unknown-linux-musl/debug/deps/hellopp-e18a46c88e8651c0.4jh1kcigexzy7mj.rcgu.o" "/target/aarch64-unknown-linux-musl/debug/deps/hellopp-e18a46c88e8651c0.86k6xqe3mcfnldm.rcgu.o" "/target/aarch64-unknown-linux-musl/debug/deps/hellopp-e18a46c88e8651c0.37wbsb42mhp6kphi.rcgu.o" "-Wl,--as-needed" "-L" "/target/aarch64-unknown-linux-musl/debug/deps" "-L" "/target/debug/deps" "-L" "/target/aarch64-unknown-linux-musl/debug/build/hellopp-be12ba6d38a66dd4/out" "-L" "/home/ahusz/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/aarch64-unknown-linux-musl/lib" "-Wl,-Bstatic" "-lhellopp" "-Wl,-Bdynamic" "-lstdc++" "-Wl,--start-group" "-Wl,-Bstatic" "/target/aarch64-unknown-linux-musl/debug/deps/libstd-2b9a1a9c35b1230a.rlib" "/target/aarch64-unknown-linux-musl/debug/deps/libpanic_unwind-d70e14d6e59177bc.rlib" "/target/aarch64-unknown-linux-musl/debug/deps/librustc_demangle-f3d5b949b7b1a5de.rlib" "/target/aarch64-unknown-linux-musl/debug/deps/libstd_detect-59b5d3ce85adba29.rlib" "/target/aarch64-unknown-linux-musl/debug/deps/libhashbrown-2f24b7025c0e4078.rlib" "/target/aarch64-unknown-linux-musl/debug/deps/librustc_std_workspace_alloc-f93333caf4316797.rlib" "/target/aarch64-unknown-linux-musl/debug/deps/libunwind-755d10c7440dc2d0.rlib" "-lunwind" "/target/aarch64-unknown-linux-musl/debug/deps/libcfg_if-22929b06043a7aec.rlib" "/target/aarch64-unknown-linux-musl/debug/deps/liblibc-3e7ed81f524f85a0.rlib" "-lc" "/target/aarch64-unknown-linux-musl/debug/deps/liballoc-64350ab48d7b62c5.rlib" "/target/aarch64-unknown-linux-musl/debug/deps/librustc_std_workspace_core-ab8f7e806a10a573.rlib" "/target/aarch64-unknown-linux-musl/debug/deps/libcore-b2d649ba95a0a0a1.rlib" "-Wl,--end-group" "/target/aarch64-unknown-linux-musl/debug/deps/libcompiler_builtins-d8af7abe78822f7d.rlib" "-Wl,-Bdynamic" "-Wl,--eh-frame-hdr" "-Wl,-znoexecstack" "-nostartfiles" "-L" "/home/ahusz/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/aarch64-unknown-linux-musl/lib" "-L" "/home/ahusz/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/aarch64-unknown-linux-musl/lib/self-contained" "-o" "/target/aarch64-unknown-linux-musl/debug/deps/hellopp-e18a46c88e8651c0" "-Wl,--gc-sections" "-static" "-no-pie" "-Wl,-zrelro,-znow" "-nodefaultlibs" "/home/ahusz/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/aarch64-unknown-linux-musl/lib/self-contained/crtend.o" "/home/ahusz/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/aarch64-unknown-linux-musl/lib/self-contained/crtn.o"
  = note: + set -euo pipefail
          + main /home/ahusz/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/aarch64-unknown-linux-musl/lib/self-contained/crt1.o /home/ahusz/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/aarch64-unknown-linux-musl/lib/self-contained/crti.o /home/ahusz/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/aarch64-unknown-linux-musl/lib/self-contained/crtbegin.o /tmp/rustcgsdU4c/symbols.o /target/aarch64-unknown-linux-musl/debug/deps/hellopp-e18a46c88e8651c0.17yj6cbrqsa7ydok.rcgu.o /target/aarch64-unknown-linux-musl/debug/deps/hellopp-e18a46c88e8651c0.31ozsu1nxvk40u8p.rcgu.o /target/aarch64-unknown-linux-musl/debug/deps/hellopp-e18a46c88e8651c0.3jb6c2penqwbl1tw.rcgu.o /target/aarch64-unknown-linux-musl/debug/deps/hellopp-e18a46c88e8651c0.43s4nhow0bh4mdu7.rcgu.o /target/aarch64-unknown-linux-musl/debug/deps/hellopp-e18a46c88e8651c0.4jh1kcigexzy7mj.rcgu.o /target/aarch64-unknown-linux-musl/debug/deps/hellopp-e18a46c88e8651c0.86k6xqe3mcfnldm.rcgu.o /target/aarch64-unknown-linux-musl/debug/deps/hellopp-e18a46c88e8651c0.37wbsb42mhp6kphi.rcgu.o -Wl,--as-needed -L /target/aarch64-unknown-linux-musl/debug/deps -L /target/debug/deps -L /target/aarch64-unknown-linux-musl/debug/build/hellopp-be12ba6d38a66dd4/out -L /home/ahusz/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/aarch64-unknown-linux-musl/lib -Wl,-Bstatic -lhellopp -Wl,-Bdynamic -lstdc++ -Wl,--start-group -Wl,-Bstatic /target/aarch64-unknown-linux-musl/debug/deps/libstd-2b9a1a9c35b1230a.rlib /target/aarch64-unknown-linux-musl/debug/deps/libpanic_unwind-d70e14d6e59177bc.rlib /target/aarch64-unknown-linux-musl/debug/deps/librustc_demangle-f3d5b949b7b1a5de.rlib /target/aarch64-unknown-linux-musl/debug/deps/libstd_detect-59b5d3ce85adba29.rlib /target/aarch64-unknown-linux-musl/debug/deps/libhashbrown-2f24b7025c0e4078.rlib /target/aarch64-unknown-linux-musl/debug/deps/librustc_std_workspace_alloc-f93333caf4316797.rlib /target/aarch64-unknown-linux-musl/debug/deps/libunwind-755d10c7440dc2d0.rlib -lunwind /target/aarch64-unknown-linux-musl/debug/deps/libcfg_if-22929b06043a7aec.rlib /target/aarch64-unknown-linux-musl/debug/deps/liblibc-3e7ed81f524f85a0.rlib -lc /target/aarch64-unknown-linux-musl/debug/deps/liballoc-64350ab48d7b62c5.rlib /target/aarch64-unknown-linux-musl/debug/deps/librustc_std_workspace_core-ab8f7e806a10a573.rlib /target/aarch64-unknown-linux-musl/debug/deps/libcore-b2d649ba95a0a0a1.rlib -Wl,--end-group /target/aarch64-unknown-linux-musl/debug/deps/libcompiler_builtins-d8af7abe78822f7d.rlib -Wl,-Bdynamic -Wl,--eh-frame-hdr -Wl,-znoexecstack -nostartfiles -L /home/ahusz/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/aarch64-unknown-linux-musl/lib -L /home/ahusz/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/aarch64-unknown-linux-musl/lib/self-contained -o /target/aarch64-unknown-linux-musl/debug/deps/hellopp-e18a46c88e8651c0 -Wl,--gc-sections -static -no-pie -Wl,-zrelro,-znow -nodefaultlibs /home/ahusz/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/aarch64-unknown-linux-musl/lib/self-contained/crtend.o /home/ahusz/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/aarch64-unknown-linux-musl/lib/self-contained/crtn.o
          + local release=
          ++ rustc -Vv
          ++ grep '^release:'
          ++ cut -d : -f2
          + release=' 1.63.0-nightly'
          + local minor=
          ++ echo ' 1.63.0-nightly'
          ++ cut -d . -f2
          + minor=63
          + ((  minor >= 48  ))
          + aarch64-linux-musl-gcc /home/ahusz/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/aarch64-unknown-linux-musl/lib/self-contained/crt1.o /home/ahusz/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/aarch64-unknown-linux-musl/lib/self-contained/crti.o /home/ahusz/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/aarch64-unknown-linux-musl/lib/self-contained/crtbegin.o /tmp/rustcgsdU4c/symbols.o /target/aarch64-unknown-linux-musl/debug/deps/hellopp-e18a46c88e8651c0.17yj6cbrqsa7ydok.rcgu.o /target/aarch64-unknown-linux-musl/debug/deps/hellopp-e18a46c88e8651c0.31ozsu1nxvk40u8p.rcgu.o /target/aarch64-unknown-linux-musl/debug/deps/hellopp-e18a46c88e8651c0.3jb6c2penqwbl1tw.rcgu.o /target/aarch64-unknown-linux-musl/debug/deps/hellopp-e18a46c88e8651c0.43s4nhow0bh4mdu7.rcgu.o /target/aarch64-unknown-linux-musl/debug/deps/hellopp-e18a46c88e8651c0.4jh1kcigexzy7mj.rcgu.o /target/aarch64-unknown-linux-musl/debug/deps/hellopp-e18a46c88e8651c0.86k6xqe3mcfnldm.rcgu.o /target/aarch64-unknown-linux-musl/debug/deps/hellopp-e18a46c88e8651c0.37wbsb42mhp6kphi.rcgu.o -Wl,--as-needed -L /target/aarch64-unknown-linux-musl/debug/deps -L /target/debug/deps -L /target/aarch64-unknown-linux-musl/debug/build/hellopp-be12ba6d38a66dd4/out -L /home/ahusz/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/aarch64-unknown-linux-musl/lib -Wl,-Bstatic -lhellopp -Wl,-Bdynamic -lstdc++ -Wl,--start-group -Wl,-Bstatic /target/aarch64-unknown-linux-musl/debug/deps/libstd-2b9a1a9c35b1230a.rlib /target/aarch64-unknown-linux-musl/debug/deps/libpanic_unwind-d70e14d6e59177bc.rlib /target/aarch64-unknown-linux-musl/debug/deps/librustc_demangle-f3d5b949b7b1a5de.rlib /target/aarch64-unknown-linux-musl/debug/deps/libstd_detect-59b5d3ce85adba29.rlib /target/aarch64-unknown-linux-musl/debug/deps/libhashbrown-2f24b7025c0e4078.rlib /target/aarch64-unknown-linux-musl/debug/deps/librustc_std_workspace_alloc-f93333caf4316797.rlib /target/aarch64-unknown-linux-musl/debug/deps/libunwind-755d10c7440dc2d0.rlib -lunwind /target/aarch64-unknown-linux-musl/debug/deps/libcfg_if-22929b06043a7aec.rlib /target/aarch64-unknown-linux-musl/debug/deps/liblibc-3e7ed81f524f85a0.rlib -lc /target/aarch64-unknown-linux-musl/debug/deps/liballoc-64350ab48d7b62c5.rlib /target/aarch64-unknown-linux-musl/debug/deps/librustc_std_workspace_core-ab8f7e806a10a573.rlib /target/aarch64-unknown-linux-musl/debug/deps/libcore-b2d649ba95a0a0a1.rlib -Wl,--end-group /target/aarch64-unknown-linux-musl/debug/deps/libcompiler_builtins-d8af7abe78822f7d.rlib -Wl,-Bdynamic -Wl,--eh-frame-hdr -Wl,-znoexecstack -nostartfiles -L /home/ahusz/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/aarch64-unknown-linux-musl/lib -L /home/ahusz/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/aarch64-unknown-linux-musl/lib/self-contained -o /target/aarch64-unknown-linux-musl/debug/deps/hellopp-e18a46c88e8651c0 -Wl,--gc-sections -static -no-pie -Wl,-zrelro,-znow -nodefaultlibs /home/ahusz/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/aarch64-unknown-linux-musl/lib/self-contained/crtend.o /home/ahusz/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/aarch64-unknown-linux-musl/lib/self-contained/crtn.o
          /usr/local/bin/../lib/gcc/aarch64-linux-musl/9.2.0/../../../../aarch64-linux-musl/bin/ld: /home/ahusz/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/aarch64-unknown-linux-musl/lib/self-contained/libc.a(fmodl.lo): undefined reference to symbol '__letf2@@GCC_3.0'
          /usr/local/bin/../lib/gcc/aarch64-linux-musl/9.2.0/../../../../aarch64-linux-musl/bin/ld: /usr/local/bin/../aarch64-linux-musl/lib/libgcc_s.so.1: error adding symbols: DSO missing from command line
          collect2: error: ld returned 1 exit status

  = help: 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 `hellopp` due to previous error

Or, missing the __letf2 routine.

@Alexhuszagh
Copy link
Contributor

Alexhuszagh commented Jul 29, 2022

This seems to be related to, but not exactly the same as, rust-lang/rust#46651, which was a previous issue for our aarch64-unknown-linux-musl. We've had to link to -lgcc due to missing symbols from Rust before for multiple targets before, so this is likely an upstream issue (but with a simple fix):

This is probably a generic musl issue, and upstream in Rust itself. A simple temporary fix though is to always link to libgcc. I'll file issues upstream.

@Alexhuszagh
Copy link
Contributor

The patch in #986 seems to fix this issue: if you want to test the above patch to see if it works, let me know. I've tried using your fork of cargo-bininstalland everything works on my end (and the resulting binary is statically linked, as expected).

@Alexhuszagh
Copy link
Contributor

Alexhuszagh commented Jul 29, 2022

Missing __ctzdi2 is very unusual, since it should be provided always by the Rust compiler builtins for all targets (and was present in v0.1.73 (which is what I was using). It might have been missing from an older target.

https://github.com/rust-lang/compiler-builtins/blob/5e2d31689d6446c5c767f6a75c24aed81786e949/build.rs#L202

Some of the other missing intrinsics seem to be due to consider_float_intrinsics not being set (which would only occur if either the +nofp or +nosimd target feature was set).

https://github.com/NobodyXu/cargo-binstall/runs/7576062950?check_suite_focus=true#step:11:250

We can clearly see from the source that these symbols should be defined:

https://github.com/rust-lang/compiler-builtins/blob/5e2d31689d6446c5c767f6a75c24aed81786e949/build.rs#L414-L443

@NobodyXu
Copy link
Author

The patch in #986 seems to fix this issue: if you want to test the above patch to see if it works, let me know

Thanks, I will have a try later.

Some of the other missing intrinsics seem to be due to consider_float_intrinsics not being set (which would only occur if either the +nofp or +nosimd target feature was set)

I only disable the panic unwind/backtract/fmt-message stuff, so I am pretty sure I didn't disable that.

@Alexhuszagh
Copy link
Contributor

Alexhuszagh commented Jul 30, 2022

Actually, this might be an issue due to not having the c feature enabled and the image not having the LLVM builtin sources. In short, it's actually impossible to build aarch64-unknown-linux-musl std until those intrinsics are implemented natively in Rust itself. The only good solution is to link to -lgcc itself (see #986).

@Alexhuszagh
Copy link
Contributor

This has now been fully documented on the wiki. Let me know if anything is unclear so we can improve the documentation.

@NobodyXu
Copy link
Author

This has now been fully documented on the wiki. Let me know if anything is unclear so we can improve the documentation.

Thanks, this fixed the problem for me!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-musl Area: musl libc targets upstream
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants