Skip to content

musl build broken? #14753

@makemeunsee

Description

@makemeunsee

Summary

Following the instructions from the documentation to build a musl-libc binary, linking fails, symbols from the math library are not found:

$ HELIX_DISABLE_AUTO_GRAMMAR_BUILD=true RUSTFLAGS="-C target-feature=-crt-static" cargo build --profile opt --config 'build.rustflags="-C target-cpu=native"' --target x86_64-unknown-linux-musl
   Compiling helix-term v25.7.1 (/home/xyz/gits/helix/helix-term)
error: linking with `cc` failed: exit status: 1
  |
  = note: LC_ALL="C" PATH="/home/xyz/.rustup/toolchains/1.82.0-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/bin:/home/xyz/.rustup/toolchains/1.82.0-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/bin:/home/xyz/.rustup/toolchains/1.82.0-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/bin:/home/xyz/.cabal/bin:/home/xyz/.ghcup/bin:/home/xyz/.cargo/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/lib/jvm/default/bin:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl:/home/xyz/bin/:/home/xyz/.local/bin" VSLANG="1033" "cc" "-m64" "/tmp/rustczXvfdg/symbols.o" "/home/xyz/dev/helix/target/x86_64-unknown-linux-musl/opt/deps/hx-bbb3a5e797e17ac2.hx.6ff96c93f4a86c93-cgu.0.rcgu.o" "-Wl,--as-needed" "-Wl,-Bstatic" "/tmp/rustczXvfdg/libtree_house_bindings-6b0e44051011440b.rlib" "/home/xyz/.rustup/toolchains/1.82.0-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-musl/lib/libcompiler_builtins-dbe01828b841a238.rlib" "-Wl,-Bdynamic" "-ldl" "-lgcc_s" "-lc" "-Wl,--eh-frame-hdr" "-Wl,-z,noexecstack" "-L" "/home/xyz/dev/helix/target/x86_64-unknown-linux-musl/opt/build/tree-house-bindings-32d2beb644e02417/out" "-L" "/home/xyz/.rustup/toolchains/1.82.0-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-musl/lib" "-o" "/home/xyz/dev/helix/target/x86_64-unknown-linux-musl/opt/deps/hx-bbb3a5e797e17ac2" "-Wl,--gc-sections" "-pie" "-Wl,-z,relro,-z,now" "-Wl,-O1" "-Wl,--strip-all" "-nodefaultlibs"
  = note: /usr/bin/ld: /home/xyz/dev/helix/target/x86_64-unknown-linux-musl/opt/deps/hx-bbb3a5e797e17ac2.hx.6ff96c93f4a86c93-cgu.0.rcgu.o: in function `<core::marker::PhantomData<T> as serde::de::DeserializeSeed>::deserialize':
          hx.6ff96c93f4a86c93-cgu.0:(.text._ZN81_$LT$core..marker..PhantomData$LT$T$GT$$u20$as$u20$serde..de..DeserializeSeed$GT$11deserialize17h9c08d251004dbc73E+0x3c8): undefined reference to `trunc'
          /usr/bin/ld: /home/xyz/dev/helix/target/x86_64-unknown-linux-musl/opt/deps/hx-bbb3a5e797e17ac2.hx.6ff96c93f4a86c93-cgu.0.rcgu.o: in function `std::sync::once::Once::call_once::{{closure}}':
          hx.6ff96c93f4a86c93-cgu.0:(.text._ZN3std4sync4once4Once9call_once28_$u7b$$u7b$closure$u7d$$u7d$17hf8babac4bb197d6cE+0x1219): undefined reference to `ceil'
          /usr/bin/ld: /home/xyz/dev/helix/target/x86_64-unknown-linux-musl/opt/deps/hx-bbb3a5e797e17ac2.hx.6ff96c93f4a86c93-cgu.0.rcgu.o: in function `tokio::runtime::scheduler::multi_thread::worker::run':
          hx.6ff96c93f4a86c93-cgu.0:(.text._ZN5tokio7runtime9scheduler12multi_thread6worker3run17h9690933dd40f4b70E+0xa32): undefined reference to `pow'
          /usr/bin/ld: hx.6ff96c93f4a86c93-cgu.0:(.text._ZN5tokio7runtime9scheduler12multi_thread6worker3run17h9690933dd40f4b70E+0x1149): undefined reference to `pow'
          /usr/bin/ld: /home/xyz/dev/helix/target/x86_64-unknown-linux-musl/opt/deps/hx-bbb3a5e797e17ac2.hx.6ff96c93f4a86c93-cgu.0.rcgu.o: in function `toml_edit::encode::encode_value':
          hx.6ff96c93f4a86c93-cgu.0:(.text._ZN9toml_edit6encode12encode_value17h1ab86b5005a77920E+0x1c2f): undefined reference to `fmod'
          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#rustc-link-lib)

Adding this line to helix-term/build.rs fixes the build:

    println!("cargo:rustc-link-lib=m");

but the binary produced still requires GLIBC, while I'd expect a musl bin to run 'anywhere'. Runtime error:

./hx
./hx: /lib64/libm.so.6: version `GLIBC_2.38' not found (required by ./hx)
./hx: /lib64/libc.so.6: version `GLIBC_2.39' not found (required by ./hx)

Reproduction Steps

described in the summary

Helix log

irrelevant

Platform

Linux

Terminal Emulator

alacritty

Installation Method

source

Helix Version

25.07.01

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions