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

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`
main
Ryan Burns 3 years ago
parent 6c39b6eda2
commit 544707d6a4
  1. 2
      pkgs/development/compilers/llvm/10/llvm/default.nix
  2. 16
      pkgs/development/compilers/llvm/10/llvm/outputs.patch
  3. 2
      pkgs/development/compilers/llvm/11/llvm/default.nix
  4. 16
      pkgs/development/compilers/llvm/11/llvm/outputs.patch
  5. 2
      pkgs/development/compilers/llvm/12/llvm/default.nix
  6. 16
      pkgs/development/compilers/llvm/12/llvm/outputs.patch
  7. 2
      pkgs/development/compilers/llvm/13/llvm/default.nix
  8. 16
      pkgs/development/compilers/llvm/13/llvm/outputs.patch
  9. 2
      pkgs/development/compilers/llvm/5/llvm/default.nix
  10. 16
      pkgs/development/compilers/llvm/5/llvm/outputs.patch
  11. 2
      pkgs/development/compilers/llvm/6/llvm/default.nix
  12. 16
      pkgs/development/compilers/llvm/6/llvm/outputs.patch
  13. 2
      pkgs/development/compilers/llvm/7/llvm/default.nix
  14. 16
      pkgs/development/compilers/llvm/7/llvm/outputs.patch
  15. 2
      pkgs/development/compilers/llvm/8/llvm/default.nix
  16. 16
      pkgs/development/compilers/llvm/8/llvm/outputs.patch
  17. 2
      pkgs/development/compilers/llvm/9/llvm/default.nix
  18. 16
      pkgs/development/compilers/llvm/9/llvm/outputs.patch
  19. 2
      pkgs/development/compilers/llvm/git/llvm/default.nix
  20. 16
      pkgs/development/compilers/llvm/git/llvm/outputs.patch
  21. 16
      pkgs/development/compilers/llvm/rocm/llvm/outputs.patch

@ -81,7 +81,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
'' + ''

@ -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

@ -73,7 +73,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
'' + ''

@ -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

@ -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
'' + ''

@ -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

@ -68,7 +68,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
'' + ''

@ -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

@ -74,7 +74,7 @@ stdenv.mkDerivation ({
--replace 'set(_install_rpath "@loader_path/../''${CMAKE_INSTALL_LIBDIR}" ''${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
'' + ''

@ -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

@ -72,7 +72,7 @@ stdenv.mkDerivation ({
--replace 'set(_install_rpath "@loader_path/../''${CMAKE_INSTALL_LIBDIR}" ''${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
'' + ''

@ -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

@ -76,7 +76,7 @@ in stdenv.mkDerivation ({
--replace 'set(_install_rpath "@loader_path/../''${CMAKE_INSTALL_LIBDIR}" ''${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
'' + ''

@ -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

@ -79,7 +79,7 @@ in stdenv.mkDerivation ({
--replace 'set(_install_rpath "@loader_path/../''${CMAKE_INSTALL_LIBDIR}" ''${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
'' + ''

@ -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

@ -77,7 +77,7 @@ in stdenv.mkDerivation (rec {
--replace 'set(_install_rpath "@loader_path/../''${CMAKE_INSTALL_LIBDIR}" ''${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
'' + ''

@ -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

@ -60,7 +60,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
'' + ''

@ -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

@ -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

Loading…
Cancel
Save