Skip to content

glibc: always compile with a gcc stdenv#119786

Merged
Ericson2314 merged 1 commit intoNixOS:stagingfrom
sternenseemann:glibc-gcc
Apr 28, 2021
Merged

glibc: always compile with a gcc stdenv#119786
Ericson2314 merged 1 commit intoNixOS:stagingfrom
sternenseemann:glibc-gcc

Conversation

@sternenseemann
Copy link
Copy Markdown
Member

@sternenseemann sternenseemann commented Apr 18, 2021

Our glibc doesn't compile with clang and useLLVM doesn't make the stdenv
implicitly switch to musl (and arguably shouldn't do that). To make LLVM
cross compilation without patching glibc to compile with clang (which is
probably a lot of work), always compile glibc with gcc. This should
unbreak a lot of cross compilation tests, I have tested:

  • tests.cross.llvm.gnu64
  • tests.cross.llvm.aarch64-multiplatform

Basing against staging because this change only really makes sense if
useLLVM works with llvmPackages_7 which is only the case in staging at
the moment.

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.

Our glibc doesn't compile with clang and useLLVM doesn't make the stdenv
implicitly switch to musl (and arguably shouldn't do that). To make LLVM
cross compilation without patching glibc to compile with clang (which is
probably a lot of work), always compile glibc with gcc. This should
unbreak a lot of cross compilation tests, I have tested:

* tests.cross.llvm.gnu64
* tests.cross.llvm.aarch64-multiplatform

Basing against staging because this change only really makes sense if
useLLVM works with llvmPackages_7 which is only the case in staging at
the moment.
@ofborg ofborg bot added 10.rebuild-darwin: 11-100 This PR causes between 11 and 100 packages to rebuild on Darwin. 10.rebuild-linux: 0 This PR does not cause any packages to rebuild on Linux. labels Apr 18, 2021

crossLibcStdenv =
if stdenv.hostPlatform.useLLVM or false
then overrideCC stdenv buildPackages.llvmPackages_8.lldClangNoLibc
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

BTW this should use the default LLVM version now that it's updated to be newer for cross.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's still clang 7 for useLLVM right? I think we'll have to check up on this topic anyways. Unfortunately there's still some issue with llvmPackages_7.lldClang with C++ and libunwind (i. e. ncurses' C++ library doesn't compile with useLLVM atm).

This is probably something unrelated to this though, I'd expect we can compile musl with clang 7 just fine. I'll try to rememeber to check that later.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's a later version when cross compilation is involved. We can tweak the condition if something isn't working.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At least stdenv itself still uses clang 7.

@Ericson2314 Ericson2314 merged commit 7d4a695 into NixOS:staging Apr 28, 2021
@sternenseemann sternenseemann deleted the glibc-gcc branch April 28, 2021 11:19
sternenseemann added a commit to sternenseemann/nixpkgs that referenced this pull request May 10, 2021
Provide a version of nixpkgs which is built using the LLVM toolchain.
This is achieved by reusing the useLLVM attribute usable in the cross
toolchain bootstrapping which is a) perfectly acceptable and b) the only
way to bootstrap a LLVM stdenv across platforms without unreasonable
amounts of work.

This is mostly working now since we fixed some issues with
llvmPackages_7.lldClang in NixOS#119717 and compile glibc with gcc at all
times as of NixOS#119786 (since clang can't compile our glibc at the moment).
There are seemingly some issues left to be ironed out, for example the
C++ library of ncurses fails to build with a linking issue. I have
attempted to alleviate that problem with NixOS#120790, but to no avail so
far.

Nonetheless, having a working pkgsLLVM.hello is a good start.

A currently present issue is that there is no way to change the libc
since there is some issue with lldClang actually picking up on the set
libc. This will need investigation and fixing.
@sternenseemann sternenseemann restored the glibc-gcc branch July 24, 2021 13:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

10.rebuild-darwin: 11-100 This PR causes between 11 and 100 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.

2 participants