From edd039abdceb14af8eb6ca28df444966447c5b47 Mon Sep 17 00:00:00 2001 From: Sebastien Bourdeauducq Date: Sun, 27 Mar 2022 18:41:23 +0800 Subject: [PATCH] windows: build LLD --- flake.nix | 1 + nix/windows/default.nix | 32 ++++++++++++++++++++++++++ nix/windows/lld-disable-macho.diff | 36 ++++++++++++++++++++++++++++++ 3 files changed, 69 insertions(+) create mode 100644 nix/windows/lld-disable-macho.diff diff --git a/flake.nix b/flake.nix index da94de64..a51f860b 100644 --- a/flake.nix +++ b/flake.nix @@ -142,6 +142,7 @@ inherit (packages.x86_64-linux) llvm-nac3 nac3artiq; llvm-nac3-msys2 = packages.x86_64-w64-mingw32.llvm-nac3; nac3artiq-msys2 = packages.x86_64-w64-mingw32.nac3artiq; + lld-msys2 = packages.x86_64-w64-mingw32.lld; }; }; diff --git a/nix/windows/default.nix b/nix/windows/default.nix index 71248b7f..4d48f298 100644 --- a/nix/windows/default.nix +++ b/nix/windows/default.nix @@ -103,6 +103,38 @@ in rec { ''; dontFixup = true; }; + lld = pkgs.stdenvNoCC.mkDerivation rec { + pname = "lld-msys2"; + version = "13.0.1"; + src = pkgs.fetchurl { + url = "https://github.com/llvm/llvm-project/releases/download/llvmorg-${version}/lld-${version}.src.tar.xz"; + sha256 = "sha256-Zmr3Rei/e2gFM7TRi3ox3HyrV1sebk0mGSK7r9lkTPs="; + }; + buildInputs = [ pkgs.wineWowPackages.stable ]; + phases = [ "unpackPhase" "patchPhase" "configurePhase" "buildPhase" "installPhase" ]; + patches = [ ./lld-disable-macho.diff ]; + configurePhase = + '' + export HOME=`mktemp -d` + export WINEDEBUG=-all + export WINEPATH=Z:${msys2-env}/mingw64/bin\;Z:${llvm-nac3}/bin + ${silenceFontconfig} + mkdir build + cd build + wine64 cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=Z:$out + ''; + buildPhase = + '' + wine64 ninja + ''; + installPhase = + '' + wine64 ninja install + mkdir $out/nix-support + echo file binary-dist $out/bin/lld.exe >> $out/nix-support/hydra-build-products + ''; + dontFixup = true; + }; wine-msys2 = pkgs.writeShellScriptBin "wine-msys2" '' export WINEDEBUG=-all diff --git a/nix/windows/lld-disable-macho.diff b/nix/windows/lld-disable-macho.diff new file mode 100644 index 00000000..8f7a9a13 --- /dev/null +++ b/nix/windows/lld-disable-macho.diff @@ -0,0 +1,36 @@ +diff '--color=auto' -Naur lld-13.0.1.src/CMakeLists.txt lld-13.0.1.src-new/CMakeLists.txt +--- lld-13.0.1.src/CMakeLists.txt 2022-01-21 05:31:59.000000000 +0800 ++++ lld-13.0.1.src-new/CMakeLists.txt 2022-03-27 18:26:30.284921982 +0800 +@@ -206,7 +206,6 @@ + add_subdirectory(docs) + add_subdirectory(COFF) + add_subdirectory(ELF) +-add_subdirectory(MachO) + add_subdirectory(MinGW) + add_subdirectory(wasm) + +diff '--color=auto' -Naur lld-13.0.1.src/tools/lld/CMakeLists.txt lld-13.0.1.src-new/tools/lld/CMakeLists.txt +--- lld-13.0.1.src/tools/lld/CMakeLists.txt 2022-01-21 05:31:59.000000000 +0800 ++++ lld-13.0.1.src-new/tools/lld/CMakeLists.txt 2022-03-27 18:26:40.805046295 +0800 +@@ -15,7 +15,6 @@ + lldCOFF + lldDriver + lldELF +- lldMachO2 + lldMinGW + lldWasm + ) +diff '--color=auto' -Naur lld-13.0.1.src/tools/lld/lld.cpp lld-13.0.1.src-new/tools/lld/lld.cpp +--- lld-13.0.1.src/tools/lld/lld.cpp 2022-01-21 05:31:59.000000000 +0800 ++++ lld-13.0.1.src-new/tools/lld/lld.cpp 2022-03-27 08:43:54.205524156 +0800 +@@ -148,10 +148,6 @@ + return !elf::link(args, exitEarly, stdoutOS, stderrOS); + case WinLink: + return !coff::link(args, exitEarly, stdoutOS, stderrOS); +- case Darwin: +- return !macho::link(args, exitEarly, stdoutOS, stderrOS); +- case DarwinOld: +- return !mach_o::link(args, exitEarly, stdoutOS, stderrOS); + case Wasm: + return !lld::wasm::link(args, exitEarly, stdoutOS, stderrOS); + default: