From 3090ed3f403cae8ec297aa8cbe8f7f7114c4dc75 Mon Sep 17 00:00:00 2001 From: sternenseemann Date: Fri, 29 Oct 2021 12:12:58 +0200 Subject: [PATCH 1/2] writers: use platform's default strip bintools points to the default bintools (e. g. cctools, binutils, llvmPackages.bintools) for the next stage. So instead of using GNU binutils' strip which may not support the current platform, we need to use buildPackages.bintools-unwrapped. Additionally we need to use `-S` over `--strip-unneeded` as the latter is a GNU binutils-specific flag and not supported by cctools. Also add the correct targetPrefix in order to support cross-compilation correctly here at least. --- pkgs/build-support/writers/default.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkgs/build-support/writers/default.nix b/pkgs/build-support/writers/default.nix index 111ec68a6021..09ee7d738658 100644 --- a/pkgs/build-support/writers/default.nix +++ b/pkgs/build-support/writers/default.nix @@ -1,4 +1,4 @@ -{ pkgs, lib, gawk, gnused, gixy }: +{ pkgs, buildPackages, lib, gawk, gnused, gixy }: with lib; rec { @@ -77,7 +77,7 @@ rec { }) '' ${compileScript} ${lib.optionalString strip - "${pkgs.binutils-unwrapped}/bin/strip --strip-unneeded $out"} + "${lib.getBin buildPackages.bintools-unwrapped}/bin/${buildPackages.bintools-unwrapped.targetPrefix}strip -S $out"} ${optionalString (types.path.check nameOrPath) '' mv $out tmp mkdir -p $out/$(dirname "${nameOrPath}") From b1197ac729ad272c7f2c30423cb3057a16bc61c8 Mon Sep 17 00:00:00 2001 From: sternenseemann Date: Fri, 29 Oct 2021 12:19:17 +0200 Subject: [PATCH 2/2] writers: run fixupPhase for darwin bin writers mach-o executables we produce in writers are not always fully valid for some reason. In normal derivation this is fixed in fixupPhase and we can replicate this behavior here easily. Resolves #132660. --- pkgs/build-support/writers/default.nix | 4 ++++ pkgs/top-level/release-haskell.nix | 5 +---- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/pkgs/build-support/writers/default.nix b/pkgs/build-support/writers/default.nix index 09ee7d738658..216e41f6d7ec 100644 --- a/pkgs/build-support/writers/default.nix +++ b/pkgs/build-support/writers/default.nix @@ -78,6 +78,10 @@ rec { ${compileScript} ${lib.optionalString strip "${lib.getBin buildPackages.bintools-unwrapped}/bin/${buildPackages.bintools-unwrapped.targetPrefix}strip -S $out"} + # Sometimes binaries produced for darwin (e. g. by GHC) won't be valid + # mach-o executables from the get-go, but need to be corrected somehow + # which is done by fixupPhase. + ${lib.optionalString pkgs.stdenvNoCC.hostPlatform.isDarwin "fixupPhase"} ${optionalString (types.path.check nameOrPath) '' mv $out tmp mkdir -p $out/$(dirname "${nameOrPath}") diff --git a/pkgs/top-level/release-haskell.nix b/pkgs/top-level/release-haskell.nix index 0cd73d68518a..11dad3dd3a39 100644 --- a/pkgs/top-level/release-haskell.nix +++ b/pkgs/top-level/release-haskell.nix @@ -330,10 +330,7 @@ let }; constituents = accumulateDerivations [ # haskell specific tests - # - # TODO: The writers test appears to be failing on darwin for unknown - # reasons. See https://github.com/NixOS/nixpkgs/pull/129606#issuecomment-881307871. - (lib.recursiveUpdate jobs.tests.haskell { writers.x86_64-darwin = null; }) + jobs.tests.haskell # important top-level packages jobs.cabal-install jobs.cabal2nix