Skip to content

Allow using GHC with ld.lld #2391

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

Merged
merged 1 commit into from
Jun 19, 2025

Conversation

TeofilC
Copy link
Contributor

@TeofilC TeofilC commented Jun 18, 2025

We need to add llvmPackages.bintools to the nativeBuildInputs of builders when using this and we need to configure GHC to use ld.lld.

Resolves #2317

@TeofilC TeofilC force-pushed the wip/useLdLld branch 2 times, most recently from d199096 to bf7a53d Compare June 18, 2025 18:26
We need to add llvmPackages.bintools to the nativeBuildInputs of
builders when using this and we need to configure GHC to use ld.lld.
@TeofilC TeofilC marked this pull request as ready for review June 19, 2025 17:31
@hamishmack hamishmack merged commit cd01875 into input-output-hk:master Jun 19, 2025
37 of 6266 checks passed
@purefn
Copy link
Contributor

purefn commented Jun 20, 2025

This is great, thanks! What's the best way to enable it for use with pkgs.haskell-nix.project'? Right now it looks like it would require using an overlay to override the useLdLld setting in pkgs.haskell-nix.compiler.ghcXXX. Is there an easier way that would apply it to all versions of ghc - we build with ghc96, ghc910, and ghc912, so having an easy way of setting it for all of them would be great.

@TeofilC TeofilC deleted the wip/useLdLld branch June 21, 2025 11:12
@TeofilC
Copy link
Contributor Author

TeofilC commented Jun 21, 2025

@purefn The way I have been doing this is by just adding a commit to our fork that always enables it like so: circuithub@bf4b789

There is probably a better way to do it, but this is the easiest thing to do so that's what I've been doing 😅

I'll leave the job of adding a nicer interface to access this to someone else.

@purefn
Copy link
Contributor

purefn commented Jun 23, 2025

I think I found an easier way to do that.

  project = haskell-nix.project' ({config, ...}: {

    compilerSelection = p: builtins.mapAttrs (_: x: x.override { hadrianEvalPackages = config.evalPackages; useLdLld = true; }) p.haskell-nix.compiler;

But it doesn't seem to work on macOS.

ghc> checking for arm64-apple-darwin-ld... /nix/store/3py6dyxg2h95vlba8dil3anhighi0dqj-llvm-binutils-wrapper-15.0.7/bin/ld.lld
ghc> checking for arm64-apple-darwin-nm... /nix/store/idmz24ps83r9mz2hkxdqwv6y4v2v7x28-cctools-binutils-darwin-1010.6/bin/nm
ghc> checking whether nm program is broken... no
ghc> configure: Setting cmd
ghc> checking for ld.gold object merging bug (binutils 22266)... ld.lld: error: unknown argument '-platform_version'
ghc> ld.lld: error: unknown argument '-no_dtrace_dof'
ghc> configure: Checking whether /nix/store/3py6dyxg2h95vlba8dil3anhighi0dqj-llvm-binutils-wrapper-15.0.7/bin/ld.lld can merge objects
ghc> ld.lld: error: unknown argument '-platform_version'
ghc> ld.lld: error: unknown argument '-no_dtrace_dof'
ghc> ld.lld: error: cannot open macos: No such file or directory
ghc> ld.lld: error: cannot open 11.3: No such file or directory
ghc> ld.lld: error: cannot open 11.3: No such file or directory
ghc> ld.lld: error: conftesta.o: unknown file type
ghc> ld.lld: error: conftestb.o: unknown file type
ghc> configure: error:  /nix/store/3py6dyxg2h95vlba8dil3anhighi0dqj-llvm-binutils-wrapper-15.0.7/bin/ld.lld could not merge objects

Is this something that will only work on Linux? Sorry, not up to date on my linkers.

@TeofilC
Copy link
Contributor Author

TeofilC commented Jun 23, 2025

Nice!

Sorry I have no idea about linkers on MacOS

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Using lld as our linker
3 participants