rustc: fix building with llvm#320432
Conversation
e05dbb6 to
8f443be
Compare
|
I still get this on x86_64-linux: |
|
@tomberek Yes, this seems to still occur on aarch64-linux as well. Not entirely sure why we are still facing this issue. Looking at the documentation comments in |
8f443be to
b966a22
Compare
|
@ofborg build pkgsLLVM.rustc |
|
On x86_64-linux I'm getting: |
|
@jopejoe1 Thank you for testing, I marked it as a draft and will continue figuring out why rustc still doesn't compile tonight. |
perhaps we should be compiling the pkgsLLVM clang so that it translates the alternatively, adding the flag -stdlib=libc++ should also work |
e73636c to
1108be3
Compare
8394848 to
8b96d40
Compare
8b96d40 to
0c3cbd2
Compare
There was a problem hiding this comment.
| ++ optional (stdenv.isLinux && !withBundledLLVM && !stdenv.targetPlatform.isFreeBSD && useLLVM) "--push-state --as-needed -L${llvmPackages.libcxx}/lib -lc++ -lc++abi -lLLVM-${lib.versions.major llvmPackages.llvm.version} --pop-state" | |
| ++ optional (stdenv.isLinux && !withBundledLLVM && !stdenv.targetPlatform.isFreeBSD && useLLVM) | |
| "--push-state --as-needed -L${llvmPackages.libcxx}/lib -lc++ -lc++abi -lLLVM-${lib.versions.major llvmPackages.llvm.version} --pop-state" |
There was a problem hiding this comment.
| optional (stdenv.isLinux && !withBundledLLVM && !stdenv.targetPlatform.isFreeBSD && !useLLVM) "--push-state --as-needed -lstdc++ --pop-state" | |
| optional (stdenv.isLinux && !withBundledLLVM && !stdenv.targetPlatform.isFreeBSD && !useLLVM) | |
| "--push-state --as-needed -lstdc++ --pop-state" |
0c3cbd2 to
f9d3bb5
Compare
f9d3bb5 to
36219b4
Compare
|
This pull request has been mentioned on NixOS Discourse. There might be relevant details there: |
|
For aarch64-darwin: |
36219b4 to
2c03b10
Compare
|
@tomberek I've pushed a change which I believe might fix it, if it doesn't then I'll do some more diagnosing tonight. |
|
Builds on x86_64-linux. |
|
Bisect says 6a163e2 |
|
@trofi Will take a look at it tonight. Tbf, it probably wouldn't even have built anyway so it's not like we totally broke everything. |
|
My concern is the eval only (I usually scan for things in treewide evals). It used to eval successfully and does not anymore. |
|
Heh yeah, I'll take a look tonight after work to try fixing this. Unless someone else wants to touch this. |
The PR which fixed `useLLVM` native rustc builds (NixOS#320432) also broke cross builds. The C compiler it used to produce `llvmShared` and `llvmPackages`, `llvmPackages.clangUseLLVM`, was built to run on the host and create binaries for the target (`pkgsHostTarget`). Instead, the compiler should be built to run on the build machine and produce binaries for the host machine (`pkgsBuildHost`). Replace the overridden compilers with ones from `pkgsBuildHost` Co-Authored-By: Artemis Tosini <[email protected]>
| let | ||
| inherit (lib) optionals optional optionalString concatStringsSep; | ||
| inherit (darwin.apple_sdk.frameworks) Security; | ||
| useLLVM = stdenv.targetPlatform.useLLVM or false; |
There was a problem hiding this comment.
@RossComputerGuy why is this looking at the target platform? I'm possibly missing something but as far as I can see, useLLVM is only used to control aspects during the build, not at runtime (these would be covered by #330037) so shouldn't it be hostPlatform?
example of a build that fails (when ran on a non-LLVM localSystem):
nix-build --arg crossSystem '{ config = "x86_64-unknown-linux-gnu"; useLLVM = true; }' -A buildPackages.rustc.unwrapped
(note the buildPackages)
There was a problem hiding this comment.
pkgsLLVM.buildPackages.stdenv.targetPlatform.useLLVM evaluates to true while pkgsLLVM.buildPackages.stdenv.hostPlatform.useLLVM evaluates to false.
There was a problem hiding this comment.
yes, that's what I'm saying. in the setup above, because pkgsLLVM.buildPackages.stdenv.targetPlatform.useLLVM evaluates to true, the tweaks are enabled when it looks like they shouldn't (because you are building binaries for a gcc-based platform so you should be using libgcc rather than libunwind, even if the target is LLVM). is my reasoning correct?
| ++ optionals stdenv.isDarwin [ libiconv Security ] | ||
| ++ optional (!withBundledLLVM) llvmShared; | ||
| ++ optional (!withBundledLLVM) llvmShared.lib | ||
| ++ optional (useLLVM && !withBundledLLVM) [ |
There was a problem hiding this comment.
Oh, no. Should be optionals here.
There was a problem hiding this comment.
It doesn't matter that much since it gets flattened
There was a problem hiding this comment.
It doesn't matter that much since it gets flattened
I don't think so. I applied the patch below, and the build failure was resolved.
--- a/pkgs/development/compilers/rust/rustc.nix
+++ b/pkgs/development/compilers/rust/rustc.nix
@@ -391,15 +391,9 @@ stdenv.mkDerivation (finalAttrs: {
zlib
]
++ optional (!withBundledLLVM) llvmShared.lib
- ++ optional (useLLVM && !withBundledLLVM && !stdenv.targetPlatform.isFreeBSD) [
- llvmPackages.libunwind
- # Hack which is used upstream https://github.com/gentoo/gentoo/blob/master/dev-lang/rust/rust-1.78.0.ebuild#L284
- (runCommandLocal "libunwind-libgcc" { } ''
- mkdir -p $out/lib
- ln -s ${llvmPackages.libunwind}/lib/libunwind.so $out/lib/libgcc_s.so
- ln -s ${llvmPackages.libunwind}/lib/libunwind.so $out/lib/libgcc_s.so.1
- '')
- ];
+ ++ optional (
+ useLLVM && !withBundledLLVM && !stdenv.targetPlatform.isFreeBSD
+ ) llvmPackages.libunwind;
outputs = [
"out"
Description of changes
Fixes #311930
Can be tested / reproduced by building
pkgsLLVM.rustc. Fix was tested under the Nixpkgs LLVM Workspace project.Things done
nix.conf? (See Nix manual)sandbox = relaxedsandbox = truenix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD". Note: all changes have to be committed, also see nixpkgs-review usage./result/bin/)Add a 👍 reaction to pull requests you find important.