Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get GHC 9.8 working on M3 macs #296909

Closed
wants to merge 1 commit into from

Conversation

mpscholten
Copy link
Contributor

@mpscholten mpscholten commented Mar 18, 2024

Description of changes

GHC 9.8 cannot currently be built on M3 Macs because it relies on GHC 9.6.3 (through hadrian) which is broken due to https://gitlab.haskell.org/ghc/ghc/-/issues/23746

Error I get when building GHC 9.8:

marc@Marcs-M3-Max ihp-pro % nix develop --impure
warning: Git tree '/Users/marc/digitallyinduced/ihp-pro' is dirty
error: builder for '/nix/store/25yjia69f7has5h7fyic684d2yff5xh6-shake-0.19.8.drv' failed with exit code 1;
       last 10 log lines:
       >       _Ls1ehn_info in Cloud.o
       >       _Ls2xX0_info in Derived.o
       >       _Ls2zGK_info in Files.o
       >       _Lsa90_info in libHShashable-1.4.3.0-A9LFXpiwTxs1MJiRE3ofES.a(Class.o)
       >       _LcdzG_info in libHShashable-1.4.3.0-A9LFXpiwTxs1MJiRE3ofES.a(Class.o)
       >       _Lsb7C_info in libHShashable-1.4.3.0-A9LFXpiwTxs1MJiRE3ofES.a(Class.o)
       >       ...
       > ld: symbol(s) not found for architecture arm64
       > clang-16: error: linker command failed with exit code 1 (use -v to see invocation)
       > ghc-9.6.3: `clang' failed in phase `Linker'. (Exit code: 1)
       For full logs, run 'nix log /nix/store/25yjia69f7has5h7fyic684d2yff5xh6-shake-0.19.8.drv'.
error: 1 dependencies of derivation '/nix/store/ip40rpl4k8j249glnayc7h0nhmafq15y-hadrian-9.8.2.drv' failed to build
error: 1 dependencies of derivation '/nix/store/h2awpp00v44srnga8w4l50irnb4bj537-ghc-9.8.2.drv' failed to build
error: 1 dependencies of derivation '/nix/store/3j78g9px9vzy1mb9cg3ixy9rwlvqbv1b-ghc-9.8.2-with-packages.drv' failed to build
error: 1 dependencies of derivation '/nix/store/gx4g8x0s58prd42qxppgqvi4wldaqblh-haskell-language-server-2.6.0.0.drv' failed to build
error: 1 dependencies of derivation '/nix/store/a2c2zc4znl9pkgfxls7n2i5i9z6dk2pb-devenv-profile.drv' failed to build
error: 1 dependencies of derivation '/nix/store/84w08nzwnnihgrbcgrs5jb59jsk8vw1b-devenv-shell-env.drv' failed to build
marc@Marcs-M3-Max ihp-pro % github .

The fix for that linker error is in GHC 9.6.4. So by upgrading the GHC version we should have things working again.

Things done

  • Built on platform(s)
    • x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
  • For non-Linux: Is sandboxing enabled in nix.conf? (See Nix manual)
    • sandbox = relaxed
    • sandbox = true
  • Tested, as applicable:
  • Tested compilation of all packages that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD". Note: all changes have to be committed, also see nixpkgs-review usage
  • Tested basic functionality of all binary files (usually in ./result/bin/)
  • 24.05 Release Notes (or backporting 23.05 and 23.11 Release notes)
    • (Package updates) Added a release notes entry if the change is major or breaking
    • (Module updates) Added a release notes entry if the change is significant
    • (Module addition) Added a release notes entry if adding a new NixOS module
  • Fits CONTRIBUTING.md.

Add a 👍 reaction to pull requests you find important.

@mpscholten

This comment was marked as outdated.

@mpscholten mpscholten changed the title haskell.compiler.ghc964Binary: init at 9.6.4 Get GHC 9.8 working on M3 macs Mar 18, 2024
@ofborg ofborg bot added the 8.has: package (new) This PR adds a new package label Mar 18, 2024
@ofborg ofborg bot requested review from expipiplus1 and cdepillabout March 18, 2024 14:31
@ofborg ofborg bot added 10.rebuild-linux: 0 This PR does not cause any packages to rebuild on Linux and removed 10.rebuild-linux: 1-10 labels Mar 18, 2024
@mpscholten
Copy link
Contributor Author

@maralorn any feedback on this one so far?

@mpscholten
Copy link
Contributor Author

@ncfavier maybe you can take a look at this one as well. This makes GHC9.8 work on macs. Not sure whether this is the best approach, but it made the build work locally

@ncfavier
Copy link
Member

I don't have very much knowledge about darwin or GHC bootstrapping, but I doubt we want to use a non-binary distribution for bootstrapping on darwin. Why not simply update the 9.6.3 binary to 9.6.4?

@mpscholten
Copy link
Contributor Author

mpscholten commented Mar 19, 2024

Why not simply update the 9.6.3 binary to 9.6.4?

I tried this initially (that's why the branch of this PR is named this way). It compiled but the resulting GHC binary couldn't successfully link any haskell program.

but I doubt we want to use a non-binary distribution for bootstrapping on darwin

I agree, but it's better than no GHC 9.8 at all

@sternenseemann
Copy link
Member

It compiled but the resulting GHC binary couldn't successfully link any haskell program.

Which GHC binary?

@mpscholten
Copy link
Contributor Author

I think it was the GHC9.6.4 which couldn't link the Hadrian binary anymore to bootstrap the GHC9.8

@mpscholten
Copy link
Contributor Author

mpscholten commented Mar 20, 2024

Here's the full error when using the ghc 9.6.4 binary to bootstrap ghc 9.8:

@nix { "action": "setPhase", "phase": "setupCompilerEnvironmentPhase" }
Running phase: setupCompilerEnvironmentPhase
Build with /nix/store/j1r1hnfk0zn4k44nm6m4a27nka35649n-ghc-binary-9.6.4.
@nix { "action": "setPhase", "phase": "unpackPhase" }
Running phase: unpackPhase
unpacking source archive /nix/store/sq52klsgzsvzn0f08izklqjkgvqydiid-clock-0.8.4.tar.gz
source root is clock-0.8.4
setting SOURCE_DATE_EPOCH to timestamp 1000000000 of file clock-0.8.4/tests/test.hs
@nix { "action": "setPhase", "phase": "patchPhase" }
Running phase: patchPhase
@nix { "action": "setPhase", "phase": "compileBuildDriverPhase" }
Running phase: compileBuildDriverPhase
setupCompileFlags: -package-db=/private/tmp/nix-build-clock-0.8.4.drv-0/tmp.F9s09YB3zl/setup-package.conf.d -j16 -threaded -rtsopts
[[1 of 22 of ] Compiling2 ] LinkingMain              (Setup 
Setup.hs, /private/tmp/nix-build-clock-0.8.4.drv-0/tmp.F9s09YB3zl/Main.o )
@nix { "action": "setPhase", "phase": "updateAutotoolsGnuConfigScriptsPhase" }
Running phase: updateAutotoolsGnuConfigScriptsPhase
@nix { "action": "setPhase", "phase": "configurePhase" }
Running phase: configurePhase
configureFlags: --verbose --prefix=/nix/store/5m4jz8iznpbg7n407fzihxb1vly26jjx-clock-0.8.4 --libdir=$prefix/lib/$compiler/lib --libsubdir=$abi/$libname --with-gcc=clang --package-db=/private/tmp/nix-build-clock-0.8.4.drv-0/tmp.F9s09YB3zl/package.conf.d --ghc-options=-j16 --disable-library-profiling --disable-profiling --disable-shared --disable-coverage --enable-static --disable-executable-dynamic --disable-tests --disable-benchmarks --enable-library-vanilla --disable-library-for-ghci --disable-split-sections --enable-library-stripping --enable-executable-stripping --extra-include-dirs=/nix/store/rjgv94p1nnj02v0f9r2jpann9x02b4vw-libcxx-16.0.6-dev/include --extra-lib-dirs=/nix/store/j3yw5w8pbdv4argnmx7i4i0lvglnh7ll-libcxx-16.0.6/lib --extra-include-dirs=/nix/store/s6hsrbxn6wfws552x9jbn4agjz71ps3x-libcxxabi-16.0.6-dev/include --extra-lib-dirs=/nix/store/g9x4r8l8hjk3vfj26k90p3rjc6g8j3i6-libcxxabi-16.0.6/lib --extra-include-dirs=/nix/store/rbjxdnzf9kc1in1n1ca7phddg80h55xd-compiler-rt-libc-16.0.6-dev/include --extra-lib-dirs=/nix/store/v7rhm5d36dn6bgcbdc4w3dg8ym3vxb5d-compiler-rt-libc-16.0.6/lib --extra-lib-dirs=/nix/store/7y2jn8rdygiy22rzy66wsz4gvrfn5hh6-apple-framework-CoreFoundation-11.0.0/lib --extra-framework-dirs=/nix/store/7y2jn8rdygiy22rzy66wsz4gvrfn5hh6-apple-framework-CoreFoundation-11.0.0/Library/Frameworks --extra-include-dirs=/nix/store/cii11dfrz126yb3d03aqyahwq3fanl1g-libobjc-11.0.0/include --extra-lib-dirs=/nix/store/cii11dfrz126yb3d03aqyahwq3fanl1g-libobjc-11.0.0/lib
Using Parsec parser
Configuring clock-0.8.4...
Flags chosen: llvm=False
Dependency base >=4.7 && <5: using base-4.18.2.0
Source component graph: component lib
Configured component graph:
    component clock-0.8.4-GWdt9eQOakoIoTGtE10Wmd include base-4.18.2.0
Linked component graph:
    unit clock-0.8.4-GWdt9eQOakoIoTGtE10Wmd
        include base-4.18.2.0
        System.Clock=clock-0.8.4-GWdt9eQOakoIoTGtE10Wmd:System.Clock,System.Clock.Seconds=clock-0.8.4-GWdt9eQOakoIoTGtE10Wmd:System.Clock.Seconds
Ready component graph:
    definite clock-0.8.4-GWdt9eQOakoIoTGtE10Wmd depends base-4.18.2.0
Using Cabal-3.10.1.0 compiled by ghc-9.6
Using compiler: ghc-9.6.4
Using install prefix: /nix/store/5m4jz8iznpbg7n407fzihxb1vly26jjx-clock-0.8.4
Executables installed in:
/nix/store/5m4jz8iznpbg7n407fzihxb1vly26jjx-clock-0.8.4/bin
Libraries installed in:
/nix/store/5m4jz8iznpbg7n407fzihxb1vly26jjx-clock-0.8.4/lib/ghc-9.6.4/lib/aarch64-osx-ghc-9.6.4/clock-0.8.4-GWdt9eQOakoIoTGtE10Wmd
Dynamic Libraries installed in:
/nix/store/5m4jz8iznpbg7n407fzihxb1vly26jjx-clock-0.8.4/lib/ghc-9.6.4/lib/aarch64-osx-ghc-9.6.4
Private executables installed in:
/nix/store/5m4jz8iznpbg7n407fzihxb1vly26jjx-clock-0.8.4/libexec/aarch64-osx-ghc-9.6.4/clock-0.8.4
Data files installed in:
/nix/store/5m4jz8iznpbg7n407fzihxb1vly26jjx-clock-0.8.4/share/aarch64-osx-ghc-9.6.4/clock-0.8.4
Documentation installed in:
/nix/store/5m4jz8iznpbg7n407fzihxb1vly26jjx-clock-0.8.4/share/doc/aarch64-osx-ghc-9.6.4/clock-0.8.4
Configuration files installed in:
/nix/store/5m4jz8iznpbg7n407fzihxb1vly26jjx-clock-0.8.4/etc
No alex found
Using ar found on system at:
/nix/store/0m04cmy32vs1686pzjqajsh50arbv8m4-clang-wrapper-16.0.6/bin/ar
No c2hs found
No cpphs found
No doctest found
Using gcc version 16.0.6 given by user at:
/nix/store/0m04cmy32vs1686pzjqajsh50arbv8m4-clang-wrapper-16.0.6/bin/clang
Using ghc version 9.6.4 found on system at:
/nix/store/j1r1hnfk0zn4k44nm6m4a27nka35649n-ghc-binary-9.6.4/bin/ghc
Using ghc-pkg version 9.6.4 found on system at:
/nix/store/j1r1hnfk0zn4k44nm6m4a27nka35649n-ghc-binary-9.6.4/bin/ghc-pkg-9.6.4
No ghcjs found
No ghcjs-pkg found
No greencard found
Using haddock version 2.29.2 found on system at:
/nix/store/j1r1hnfk0zn4k44nm6m4a27nka35649n-ghc-binary-9.6.4/bin/haddock-ghc-9.6.4
No happy found
Using haskell-suite found on system at: haskell-suite-dummy-location
Using haskell-suite-pkg found on system at: haskell-suite-pkg-dummy-location
No hmake found
Using hpc version 0.68 found on system at:
/nix/store/j1r1hnfk0zn4k44nm6m4a27nka35649n-ghc-binary-9.6.4/bin/hpc-ghc-9.6.4
Using hsc2hs version 0.68.9 found on system at:
/nix/store/j1r1hnfk0zn4k44nm6m4a27nka35649n-ghc-binary-9.6.4/bin/hsc2hs-ghc-9.6.4
Using hscolour version 1.25 found on system at:
/nix/store/7xjz96ia05q1z8v6jxdmlvrz87nh5l1j-hscolour-1.25/bin/HsColour
No jhc found
Using ld found on system at:
/nix/store/0m04cmy32vs1686pzjqajsh50arbv8m4-clang-wrapper-16.0.6/bin/ld
No pkg-config found
Using runghc version 9.6.4 found on system at:
/nix/store/j1r1hnfk0zn4k44nm6m4a27nka35649n-ghc-binary-9.6.4/bin/runghc-9.6.4
Using strip found on system at:
/nix/store/0m04cmy32vs1686pzjqajsh50arbv8m4-clang-wrapper-16.0.6/bin/strip
Using tar found on system at:
/nix/store/h9hn3zrjcdf2ck1fp9agis9f1d6rphcw-gnutar-1.35/bin/tar
No uhc found
@nix { "action": "setPhase", "phase": "buildPhase" }
Running phase: buildPhase
Preprocessing library for clock-0.8.4..
linking dist/build/System/Clock_hsc_make.o failed (exit code 1)
rsp file was: "dist/build/System/hsc2hscall78565-2.rsp"
command was: /nix/store/0m04cmy32vs1686pzjqajsh50arbv8m4-clang-wrapper-16.0.6/bin/clang dist/build/System/Clock_hsc_make.o dist/build/System/Clock_hsc_utils.o -o dist/build/System/Clock_hsc_make --target=arm64-apple-darwin -Wl,-no_fixup_chains -Wl,-no_warn_duplicate_libraries --target=arm64-apple-darwin -L/nix/store/j3yw5w8pbdv4argnmx7i4i0lvglnh7ll-libcxx-16.0.6/lib -L/nix/store/g9x4r8l8hjk3vfj26k90p3rjc6g8j3i6-libcxxabi-16.0.6/lib -L/nix/store/v7rhm5d36dn6bgcbdc4w3dg8ym3vxb5d-compiler-rt-libc-16.0.6/lib -L/nix/store/7y2jn8rdygiy22rzy66wsz4gvrfn5hh6-apple-framework-CoreFoundation-11.0.0/lib -L/nix/store/cii11dfrz126yb3d03aqyahwq3fanl1g-libobjc-11.0.0/lib -L/nix/store/j1r1hnfk0zn4k44nm6m4a27nka35649n-ghc-binary-9.6.4/lib/ghc-9.6.4/lib/../lib/aarch64-osx-ghc-9.6.4/base-4.18.2.0 -L/nix/store/n7hyb4xfwjdcm87gbisck8pl9c2mp1qs-libiconv-50/lib -liconv -L/nix/store/j1r1hnfk0zn4k44nm6m4a27nka35649n-ghc-binary-9.6.4/lib/ghc-9.6.4/lib/../lib/aarch64-osx-ghc-9.6.4/ghc-bignum-1.3 -L/nix/store/5kg229dp8nb6a2m0hv7g1zl725kxp0nn-gmp-with-cxx-6.3.0/lib -L/nix/store/j1r1hnfk0zn4k44nm6m4a27nka35649n-ghc-binary-9.6.4/lib/ghc-9.6.4/lib/../lib/aarch64-osx-ghc-9.6.4/ghc-prim-0.10.0 -L/nix/store/0z3mx40zc1b2zf8yjlrkk0iyps3yxlil-libffi-3.4.6/lib -L/nix/store/j1r1hnfk0zn4k44nm6m4a27nka35649n-ghc-binary-9.6.4/lib/ghc-9.6.4/lib/../lib/aarch64-osx-ghc-9.6.4/rts-1.0.2 -L/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/lib -lm -ldl -lffi
error: ld: unknown option: -no_fixup_chains
clang-16: error: linker command failed with exit code 1 (use -v to see invocation)

Nix Stacktrace:

error: 1 dependencies of derivation '/nix/store/qyxlaayrlfakgl82ijcqnny8y54r1nx6-extra-1.7.14.drv' failed to build
error: 1 dependencies of derivation '/nix/store/nrc4kswi5sjmk8s4ga0pf6hk3a315ib2-hadrian-9.8.2.drv' failed to build
error: 1 dependencies of derivation '/nix/store/n4w4wfnfzdwrfjhjmj103is4kbfw82dd-ghc-9.8.2.drv' failed to build
error: 1 dependencies of derivation '/nix/store/c4jv6as353pz4r6jby0mrsmz52mwl6ja-ghc-9.8.2-with-packages.drv' failed to build
error: 1 dependencies of derivation '/nix/store/kn74amwb539g2hqsygndnn4vahkxyfp1-devenv-profile.drv' failed to build
error: 1 dependencies of derivation '/nix/store/98f9r5hhkal51wi1xj89q9yczd4ffhxf-devenv-shell-env.drv' failed to build

@mpscholten
Copy link
Contributor Author

I've created a PR with the ghc 9.6.4 binary at #297418

@maralorn
Copy link
Member

I have no much stakes in darwin, nor am I very knowledgeable about our ghc builds. But I agree if we can ghc-binary 9.6.4 to work that would be a desirable solution.

@sternenseemann
Copy link
Member

#297804

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
6.topic: haskell 8.has: package (new) This PR adds a new package 10.rebuild-darwin: 1-10 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.

4 participants