Trying to build pkgsStatic.gcc on my local NixOS system and am getting the following error at the end of the build:
mv: cannot stat '/nix/store/0xkrd6yzxbmylf4fzwkw0jczb9pvr0ra-gcc-static-x86_64-unknown-linux-musl-12.2.0-lib/lib/libgcc_s.so': No such file or directory
Full logs here. For posterity sake, tried in a fresh Nixified container with the same result. Any ideas on what’s going on? This is running against a fairly recent (as in last couple of days) version of nixpkgs-unstable.
Are you sure you want pkgsStatic.gcc, i.e. a statically-linked gcc, rather than a gcc that produces static binaries? If you actually want the latter, you’re looking for pkgsStatic.buildPackages.gcc (or pkgsStatic.stdenv.cc).
There are reasons you might, for example if you wanted to be able to easily use the GCC you produced on another system, but it’s a much less common thing to want to do that produce static binaries with GCC.
Are you sure you want pkgsStatic.gcc , i.e. a statically-linked gcc, rather than a gcc that produces static binaries? If you actually want the latter, you’re looking for pkgsStatic.buildPackages.gcc (or pkgsStatic.stdenv.cc ).
Possibly. This originally came from my efforts to get a static version of cargo/rustc:
When I attempt to build the toolchain, it ends up building gcc-static-x86_64-unknown-linux-musl-12.2.0, which fails with the error I originally gave. It’s possible I’m not configuring this correctly. This is using rust-overlay.
Yes, it would be the latter: building statically linked rust binaries with cargo/rustc. Thanks for the additional information on the current state of this. I pulled the rust-overlay solution from this issue. It’s possible it regressed since then. Unfortunately, troubleshooting the gcc build is a bit out of my league/capacity at the moment
That sounds more like the former of what I asked about:
i.e., if I’m understanding you correctly, you don’t care about what kind of binary “cargo” is, you want to build some Rust application statically.
That’s very well supported. For example, pkgsStatic.ripgrep in Nixpkgs is a statically linked version of ripgrep, a Rust program. To build your own application statically, you can use pkgsStatic.callPackage, and with cargo/rustc from Nixpkgs it should just work.