From 3fe4fabbc517592cefd2c445340fa426729a8d2f Mon Sep 17 00:00:00 2001 From: Zhong Jianxin Date: Wed, 6 Nov 2024 19:10:41 +0800 Subject: [PATCH] swift: Workaround Hydra darwin build problem When the host platform is darwin, building swift on Hydra and Github Actions with ninja 1.12 will both give the same error: ``` 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) ... ``` Beware the failure does not happen on developers' local machines. Until we find out the exact cause, pin ninja to version 1.11 to workaround the problem. --- .../compilers/swift/compiler/default.nix | 20 ++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/pkgs/development/compilers/swift/compiler/default.nix b/pkgs/development/compilers/swift/compiler/default.nix index 651c6faa566ce..76d36e170a82b 100644 --- a/pkgs/development/compilers/swift/compiler/default.nix +++ b/pkgs/development/compilers/swift/compiler/default.nix @@ -190,6 +190,24 @@ let ''; }; + ninja' = + if stdenv.hostPlatform.isDarwin then + # https://github.com/NixOS/nixpkgs/issues/327836 + # Fail to build with ninja 1.12 on Hydra when host platform is darwin, but + # not on developers' local machines. + # Until we find out the exact cause, pin ninja to version 1.11 to + # workaround the problem. + ninja.overrideAttrs (old: rec { + version = "1.11.1"; + src = old.src.override { + rev = version; + hash = "sha256-LvV/Fi2ARXBkfyA1paCRmLUwCh/rTyz+tGMg2/qEepI="; + }; + patches = [ ]; + }) + else + ninja; + in stdenv.mkDerivation { pname = "swift"; inherit (sources) version; @@ -199,7 +217,7 @@ in stdenv.mkDerivation { nativeBuildInputs = [ cmake git - ninja + ninja' perl # pod2man pkg-config python3