From 8dfed1b9a444dca8e41a1d0f90436664f902634e Mon Sep 17 00:00:00 2001 From: Zhong Jianxin Date: Fri, 8 Nov 2024 09:10:53 +0800 Subject: [PATCH] swift: Workaround Hydra darwin build problem Fail to build with ninja 1.12 when NIX_BUILD_CORES is low (Hydra or Github Actions): ``` ld: warning: directory not found for option '-L/nix/store/g9rbp9m6vs1xj4jl6b6vjb6bm8kgr107-SDKs/MacOSX10.15.sdk/usr/lib/swift' ... ld: warning: Could not find or use auto-linked library 'swiftCompatibility56' Undefined symbols for architecture arm64: "__swift_FORCE_LOAD_$_swiftCompatibility56", referenced from: __swift_FORCE_LOAD_$_swiftCompatibility56_$_Optimizer in libswiftCompilerModules-bootstrapping1.a(Optimizer.o) ... ``` Can reproduce using `nix --option cores 2 build -f . swiftPackages.swift-unwrapped`. Until we find out the exact cause, follow [swift upstream][1], pin ninja to version 1.11.1. [1]: https://github.com/swiftlang/swift/pull/72989 --- pkgs/development/compilers/swift/compiler/default.nix | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/pkgs/development/compilers/swift/compiler/default.nix b/pkgs/development/compilers/swift/compiler/default.nix index 651c6faa566ce..8e8cf798db4f2 100644 --- a/pkgs/development/compilers/swift/compiler/default.nix +++ b/pkgs/development/compilers/swift/compiler/default.nix @@ -6,7 +6,7 @@ , coreutils , gnugrep , perl -, ninja +, ninja_1_11 , pkg-config , clang , bintools @@ -190,6 +190,14 @@ let ''; }; + # https://github.com/NixOS/nixpkgs/issues/327836 + # Fail to build with ninja 1.12 when NIX_BUILD_CORES is low (Hydra or Github Actions). + # Can reproduce using `nix --option cores 2 build -f . swiftPackages.swift-unwrapped`. + # Until we find out the exact cause, follow [swift upstream][1], pin ninja to version + # 1.11.1. + # [1]: https://github.com/swiftlang/swift/pull/72989 + ninja = ninja_1_11; + in stdenv.mkDerivation { pname = "swift"; inherit (sources) version;