flake: patch nixpkgs to fix mingw llvm_12 build

This commit is contained in:
Sebastien Bourdeauducq 2021-11-26 17:01:44 +08:00
parent 9f316a3294
commit 5e1b0a10a0
2 changed files with 36 additions and 1 deletions

View File

@ -10,7 +10,7 @@
nixpkgs-patched = pkgs-orig.applyPatches {
name = "nixpkgs";
src = nixpkgs;
patches = [ ./llvm-future-riscv-abi.diff ./llvm-restrict-targets.diff ];
patches = [ ./llvm-future-riscv-abi.diff ./llvm-restrict-targets.diff ./llvm-mingw-crosscompile.diff ];
};
pkgs = import nixpkgs-patched { system = "x86_64-linux"; };
in rec {

View File

@ -0,0 +1,35 @@
diff --git a/pkgs/development/compilers/llvm/12/llvm/default.nix b/pkgs/development/compilers/llvm/12/llvm/default.nix
index 30a1a7a16df..4f9435d1819 100644
--- a/pkgs/development/compilers/llvm/12/llvm/default.nix
+++ b/pkgs/development/compilers/llvm/12/llvm/default.nix
@@ -15,10 +15,11 @@
, buildLlvmTools
, debugVersion ? false
, enableManpages ? false
-, enableSharedLibraries ? !stdenv.hostPlatform.isStatic
+, enableSharedLibraries ? (!stdenv.hostPlatform.isStatic && !stdenv.targetPlatform.isMinGW)
, enablePFM ? !(stdenv.isDarwin
|| stdenv.isAarch64 # broken for Ampere eMAG 8180 (c2.large.arm on Packet) #56245
|| stdenv.isAarch32 # broken for the armv7l builder
+ || stdenv.targetPlatform.isMinGW
)
, enablePolly ? false
}:
@@ -120,7 +121,7 @@ in stdenv.mkDerivation (rec {
"-DLLVM_INSTALL_CMAKE_DIR=${placeholder "dev"}/lib/cmake/llvm/"
"-DCMAKE_BUILD_TYPE=${if debugVersion then "Debug" else "Release"}"
"-DLLVM_INSTALL_UTILS=ON" # Needed by rustc
- "-DLLVM_BUILD_TESTS=ON"
+ "-DLLVM_BUILD_TESTS=${if stdenv.targetPlatform.isMinGW then "OFF" else "ON"}"
"-DLLVM_ENABLE_FFI=ON"
"-DLLVM_ENABLE_RTTI=ON"
"-DLLVM_HOST_TRIPLE=${stdenv.hostPlatform.config}"
@@ -134,7 +135,7 @@ in stdenv.mkDerivation (rec {
"-DSPHINX_OUTPUT_MAN=ON"
"-DSPHINX_OUTPUT_HTML=OFF"
"-DSPHINX_WARNINGS_AS_ERRORS=OFF"
- ] ++ optionals (!isDarwin) [
+ ] ++ optionals (!isDarwin && !stdenv.targetPlatform.isMinGW) [
"-DLLVM_BINUTILS_INCDIR=${libbfd.dev}/include"
] ++ optionals isDarwin [
"-DLLVM_ENABLE_LIBCXX=ON"