diff --git a/flake.nix b/flake.nix index 041e71335..a88b7a84c 100644 --- a/flake.nix +++ b/flake.nix @@ -10,7 +10,7 @@ nixpkgs-patched = pkgs-orig.applyPatches { name = "nixpkgs"; src = nixpkgs; - patches = [ ./llvm-future-riscv-abi.diff ./llvm-restrict-targets.diff ./llvm-mingw-crosscompile.diff ]; + patches = [ ./llvm-future-riscv-abi.diff ./llvm-restrict-targets.diff ./llvm-mingw-crosscompile.diff ./llvm-unbreak-static-cross.diff ]; }; pkgs = import nixpkgs-patched { system = "x86_64-linux"; }; pkgs-mingw = import nixpkgs-patched { system = "x86_64-linux"; crossSystem = { config = "x86_64-w64-mingw32"; libc = "msvcrt"; }; }; diff --git a/llvm-unbreak-static-cross.diff b/llvm-unbreak-static-cross.diff new file mode 100644 index 000000000..594731dee --- /dev/null +++ b/llvm-unbreak-static-cross.diff @@ -0,0 +1,44 @@ +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