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

GHC does not compile on pkgsMusl after the ld.gold change #84670

Closed
utdemir opened this issue Apr 7, 2020 · 12 comments · Fixed by pbogdan/nix-hie#81
Closed

GHC does not compile on pkgsMusl after the ld.gold change #84670

utdemir opened this issue Apr 7, 2020 · 12 comments · Fixed by pbogdan/nix-hie#81

Comments

@utdemir
Copy link
Member

utdemir commented Apr 7, 2020

Describe the bug

GHC does not compile on pkgsMusl anymore, after #80466 is merged, failing with this error:

...
checking for dllwrap... no
checking for -objdump... objdump
checking for x86_64-unknown-linux-musl-gcc... /nix/store/wv11dyp6p1sk8il4wxqn3rd9bclhf9m8-gcc-wrapper-9.2.0/bin/cc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... configure: error: in `/tmp/nix-build-ghc-8.6.5.drv-0/ghc-8.6.5':
configure: error: cannot run C compiled programs.
If you meant to cross compile, use `--host'.
See `config.log' for more details
builder for '/nix/store/ydqgcy4yahnlahbazhj9r69j7ijwvnb3-ghc-8.6.5.drv' failed with exit code 1
17403: failed: NixPermanentFailure builder for '/nix/store/ydqgcy4yahnlahbazhj9r69j7ijwvnb3-ghc-8.6.5.drv' failed with exit code 1
error: build of '/nix/store/ydqgcy4yahnlahbazhj9r69j7ijwvnb3-ghc-8.6.5.drv' on 'ssh://nxb-4' failed: builder for '/nix/store/ydqgcy4yahnlahbazhj9r69j7ijwvnb3-ghc-8.6.5.drv' failed with exit code 1
builder for '/nix/store/ydqgcy4yahnlahbazhj9r69j7ijwvnb3-ghc-8.6.5.drv' failed with exit code 1
error: build of '/nix/store/ydqgcy4yahnlahbazhj9r69j7ijwvnb3-ghc-8.6.5.drv' failed

To Reproduce

$ nix-build -A pkgsMusl.haskell.packages.ghc865.ghc

I only confirmed ghc865 to be caused by the commit I mentioned. GHC 8.8 and GHC 8.10 also doesn't compile with pkgsMusl currently, but I don't know if this exact commit is the cause since compiling them takes a long time.

Edit: I reproduced the issue also with ghc882 and ghc8101.

cc @peti @adamse @nh2

@nh2
Copy link
Contributor

nh2 commented Apr 7, 2020

I have also seen this failure. I also believe to have posted about it on some issue, but not sure which one it was (and maybe my message did not get submitted successfully).

@domenkozar
Copy link
Member

Does musl support gold linker?

@utdemir
Copy link
Member Author

utdemir commented Apr 7, 2020

Looks relevant: #49071 (ld.gold crashes or produces invalid executables when Musl is used as a libc)

@adamse
Copy link
Contributor

adamse commented Apr 8, 2020

If #49071 is still current it we should use -fpie (for compiling C) and -pie for linking? Or should we disable ld.gold whith musl libc?

Disabling ld.gold for musl seems like the simplest and least invasive option.

Thoughts?

adamse added a commit to adamse/nixpkgs that referenced this issue Apr 8, 2020
@Mic92
Copy link
Member

Mic92 commented Apr 8, 2020

A stacktrace/coredump might be helpful. You can get one with coredumpctl usually.

cdepillabout added a commit that referenced this issue Apr 9, 2020
ghc: do not use ld.gold with musl libc #84670
@cdepillabout
Copy link
Member

Hopefully fixed in #84741 by @adamse

peti pushed a commit that referenced this issue Apr 10, 2020
@nh2
Copy link
Contributor

nh2 commented Apr 10, 2020

Did you see that on my bug report on https://sourceware.org/bugzilla/show_bug.cgi?id=23856 somebody commented:

I've hit this on Alpine too and adding -fPIE to CFLAGS does indeed fix his.

Perhaps we could try that as well (I think that's what was suggested above)?

@bgamari do you have an opinion on that?

@adamse
Copy link
Contributor

adamse commented Apr 11, 2020

@nh2, that was indeed the other suggestion I meant above.

For the PIE solution, wouldn't that mean all Haskell programs built by this GHC would have to be PIE too or we'd have to use a different linker when using GHC?

@nh2
Copy link
Contributor

nh2 commented Apr 11, 2020

For the PIE solution, wouldn't that mean all Haskell programs built by this GHC would have to be PIE too or we'd have to use a different linker when using GHC?

I do not know the answer currently, but maybe somebody else does?

@bgamari
Copy link
Contributor

bgamari commented Apr 11, 2020

Indeed it sounds like the proposed workaround would be to link all executables with -fPIE. As a user given the choice between this workaround and falling back to BFD LD, I would probably prefer the former. gold is just that much faster.

@adamse
Copy link
Contributor

adamse commented Apr 11, 2020

Is it possible to instruct GHC to link with -fPIE by default?

@bgamari
Copy link
Contributor

bgamari commented Apr 13, 2020

Yes, IIRC you can set CONF_LD_LINKER_OPTS_STAGE2 when invoking ’configure’. The flags you pass should end up in the resulting compiler's ’settings’ file.

nomeata pushed a commit to dfinity-lab/nixpkgs that referenced this issue Jun 25, 2020
ld.gold doesn't play well with musl as is documented in NixOS#49071 and
https://sourceware.org/bugzilla/show_bug.cgi?id=23856

(cherry picked from commit 4675649)
nh2 pushed a commit to nh2/nixpkgs that referenced this issue Jul 23, 2020
ld.gold doesn't play well with musl as is documented in NixOS#49071 and
https://sourceware.org/bugzilla/show_bug.cgi?id=23856

(cherry picked from commit 4675649)
github-actions bot added a commit to pbogdan/nix-hie that referenced this issue Jul 25, 2020
## Motivation

Dependencies should be up to date.

## Changelog for stable:
Commits: [NixOS/nixpkgs@1975b868...0a40a399](NixOS/nixpkgs@1975b86...0a40a39)

* [`a7ce7241`](NixOS/nixpkgs@a7ce724) sqlite: 3.32.2 -> 3.32.3
* [`58f5c238`](NixOS/nixpkgs@58f5c23) openconnect: patch CVE-2020-12105 & CVE-2020-12823
* [`5c56247b`](NixOS/nixpkgs@5c56247) nixos-generators: 1.0.0 -> 1.1.0
* [`a7447ffc`](NixOS/nixpkgs@a7447ff) fontforge: 20190413 -> 20190801
* [`99b72d22`](NixOS/nixpkgs@99b72d2) fontforge: 20190801 -> 20200314
* [`ee1640dd`](NixOS/nixpkgs@ee1640d) ansible: v2.9.10 -> v2.9.11
* [`29f57d2f`](NixOS/nixpkgs@29f57d2) ansible_2_8: v2.8.12 -> v2.8.13
* [`e8e92a84`](NixOS/nixpkgs@e8e92a8) ghc: don't use ld.gold with musl libc (fixes NixOS/nixpkgs#84670)
* [`aea667b1`](NixOS/nixpkgs@aea667b) ghc: mention why ld.gold is disabled for musl libc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

8 participants