-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
-crt-static on musl links with libgcc_s #82521
Comments
Dynamically linking
|
I've also run into this issue as well when compiling for an environment which uses musllibc as the libc implementation. Unfortunately, the environment is not under my direct control so installing libgcc is not possible meaning there's no workaround as far as I can tell. |
Why can't use just do |
@Logarithmus In my case I want to produce a binary that will run in many different docker base images. Having a binary with no external dependencies makes that very convenient. Installing |
is there a way dont't to link libgcc_s when building dynamic lib on musl -crt-static? |
@dupu222 Maybe these alpine issues are interesting for you. The gcc_s issue should be fixed in alpine edge built rust toolchain (package version 1.62.1 or laster): |
Musl Patch ========== riscv64gc-unknown-linux-musl gets promoted to tier 2 and `crt_static_default` is updated to false in rust-lang/rust#122049, which triggers rust-lang/rust#82521 (comment) when building stage2 library artifacts (riscv64gc-unknown-linux-gnu -> riscv64gc-unknown-linux-musl). I patched it to re-enable `crt_static_default` for `riscv64gc-unknown-linux-musl` to fix the build and align with the behavior on x86 Arch Linux, where `rust-musl` defaults to statically link musl. Wasm compiler_builtins bug ========================== Wasm compiler_builtins rlib from built `rust-wasm` package includes objects for host architecture(riscv64 in our case, and x86_64 for x86 Arch Linux). This is not reproducible for toolchains installed via rustup so I have reported it to Arch Linux: https://gitlab.archlinux.org/archlinux/packaging/packages/rust/-/issues/3 Complications when building 1.82.0 ================================== rust-lang/rust#125016 landed in 1.82.0, which breaks building rust 1.82.0 using our packaged rust 1.81.0. Compiling the new compiler_builtins component requires a rustc compiler that includes rust-lang/rust@99e6a28 but unfortunately 1.81.0 does not, leading to the following ICE: https://archriscv.felixc.at/.status/log.htm?url=logs/rust/rust-1:1.82.0-1.log internal compiler error: compiler/rustc_codegen_llvm/src/abi.rs:126:22: unsupported float: Reg { kind: Float, size: Size(2 bytes) } This is mitigated upstream by bumping stage0 to 1.82: rust-lang/rust#129268 (comment) So we need to first build 1.82.0 rustc once without the f16/f128 handling part in compiler_builtins, to get a compiler that is capable of handling f16/f128. And then we can use this compiler to compile compiler_builtins with f16/f128 handling. It's not easy to do so in one patch. The most easy way is to build and package rust 1.82.0 twice. This PR covers the first part and disable-f16-f128.diff will be removed in the second part.
Musl Patch ========== riscv64gc-unknown-linux-musl gets promoted to tier 2 and `crt_static_default` is updated to false in rust-lang/rust#122049, which triggers rust-lang/rust#82521 (comment) when building stage2 library artifacts (riscv64gc-unknown-linux-gnu -> riscv64gc-unknown-linux-musl). I patched it to re-enable `crt_static_default` for `riscv64gc-unknown-linux-musl` to fix the build and align with the behavior on x86 Arch Linux, where `rust-musl` defaults to statically link musl. Wasm compiler_builtins bug ========================== Wasm compiler_builtins rlib from built `rust-wasm` package includes objects for host architecture(riscv64 in our case, and x86_64 for x86 Arch Linux). This is not reproducible for toolchains installed via rustup so I have reported it to Arch Linux: https://gitlab.archlinux.org/archlinux/packaging/packages/rust/-/issues/3 Complications when building 1.82.0 ================================== rust-lang/rust#125016 landed in 1.82.0, which breaks building rust 1.82.0 using our packaged rust 1.81.0. Compiling the new compiler_builtins component requires a rustc compiler that includes rust-lang/rust@99e6a28 but unfortunately 1.81.0 does not, leading to the following ICE: https://archriscv.felixc.at/.status/log.htm?url=logs/rust/rust-1:1.82.0-1.log internal compiler error: compiler/rustc_codegen_llvm/src/abi.rs:126:22: unsupported float: Reg { kind: Float, size: Size(2 bytes) } This is mitigated upstream by bumping stage0 to 1.82: rust-lang/rust#129268 (comment) So we need to first build 1.82.0 rustc once without the f16/f128 handling part in compiler_builtins, to get a compiler that is capable of handling f16/f128. And then we can use this compiler to compile compiler_builtins with f16/f128 handling. It's not easy to do so in one patch. The most easy way is to build and package rust 1.82.0 twice. This PR covers the first part and disable-f16-f128.diff will be removed in the second part.
Musl Patch ========== riscv64gc-unknown-linux-musl gets promoted to tier 2 and `crt_static_default` is updated to false in rust-lang/rust#122049, which triggers rust-lang/rust#82521 (comment) when building stage2 library artifacts (riscv64gc-unknown-linux-gnu -> riscv64gc-unknown-linux-musl). I patched it to re-enable `crt_static_default` for `riscv64gc-unknown-linux-musl` to fix the build and align with the behavior on x86 Arch Linux, where `rust-musl` defaults to statically link musl. Wasm compiler_builtins bug ========================== Wasm compiler_builtins rlib from built `rust-wasm` package includes objects for host architecture(riscv64 in our case, and x86_64 for x86 Arch Linux). This is not reproducible for toolchains installed via rustup so I have reported it to Arch Linux: https://gitlab.archlinux.org/archlinux/packaging/packages/rust/-/issues/3 Complications when building 1.82.0 ================================== rust-lang/rust#125016 landed in 1.82.0, which breaks building rust 1.82.0 using our packaged rust 1.81.0. Compiling the new compiler_builtins component requires a rustc compiler that includes rust-lang/rust@99e6a28 but unfortunately 1.81.0 does not, leading to the following ICE: https://archriscv.felixc.at/.status/log.htm?url=logs/rust/rust-1:1.82.0-1.log internal compiler error: compiler/rustc_codegen_llvm/src/abi.rs:126:22: unsupported float: Reg { kind: Float, size: Size(2 bytes) } This is mitigated upstream by bumping stage0 to 1.82: rust-lang/rust#129268 (comment) So we need to first build 1.82.0 rustc once without the f16/f128 handling part in compiler_builtins, to get a compiler that is capable of handling f16/f128. And then we can use this compiler to compile compiler_builtins with f16/f128 handling. It's not easy to do so in one patch. The most easy way is to build and package rust 1.82.0 twice. This PR covers the first part and disable-f16-f128.diff will be removed in the second part.
Hi, I am building dynamic libraries that I call from scripting languages (elixir nif, nodejs native addon, etc) on Alpine Linux. I have been successful using the
x86_64-unknown-linux-musl
target with-C target-feature=-crt-static
to enable buildingcdylib
s. However, I find that anycdylib
produced this way links dynamically not only tomusl
but also tolibgcc_s
:Unfortunately, the Alpine Linux docker image does not include the
libgcc
package by default, and the packages for most scripting languages do not depend on it, so users of my library will be required to explicitly install it, which is an inconvenience.Below is the line in the
unwind
crate that dynamically links tolibgcc_s
onmusl
targets whencrt-static
is disabled:rust/library/unwind/src/lib.rs
Line 41 in b36f770
Is there a path to compiling
cdylib
s formusl
without dynamically linking tolibgcc_s
? Perhaps while unwinding across FFI boundaries remains undefined behavior,-crt-static
onmusl
could statically link the unwind functionality like it does with+crt-static
?Related issues:
#29527
#55120
rustc --version --verbose
:The text was updated successfully, but these errors were encountered: