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

musl-based toolchains are missing libgcc runtime dependency #161

Closed
aaronmondal opened this issue Mar 11, 2024 · 3 comments · Fixed by #178
Closed

musl-based toolchains are missing libgcc runtime dependency #161

aaronmondal opened this issue Mar 11, 2024 · 3 comments · Fixed by #178
Labels
bug Something isn't working

Comments

@aaronmondal
Copy link

The pkgs.pkgsMusl.rust-bin.xxx toolchains mostly work fine, but (at least) rustdoc and cargo clippy instacrash with a missing libgcc_s.so.1. It seems like the musl stdenvs don't ship the libgcc package which supplies libgcc_s.so.1. This makes sense, but apparently the musl rust linux binaries were built against a dynamically linked libgcc_s.

The changes from #121 don't seem to work in this case.

This also affects pkgsCross.musl64.

On x86_64-unknown-linux-gnu, something that kinda-sorta works around the issue is adding LD_LIBRARY_PATH=${pkgs.pkgsMusl.libgcc} to a devShell. But that breaks all other non-musl packages as they expect a libgcc_s built against glibc.

Is there some way to explicitly add the libgcc runtime dependency? If possible I'd like to avoid pkgsStatic as it looks like that's not a cached package set and would incur massive upfront compilation of a static GCC toolchain.

Noticed in TraceMachina/nativelink#749

cc @RaitoBezarius

@wwilson
Copy link

wwilson commented Jun 4, 2024

Are you sure that this has fully solved the problem? I am still getting this on the latest revision of this repo:

nix-repl> :b pkgs.pkgsStatic.rust-bin.stable."1.77.2".minimal
error: builder for '/nix/store/6rzir020q8228jcp86ihqgwm1lp5w9cq-cargo-1.77.2-x86_64-unknown-linux-musl.drv' failed with exit code 1;
last 10 log lines:
> setting interpreter of /nix/store/nzlzxqh61w1hqp5ljj6gfr8pw8mbmz8k-cargo-1.77.2-x86_64-unknown-linux-musl/bin/cargo
> searching for dependencies of /nix/store/nzlzxqh61w1hqp5ljj6gfr8pw8mbmz8k-cargo-1.77.2-x86_64-unknown-linux-musl/bin/cargo
> libgcc_s.so.1 -> not found!
> auto-patchelf: 1 dependencies could not be satisfied
> error: auto-patchelf could not satisfy dependency libgcc_s.so.1 wanted by /nix/store/nzlzxqh61w1hqp5ljj6gfr8pw8mbmz8k-cargo-1.77.2-x86_64-unknown-linux-musl/bin/cargo
> auto-patchelf failed to find all the required dependencies.
> Add the missing dependencies to --libs or use --ignore-missing="foo.so.1 bar.so etc.so".
> /nix/store/kl8vsdrmbdf55ggn8hs0wi8agkfmvmwr-stdenv-linux/setup: line 74: pop_var_context: head of shell_variables not a function context
> /nix/store/kl8vsdrmbdf55ggn8hs0wi8agkfmvmwr-stdenv-linux/setup: line 1446: pop_var_context: head of shell_variables not a function context
> /nix/store/kl8vsdrmbdf55ggn8hs0wi8agkfmvmwr-stdenv-linux/setup: line 1549: pop_var_context: head of shell_variables not a function context
For full logs, run 'nix log /nix/store/6rzir020q8228jcp86ihqgwm1lp5w9cq-cargo-1.77.2-x86_64-unknown-linux-musl.drv'.
error: 1 dependencies of derivation '/nix/store/c30pm608jcdjyhcvml35zpnx39i2c5lw-rust-minimal-1.77.2.drv' failed to build

Incidentally, offering an "ultra-minimal" attribute that has rustc and rust-std but no cargo could be another way around for people who want to build with a static rust toolchain.

@oxalica
Copy link
Owner

oxalica commented Jun 4, 2024

:b pkgs.pkgsStatic.rust-bin.stable."1.77.2".minimal

I assume you want to make a toolchain that produces static binary, not a toolchain itself being static (which is impossible, because it's downloaded from upstream and it's shipped as dynamic binaries). So what you need is pkgs.pkgsStatic.buildPackages.rust-bin.stable."1.77.2".minimal. I can confirm it does build and run well. It can also compile code into static binaries via rustc --target=x86_64-unknown-linux-musl.

@wwilson
Copy link

wwilson commented Jun 4, 2024

Oh, you're right! Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants