Skip to content

nix: fix build on musl platforms#112096

Merged
SuperSandro2000 merged 2 commits intoNixOS:masterfrom
r-burns:musl-nix
Feb 23, 2021
Merged

nix: fix build on musl platforms#112096
SuperSandro2000 merged 2 commits intoNixOS:masterfrom
r-burns:musl-nix

Conversation

@r-burns
Copy link
Contributor

@r-burns r-burns commented Feb 6, 2021

Nix is currently failing to build on musl because as of recently aws-c-common doesn't support musl.
awslabs/aws-c-common#754
Until aws-c-common builds on musl, nix should default to no AWS support on musl platforms.

Fixes e.g. pkgsMusl.nix

Motivation for this change
Things done
  • Tested using sandboxing (nix.useSandbox on NixOS, or option sandbox in nix.conf on non-NixOS linux)
  • Built on platform(s)
    • NixOS
    • macOS
    • other Linux distributions
  • Tested via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests)
  • Tested compilation of all pkgs that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Determined the impact on package closure size (by running nix path-info -S before and after)
  • Ensured that relevant documentation is up to date
  • Fits CONTRIBUTING.md.

A recent update to aws-c-common uses the nonportable glibc-specific
pthread_attr_setaffinity_np function, which precludes compilation on
musl.
This is just a temporary measure until musl
compatibility is restored to aws-c-common.
@ofborg ofborg bot added 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin. 10.rebuild-linux: 0 This PR does not cause any packages to rebuild on Linux. labels Feb 6, 2021
@nixos-discourse
Copy link

This pull request has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/prs-ready-for-review/3032/471

@SuperSandro2000
Copy link
Member

Fails to build for me

checking target system type... x86_64-unknown-linux-musl
checking LIBRARY_PATH variable... ok
checking GCC_EXEC_PREFIX variable... ok
checking whether to place generated files in the source directory... no
checking whether a default linker was specified... yes (/nix/store/i65hb5xxr0pzzq0m3fl7s5hpwgbslgqh-x86_64-unknown-linux-musl-binutils-wrapper-2.35.1/bin/x86_64-unknown-linux-musl-ld)
configure: error: cannot execute: /nix/store/i65hb5xxr0pzzq0m3fl7s5hpwgbslgqh-x86_64-unknown-linux-musl-binutils-wrapper-2.35.1/bin/x86_64-unknown-linux-musl-as: check --with-as or env. var. DEFAULT_ASSEMBLER
make[1]: *** [Makefile:4315: configure-gcc] Error 1
make[1]: Leaving directory '/build/build'
make: *** [Makefile:940: all] Error 2
builder for '/nix/store/bz9m5j0sfch9pgyqcrwxa2xbm3v5gmih-x86_64-unknown-linux-musl-stage-static-gcc-10.2.0.drv' failed with exit code 2
cannot build derivation '/nix/store/ix7p8xhfgnsig6g67jcqvw4j015h1cjp-x86_64-unknown-linux-musl-stage-static-gcc-wrapper-10.2.0.drv': 1 dependencies couldn't be built
cannot build derivation '/nix/store/nkpawp4vxsq0isz9axv8i7kfqcygyndb-stdenv-linux.drv': 1 dependencies couldn't be built
cannot build derivation '/nix/store/4fvjxr5z9p4gy9av7vh6x1z9dilawb02-musl-1.2.1-x86_64-unknown-linux-musl.drv': 1 dependencies couldn't be built
cannot build derivation '/nix/store/cfhnfhwn3fc29cmlh2s0z9kvm8w9apiy-x86_64-unknown-linux-musl-stage-final-gcc-wrapper-10.2.0.drv': 1 dependencies couldn't be built
cannot build derivation '/nix/store/r2gsfrfk11wbp1vly8n6v9933ziqsj0k-stdenv-linux.drv': 1 dependencies couldn't be built
cannot build derivation '/nix/store/pfjrqff642cmb8gf3xalnw9s6l15snsc-busybox-1.32.1-x86_64-unknown-linux-musl.drv': 1 dependencies couldn't be built
cannot build derivation '/nix/store/xva77kx4znpz3brvrmnjqzjnxkxrlvq2-nix-2.3.10.drv': 1 dependencies couldn't be built
error: build of '/nix/store/xva77kx4znpz3brvrmnjqzjnxkxrlvq2-nix-2.3.10.drv' failed

@r-burns
Copy link
Contributor Author

r-burns commented Feb 22, 2021

Uh oh, that's a gcc build failure. Looks like the x86_64-musl cross toolchain has broken since I opened this. I'll look into that.

Still, this should immediately fix some other platforms which currently can't build nix, and it will be needed on x86_64-musl as well once the toolchain is working again.

Give one of these a try (they should be easy on the CPU as these toolchains are in the cross-trunk cache):
@ofborg build pkgsCross.musl-power.nix pkgsCross.aarch64-multiplatform-musl.nix

@SuperSandro2000 SuperSandro2000 merged commit 40bc4f7 into NixOS:master Feb 23, 2021
@r-burns r-burns deleted the musl-nix branch February 23, 2021 06:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin. 10.rebuild-linux: 0 This PR does not cause any packages to rebuild on Linux.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants