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

Make cross stdenv with llvmPackages_7 and useLLVM work again #119717

Merged
merged 4 commits into from Apr 17, 2021

Conversation

sternenseemann
Copy link
Member

@sternenseemann sternenseemann commented Apr 17, 2021

Motivation for this change

This makes cross compilation work again when stdenv.hostPlatform.useLLVM is true and llvmPackages points to llvmPackages_7. There were the following problems:

  • libcxxabi wouldn't evaluate for useLLVM == true since in that case libunwind would be passed as an argument. This PR makes libunwind an optional dependency of libcxxabi again and packages libunwind of llvm 7 as well.
  • lldClang passed --unwindlib to clang, but this option was introduced for clang 9. This PR backports this change for clang 7 similarly to how it was done for clang 8.

tests.cross.llvm.hello.musl64 now works again!

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.

This reverts commit 76b54c7 and brings
llvmPackages_7.libcxxabi in line with what the other llvmPackages
sets are doing again (with llvmPackages_7 being the sole outlier).

This also fixes an evaluation error of llvmPackages_7.libcxxabi if
stdenv.hostPlatform.useLLVM is true as the nonexistant libunwind
argument would be overridden.
This reflects what the other llvmPackages sets are doing.
This flag was introduced for clang 9, but we use it in the `lldClang`
wrapper for `llvmPackages` 7, 8 and 9. For this purpose the patch was
backported for `llvmPackages_8.clang`, but not for `llvmPackages_7.clang`
which has been done in this commit.

`lldClang` is mostly used when cross compiling and
`stdenv.hostPlatform.useLLVM` is true. Most likely this problem wasn't
noticed since `useLLVM` with `llvmPackages_7` was broken for other
reasons as well and all cross targets (like `wasi32`) which have
`useLLVM` at the moment use `llvmPackages_8`.

With this change tests.cross.llvm.hello.{musl64, …} works again.
@sternenseemann
Copy link
Member Author

@ofborg build llvmPackages_7.libcxxabi

@sternenseemann
Copy link
Member Author

libcxxabi on aarch64 failure is not new: https://hydra.nixos.org/job/nixpkgs/trunk/llvmPackages_7.libcxxabi.aarch64-linux

@Ericson2314 Ericson2314 merged commit d4d49c1 into NixOS:staging Apr 17, 2021
@Ericson2314
Copy link
Member

Darwin bootstrap broke, sorry -- I misunderstood what had been tested. But I am fixing this.

@sternenseemann sternenseemann deleted the libunwind-7.1.0 branch April 18, 2021 07:41
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 libunwind-7.1.0 branch July 24, 2021 13:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants