Skip to content

Fix issues with GHC outside of stdenv on Darwin#125367

Merged
sternenseemann merged 1 commit intoNixOS:haskell-updatesfrom
sternenseemann:ghc-darwin-fixes
Jun 8, 2021
Merged

Fix issues with GHC outside of stdenv on Darwin#125367
sternenseemann merged 1 commit intoNixOS:haskell-updatesfrom
sternenseemann:ghc-darwin-fixes

Conversation

@sternenseemann
Copy link
Copy Markdown
Member

@sternenseemann sternenseemann commented Jun 2, 2021

Motivation for this change
  • Fix GHC not finding otool
  • Apply fixes to all GHC versions we have
Things done
  • Tested using sandboxing (nix.useSandbox on NixOS, or option sandbox in nix.conf on non-NixOS linux)
  • Built on platform(s)
    • NixOS
    • macOS
    • other Linux distributions
  • Tested via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests)
  • Tested compilation of all pkgs that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Added a release notes entry if the change is major or breaking
  • Fits CONTRIBUTING.md.

@ofborg ofborg bot added the 6.topic: darwin Running or building packages on Darwin label Jun 2, 2021
@github-actions github-actions bot added the 6.topic: haskell General-purpose, statically typed, purely functional programming language label Jun 2, 2021
@sternenseemann
Copy link
Copy Markdown
Member Author

sternenseemann commented Jun 2, 2021

For reference, this is the new problem: Remaining rust failure:

$ nix-build -A tests.writers
these derivations will be built:
  /nix/store/hkpg0m44v3kvkgcjhzklbzhy7hyqbw1w-test_writers.drv
  /nix/store/1laarw0v4xnl6jdancfswa9imzddad85-test-writers.drv
  /nix/store/zmzl0phrj8fkzr8zch1xizysyybj7fbs-test_writers.drv
  /nix/store/awn033v3vlj7g31mcznd9caq6cr5vdvq-test-writers.drv
  /nix/store/fvsjrpls1apn2z6qcxz77cyz8z0rdl7c-test_haskell.drv
  /nix/store/xnkdwkv55xqahvqh2rsifasnha5li7rw-test_haskell.drv
  /nix/store/kx2l83gyvryka0x3nlkw8323kgs6qil3-test-writers.drv
  /nix/store/xcn490j6jsgji1mrgsvpvlx3pjjlpzqg-test-writers.drv
  /nix/store/vl2imbpfjhqc8cxqidpk3kfdvvqgj8dy-test-writers.drv
building '/nix/store/fvsjrpls1apn2z6qcxz77cyz8z0rdl7c-test_haskell.drv'...
[1 of 1] Compiling Main             ( tmp.hs, tmp.o )
Linking tmp ...
building '/nix/store/xnkdwkv55xqahvqh2rsifasnha5li7rw-test_haskell.drv'...
[1 of 1] Compiling Main             ( tmp.hs, tmp.o )
Linking tmp ...
building '/nix/store/xcn490j6jsgji1mrgsvpvlx3pjjlpzqg-test-writers.drv'...
building '/nix/store/kx2l83gyvryka0x3nlkw8323kgs6qil3-test-writers.drv'...
building '/nix/store/hkpg0m44v3kvkgcjhzklbzhy7hyqbw1w-test_writers.drv'...
error: linking with `cc` failed: exit code: 1
  |
  = note: "cc" "-m64" "-arch" "x86_64" "-L" "/nix/store/ly04c58zsvb4c219sv6q393dik249hjy-rustc-1.52.1/lib/rustlib/x86_64-apple-darwin/lib" "/nix/store/6zvgl3gafnk8k16ksxfhzg2az9ars84n-test_writers.tmp.7rcbfp3g-cgu.0.rcgu.o" "/nix/store/6zvgl3gafnk8k16ksxfhzg2az9ars84n-test_writers.tmp.7rcbfp3g-cgu.1.rcgu.o" "/nix/store/6zvgl3gafnk8k16ksxfhzg2az9ars84n-test_writers.tmp.7rcbfp3g-cgu.2.rcgu.o" "/nix/store/6zvgl3gafnk8k16ksxfhzg2az9ars84n-test_writers.tmp.7rcbfp3g-cgu.3.rcgu.o" "/nix/store/6zvgl3gafnk8k16ksxfhzg2az9ars84n-test_writers.tmp.7rcbfp3g-cgu.4.rcgu.o" "/nix/store/6zvgl3gafnk8k16ksxfhzg2az9ars84n-test_writers.tmp.7rcbfp3g-cgu.5.rcgu.o" "/nix/store/6zvgl3gafnk8k16ksxfhzg2az9ars84n-test_writers.tmp.7rcbfp3g-cgu.6.rcgu.o" "/nix/store/6zvgl3gafnk8k16ksxfhzg2az9ars84n-test_writers.tmp.7rcbfp3g-cgu.7.rcgu.o" "-o" "/nix/store/6zvgl3gafnk8k16ksxfhzg2az9ars84n-test_writers" "/nix/store/6zvgl3gafnk8k16ksxfhzg2az9ars84n-test_writers.4i0hgzmnpf4h2pz.rcgu.o" "-Wl,-dead_strip" "-nodefaultlibs" "-L" "/nix/store/ly04c58zsvb4c219sv6q393dik249hjy-rustc-1.52.1/lib/rustlib/x86_64-apple-darwin/lib" "/nix/store/ly04c58zsvb4c219sv6q393dik249hjy-rustc-1.52.1/lib/rustlib/x86_64-apple-darwin/lib/libstd-8ecebea30c961804.rlib" "/nix/store/ly04c58zsvb4c219sv6q393dik249hjy-rustc-1.52.1/lib/rustlib/x86_64-apple-darwin/lib/libpanic_unwind-78b8371c8829edb9.rlib" "/nix/store/ly04c58zsvb4c219sv6q393dik249hjy-rustc-1.52.1/lib/rustlib/x86_64-apple-darwin/lib/libobject-11c2250f76ee79de.rlib" "/nix/store/ly04c58zsvb4c219sv6q393dik249hjy-rustc-1.52.1/lib/rustlib/x86_64-apple-darwin/lib/libaddr2line-138200afe481d69a.rlib" "/nix/store/ly04c58zsvb4c219sv6q393dik249hjy-rustc-1.52.1/lib/rustlib/x86_64-apple-darwin/lib/libgimli-50edf7ed96dca7d7.rlib" "/nix/store/ly04c58zsvb4c219sv6q393dik249hjy-rustc-1.52.1/lib/rustlib/x86_64-apple-darwin/lib/librustc_demangle-f5add760ba32d8c5.rlib" "/nix/store/ly04c58zsvb4c219sv6q393dik249hjy-rustc-1.52.1/lib/rustlib/x86_64-apple-darwin/lib/libhashbrown-107795e7ae43b1fc.rlib" "/nix/store/ly04c58zsvb4c219sv6q393dik249hjy-rustc-1.52.1/lib/rustlib/x86_64-apple-darwin/lib/librustc_std_workspace_alloc-1a28e1881ca37aeb.rlib" "/nix/store/ly04c58zsvb4c219sv6q393dik249hjy-rustc-1.52.1/lib/rustlib/x86_64-apple-darwin/lib/libunwind-0b60cab5e184de42.rlib" "/nix/store/ly04c58zsvb4c219sv6q393dik249hjy-rustc-1.52.1/lib/rustlib/x86_64-apple-darwin/lib/libcfg_if-20066734a370e7ce.rlib" "/nix/store/ly04c58zsvb4c219sv6q393dik249hjy-rustc-1.52.1/lib/rustlib/x86_64-apple-darwin/lib/liblibc-0688efbb4c57e170.rlib" "/nix/store/ly04c58zsvb4c219sv6q393dik249hjy-rustc-1.52.1/lib/rustlib/x86_64-apple-darwin/lib/liballoc-0c8da59b450dd54a.rlib" "/nix/store/ly04c58zsvb4c219sv6q393dik249hjy-rustc-1.52.1/lib/rustlib/x86_64-apple-darwin/lib/librustc_std_workspace_core-159337c2037ece59.rlib" "/nix/store/ly04c58zsvb4c219sv6q393dik249hjy-rustc-1.52.1/lib/rustlib/x86_64-apple-darwin/lib/libcore-1ba7a3965a87fb70.rlib" "/nix/store/ly04c58zsvb4c219sv6q393dik249hjy-rustc-1.52.1/lib/rustlib/x86_64-apple-darwin/lib/libcompiler_builtins-2f50c7e4a63f3402.rlib" "-lSystem" "-lresolv" "-lc" "-lm" "-liconv"
  = note: ld: library not found for -liconv
          collect2: error: ld returned 1 exit status
          

error: aborting due to previous error

builder for '/nix/store/hkpg0m44v3kvkgcjhzklbzhy7hyqbw1w-test_writers.drv' failed with exit code 1
cannot build derivation '/nix/store/1laarw0v4xnl6jdancfswa9imzddad85-test-writers.drv': 1 dependencies couldn't be built
building '/nix/store/zmzl0phrj8fkzr8zch1xizysyybj7fbs-test_writers.drv'...
cannot build derivation '/nix/store/vl2imbpfjhqc8cxqidpk3kfdvvqgj8dy-test-writers.drv': 1 dependencies couldn't be built
error: build of '/nix/store/vl2imbpfjhqc8cxqidpk3kfdvvqgj8dy-test-writers.drv' failed

@ofborg ofborg bot requested review from MarcWeber, kosmikus and peti June 2, 2021 11:45
@ofborg ofborg bot added 10.rebuild-darwin: 501+ This PR causes many rebuilds on Darwin and should normally target the staging branches. 10.rebuild-darwin: 5001+ This PR causes many rebuilds on Darwin and must target the staging branches. 10.rebuild-linux: 0 This PR does not cause any packages to rebuild on Linux. labels Jun 2, 2021
@domenkozar
Copy link
Copy Markdown
Member

cc @Ericson2314 & @matthewbauer if they can help out somehow.

@sternenseemann
Copy link
Copy Markdown
Member Author

sternenseemann commented Jun 8, 2021

Okay turns out, I fixed the issue on darwin indeed, the issue pasted above is with the rust writer. I got confused because the derivation names are generic in many cases, something I'll also go ahead and fix. See #126182.

@domenkozar
Copy link
Copy Markdown
Member

@sternenseemann does this need to be backported to older GHCs?

@sternenseemann
Copy link
Copy Markdown
Member Author

I suspect so, which is why I'm still marking this as a draft. I'll add the fix to the other GHCs later and merge this into haskell-updates for testing.

Eventually I want to separate the wrapper script and the GHC derivation, so we don't need to port such fixes all the time (#123599), but one step at a time.

GHC calls otool on darwin which is contained in the
stdenv.cc.bintools.bintools derivation and thus needs adding to the
runtime PATH of GHC. Since this is toolchain specific technically, we
check for cctools instead of darwin (although I don't know if GHC
or nixpkgs work on macOS without cctools).

This fixes usage of GHC in an environment where otool is not available
and more specifically in stdenvNoCC which is used by writers.writeHaskell.
Resolves NixOS#123228.
@sternenseemann sternenseemann marked this pull request as ready for review June 8, 2021 12:00
@sternenseemann sternenseemann changed the title WIP: Fix issues with GHC outside of stdenv on Darwin Fix issues with GHC outside of stdenv on Darwin Jun 8, 2021
Copy link
Copy Markdown
Member

@maralorn maralorn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@sternenseemann sternenseemann merged commit 118b28a into NixOS:haskell-updates Jun 8, 2021
@sternenseemann sternenseemann deleted the ghc-darwin-fixes branch June 8, 2021 12:20
@sternenseemann sternenseemann added the 9.needs: port to stable A PR needs a backport to the stable release. label Jun 8, 2021
@sternenseemann sternenseemann restored the ghc-darwin-fixes branch July 24, 2021 13:36
@sternenseemann sternenseemann removed the 9.needs: port to stable A PR needs a backport to the stable release. label Nov 25, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

6.topic: darwin Running or building packages on Darwin 6.topic: haskell General-purpose, statically typed, purely functional programming language 10.rebuild-darwin: 501+ This PR causes many rebuilds on Darwin and should normally target the staging branches. 10.rebuild-darwin: 5001+ This PR causes many rebuilds on Darwin and must target the staging branches. 10.rebuild-linux: 0 This PR does not cause any packages to rebuild on Linux.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants