Skip to content

llvmPackages_*.llvm: fix llvm-config-native with static libs#148367

Merged
7c6f434c merged 1 commit intoNixOS:stagingfrom
r-burns:llvm-config-static
Dec 24, 2021
Merged

llvmPackages_*.llvm: fix llvm-config-native with static libs#148367
7c6f434c merged 1 commit intoNixOS:stagingfrom
r-burns:llvm-config-static

Conversation

@r-burns
Copy link
Contributor

@r-burns r-burns commented Dec 3, 2021

Since both static and shared libs are installed to the same lib
output, we override the ActiveLibDir unconditionally.

Fixes llvm-config-native --link-static --libs

Motivation for this change

Fixes #148117

Things done
  • Built on platform(s)
    • x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
  • For non-Linux: Is sandbox = true set in nix.conf? (See Nix manual)
  • 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/)
  • 22.05 Release Notes (or backporting 21.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
    • (Release notes changes) Ran nixos/doc/manual/md-to-db.sh to update generated release notes
  • Fits CONTRIBUTING.md.

Copy link
Contributor

@sbourdeauducq sbourdeauducq left a comment

Choose a reason for hiding this comment

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

Thanks for this!
You also need to patch unconditionally, e.g.:

--- a/pkgs/development/compilers/llvm/12/llvm/default.nix
+++ b/pkgs/development/compilers/llvm/12/llvm/default.nix
@@ -74,7 +74,7 @@ in stdenv.mkDerivation (rec {
       --replace 'set(_install_rpath "@loader_path/../''${CMAKE_INSTALL_LIBDIR}''${LLVM_LIBDIR_SUFFIX}" ''${extra_libdir})' ""
   ''
   # Patch llvm-config to return correct library path based on --link-{shared,static}.
-  + optionalString (enableSharedLibraries) ''
+  + ''
     substitute '${./outputs.patch}' ./outputs.patch --subst-var lib
     patch -p1 < ./outputs.patch
   '' + ''

Since both static and shared libs are installed to the same `lib`
output, we override the ActiveLibDir unconditionally.

Fixes `llvm-config-native --link-static --libs`
@r-burns r-burns force-pushed the llvm-config-static branch from 7ec6a03 to 544707d Compare December 3, 2021 03:21
@r-burns
Copy link
Contributor Author

r-burns commented Dec 3, 2021

Good catch, thanks!

@ofborg ofborg bot added 10.rebuild-darwin-stdenv This PR causes stdenv to rebuild on Darwin and must target a staging branch. 10.rebuild-darwin: 501+ This PR causes many rebuilds on Darwin and should normally target the staging branches. 10.rebuild-darwin: 5001+ This PR causes many rebuilds on Darwin and must target the staging branches. 10.rebuild-linux: 501+ This PR causes many rebuilds on Linux and should normally target the staging branches. 10.rebuild-linux: 5001+ This PR causes many rebuilds on Linux and must target the staging branches. labels Dec 3, 2021
@sbourdeauducq sbourdeauducq self-requested a review December 3, 2021 03:53
Copy link
Contributor

@sbourdeauducq sbourdeauducq left a comment

Choose a reason for hiding this comment

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

Checked that cross-compilation now works fine in my LLVM 12 project with this patch, and some LLVM 13 programs (lld, rustc, cargo) are still OK.
Anything else I should test?

@ofborg ofborg bot requested review from 7c6f434c, dtzWill, lovek323 and primeos December 3, 2021 04:25
@r-burns
Copy link
Contributor Author

r-burns commented Dec 3, 2021

Cool project! Yeah, that seems like a reasonable amount of testing. This will go through staging so I'll be able to keep an eye out for regressions on hydra.

@github-actions
Copy link
Contributor

Successfully created backport PR #151996 for staging-21.11.

@r-burns r-burns deleted the llvm-config-static branch December 24, 2021 11:00
@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: 501+ This PR causes many rebuilds on Darwin and should normally target the staging branches. 10.rebuild-darwin: 5001+ This PR causes many rebuilds on Darwin and must target the staging branches. 10.rebuild-darwin-stdenv This PR causes stdenv to rebuild on Darwin and must target a staging branch. 10.rebuild-linux: 501+ This PR causes many rebuilds on Linux and should normally target the staging branches. 10.rebuild-linux: 5001+ This PR causes many rebuilds on Linux and must target the staging branches.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants