Skip to content

Comments

llvmPackages.libcxx: Fix FreeBSD build#305408

Merged
wegank merged 1 commit intoNixOS:masterfrom
obsidiansystems:fix-freebsd
Apr 20, 2024
Merged

llvmPackages.libcxx: Fix FreeBSD build#305408
wegank merged 1 commit intoNixOS:masterfrom
obsidiansystems:fix-freebsd

Conversation

@Ericson2314
Copy link
Member

Description of changes

ce789e7 wasn't quite right, because multiple outputs.

Things done

  • Built on platform(s)
    • x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
  • For non-Linux: Is sandboxing enabled in nix.conf? (See Nix manual)
    • sandbox = relaxed
    • sandbox = true
  • Tested, as applicable:
  • Tested compilation of all packages that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD". Note: all changes have to be committed, also see nixpkgs-review usage
  • Tested basic functionality of all binary files (usually in ./result/bin/)
  • 24.05 Release Notes (or backporting 23.05 and 23.11 Release notes)
    • (Package updates) Added a release notes entry if the change is major or breaking
    • (Module updates) Added a release notes entry if the change is significant
    • (Module addition) Added a release notes entry if adding a new NixOS module
  • Fits CONTRIBUTING.md.

Add a 👍 reaction to pull requests you find important.

ce789e7 wasn't quite right, because multiple outputs.
@Ericson2314 Ericson2314 changed the title llvmPackgaes.libcxx: Fix FreeBSD build llvmPackages.libcxx: Fix FreeBSD build Apr 19, 2024
@Ericson2314 Ericson2314 mentioned this pull request Apr 19, 2024
13 tasks
@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 Apr 19, 2024
@wegank wegank merged commit b03c372 into NixOS:master Apr 20, 2024
@ghost
Copy link

ghost commented Apr 20, 2024

ce789e7 wasn't quite right, because multiple outputs.

ce789e7 got it right except for llvm12, all the others (13-git) were handled properly. not sure how llvm12 was missed as i diffed the files against themselves but i might've been sloppy there if the freebsd build was broken in other ways, though i thought 12 worked and 13 & 14 were broken due to libunwind or something, but that could've been pkgsLLVM or aarch64 pkgsLLVM.

# libc++.so is a linker script which expands to multiple libraries,
# libc++.so.1 and libc++abi.so or the external cxxabi. ld-wrapper doesn't
# support linker scripts so the external cxxabi needs to be symlinked in
postInstall = lib.optionalString (cxxabi != null) ''
lndir ${lib.getDev cxxabi}/include ''${!outputDev}/include/c++/v1
lndir ${lib.getLib cxxabi}/lib ''${!outputLib}/lib
'';

@Ericson2314 Ericson2314 deleted the fix-freebsd branch April 22, 2024 01:14
@Ericson2314
Copy link
Member Author

Ericson2314 commented Apr 22, 2024

@ghostofannalee these sorts of mistakes are quite likely --- I don't begrudge the author. That is why @RossComputerGuy doing the deduplication is such a good thing! --- it's best to make that mistake much less likely than try to just be more vigilant than is feasible.

@ghost
Copy link

ghost commented Apr 22, 2024

@ghostofannalee these sorts of mistakes are quite likely --- I don't begrudge the author. That is why @RossComputerGuy doing the deduplication is such a good thing! --- it's best to make that mistake much less likely than try to just be more vigilant than is feasible.

hmm, i think for llvm12 it might have needed to be $out as when i try to build nix-build -A pkgsCross.x86_64-freebsd.libcxx it fails with:

/nix/store/fv8plrk4s537n2hrnr2djhf734b3lkx8-libcxx-x86_64-unknown-freebsd13-12.0.1-dev/include/c++/v1: No such file or directory

pkgsCross.x86_64-freebsd.llvmPackages_16.libcxx works (with $dev) tho, so i think ce789e7 was correct in using $out for llvm12 and $dev for the rest.

@RossComputerGuy
Copy link
Member

@ghostofannalee That just sounds like the path that the directory being moved to doesn't exist.

@Ericson2314
Copy link
Member Author

@ghostofannalee Even if libc++ 12 puts it in $out, Nix will move it to $dev in the fixup stage. So I think we can just fix this by moving it to $dev earlier.

@ghost
Copy link

ghost commented Apr 22, 2024

@ghostofannalee Even if libc++ 12 puts it in $out, Nix will move it to $dev in the fixup stage. So I think we can just fix this by moving it to $dev earlier.

that worked for llvm12 and llvm16

diff --git a/pkgs/development/compilers/llvm/common/libcxx/default.nix b/pkgs/development/compilers/llvm/common/libcxx/default.nix
index 0e91f50551c5..c630213797db 100644
--- a/pkgs/development/compilers/llvm/common/libcxx/default.nix
+++ b/pkgs/development/compilers/llvm/common/libcxx/default.nix
@@ -124,6 +125,7 @@ stdenv.mkDerivation (rec {
   # libc++.so.1 and libc++abi.so or the external cxxabi. ld-wrapper doesn't
   # support linker scripts so the external cxxabi needs to be symlinked in
   postInstall = lib.optionalString (cxxabi != null) ''
+    [[ -d $out/include ]] && { mkdir -p $dev; mv $out/include $dev; }
     lndir ${lib.getDev cxxabi}/include $dev/include/c++/v1
     lndir ${lib.getLib cxxabi}/lib $out/lib
   '';

[edit] added diff in PR #306027

@ghost ghost mentioned this pull request Apr 22, 2024
13 tasks
@rrbutani rrbutani added the 6.topic: llvm/clang Issues related to llvmPackages, clangStdenv and related label May 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

6.topic: llvm/clang Issues related to llvmPackages, clangStdenv and related 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.

4 participants