From 5e1b0a10a0fdac966212bdea0b208cc7d8c72e66 Mon Sep 17 00:00:00 2001 From: Sebastien Bourdeauducq Date: Fri, 26 Nov 2021 17:01:44 +0800 Subject: [PATCH] flake: patch nixpkgs to fix mingw llvm_12 build --- flake.nix | 2 +- llvm-mingw-crosscompile.diff | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+), 1 deletion(-) create mode 100644 llvm-mingw-crosscompile.diff diff --git a/flake.nix b/flake.nix index e6367367..c75bec59 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 ]; + patches = [ ./llvm-future-riscv-abi.diff ./llvm-restrict-targets.diff ./llvm-mingw-crosscompile.diff ]; }; pkgs = import nixpkgs-patched { system = "x86_64-linux"; }; in rec { diff --git a/llvm-mingw-crosscompile.diff b/llvm-mingw-crosscompile.diff new file mode 100644 index 00000000..09fc6599 --- /dev/null +++ b/llvm-mingw-crosscompile.diff @@ -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"