1
0
forked from M-Labs/nac3
nac3/llvm-unbreak-static-cross.diff

45 lines
2.0 KiB
Diff
Raw Normal View History

diff --git a/pkgs/development/compilers/llvm/12/llvm/default.nix b/pkgs/development/compilers/llvm/12/llvm/default.nix
index 30a1a7a16df..bb5676b9d48 100644
--- 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
'' + ''
diff --git a/pkgs/development/compilers/llvm/12/llvm/outputs.patch b/pkgs/development/compilers/llvm/12/llvm/outputs.patch
index 40096fa3497..878460e05b8 100644
--- a/pkgs/development/compilers/llvm/12/llvm/outputs.patch
+++ b/pkgs/development/compilers/llvm/12/llvm/outputs.patch
@@ -2,23 +2,13 @@ diff --git a/tools/llvm-config/llvm-config.cpp b/tools/llvm-config/llvm-config.c
index 94d426b..37f7794 100644
--- a/tools/llvm-config/llvm-config.cpp
+++ b/tools/llvm-config/llvm-config.cpp
-@@ -333,6 +333,21 @@ int main(int argc, char **argv) {
+@@ -333,6 +333,11 @@ int main(int argc, char **argv) {
ActiveIncludeOption = "-I" + ActiveIncludeDir;
}
-+ /// Nix-specific multiple-output handling: override ActiveLibDir if --link-shared
++ /// Nix-specific multiple-output handling: override ActiveLibDir
+ if (!IsInDevelopmentTree) {
-+ bool WantShared = true;
-+ for (int i = 1; i < argc; ++i) {
-+ StringRef Arg = argv[i];
-+ if (Arg == "--link-shared")
-+ WantShared = true;
-+ else if (Arg == "--link-static")
-+ WantShared = false; // the last one wins
-+ }
-+
-+ if (WantShared)
-+ ActiveLibDir = std::string("@lib@") + "/lib" + LLVM_LIBDIR_SUFFIX;
++ ActiveLibDir = std::string("@lib@") + "/lib" + LLVM_LIBDIR_SUFFIX;
+ }
+
/// We only use `shared library` mode in cases where the static library form