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

stack hangs while linking (lld) with ghc 8.4+ #4433

Closed
Keruspe opened this issue Dec 6, 2018 · 35 comments
Closed

stack hangs while linking (lld) with ghc 8.4+ #4433

Keruspe opened this issue Dec 6, 2018 · 35 comments

Comments

@Keruspe
Copy link

Keruspe commented Dec 6, 2018

General summary/comments (optional)

I'm using stack 1.9.3 and have a project using lts-11.22.
I tried updating it to lts-12 (lts-12.0 and lts-12.21 ends up with the same problem) and stack just hangs when linking the StackSetupShim

Steps to reproduce

Update from lts-11.22 to lts-12.21
Run stack build

Expected

Build success

Actual

$ stack build
Linking /home/keruspe/.stack/setup-exe-cache/x86_64-linux-tinfo6/tmp-Cabal-simple_mPHDZzAJ_2.2.0.1_ghc-8.4.4 ...

hangs forever

Stack version

$ stack --version
Version 1.9.3, Git revision 40cf7b37526b86d1676da82167ea8758a854953b (6211 commits) x86_64 hpack-0.31.1

Method of installation

  • Official binary, downloaded from stackage.org
@mattaudesse
Copy link
Member

Hey @Keruspe - thanks for the report.

I haven't been able to replicate the problem but I wonder if it's because I'm missing some important detail.

The following worked for me with a fresh project on Debian Linux - does following the same steps fail for you?

stack --resolver lts-11.22 new test
cd test
stack build
stack --resolver lts-12.21 build

Any other specifics you can share that might be relevant? What Linux distro are you using?

If your code is public I don't mind trying again running against your repo if you'd like to share a link.

@Keruspe
Copy link
Author

Keruspe commented Dec 10, 2018

I'm running Exherbo.
Problem is reproducible with any project, see:

keruspe@Lou /tmp/stack % stack --resolver lts-11.22 new test                                                                                                                                                                     
Downloading template "new-template" to create project "test" in test/ ...

The following parameters were needed by the template but not provided: category
You can provide them in /home/keruspe/.stack/config.yaml, like this:
templates:
  params:
    category: value
Or you can pass each one as parameters like this:
stack new test new-template -p "category:value"

Looking for .cabal or package.yaml files to use to init the project.
Using cabal packages:
- test/

Selected resolver: lts-11.22
Initialising configuration using resolver: lts-11.22
Total number of user packages considered: 1
Writing configuration to file: test/stack.yaml
All done.
keruspe@Lou /tmp/stack % cd test                                                                                                                                                                                                 
keruspe@Lou /tmp/stack/test % stack build                                                                                                                                                                                        
Building all executables for `test' once. After a successful build of all of them, only specified executables will be rebuilt.
test-0.1.0.0: configure (lib + exe)
Configuring test-0.1.0.0...
test-0.1.0.0: build (lib + exe)
Preprocessing library for test-0.1.0.0..
Building library for test-0.1.0.0..
[1 of 2] Compiling Lib              ( src/Lib.hs, .stack-work/dist/x86_64-linux-ncurses6/Cabal-2.0.1.0/build/Lib.o )
[2 of 2] Compiling Paths_test       ( .stack-work/dist/x86_64-linux-ncurses6/Cabal-2.0.1.0/build/autogen/Paths_test.hs, .stack-work/dist/x86_64-linux-ncurses6/Cabal-2.0.1.0/build/Paths_test.o )
Preprocessing executable 'test-exe' for test-0.1.0.0..
Building executable 'test-exe' for test-0.1.0.0..
[1 of 2] Compiling Main             ( app/Main.hs, .stack-work/dist/x86_64-linux-ncurses6/Cabal-2.0.1.0/build/test-exe/test-exe-tmp/Main.o )
[2 of 2] Compiling Paths_test       ( .stack-work/dist/x86_64-linux-ncurses6/Cabal-2.0.1.0/build/test-exe/autogen/Paths_test.hs, .stack-work/dist/x86_64-linux-ncurses6/Cabal-2.0.1.0/build/test-exe/test-exe-tmp/Paths_test.o )
Linking .stack-work/dist/x86_64-linux-ncurses6/Cabal-2.0.1.0/build/test-exe/test-exe ...
test-0.1.0.0: copy/register
Installing library in /tmp/stack/test/.stack-work/install/x86_64-linux-ncurses6/lts-11.22/8.2.2/lib/x86_64-linux-ghc-8.2.2/test-0.1.0.0-LK8fulHuYNc5gAYF1YHqqE
Installing executable test-exe in /tmp/stack/test/.stack-work/install/x86_64-linux-ncurses6/lts-11.22/8.2.2/bin
Registering library for test-0.1.0.0..
keruspe@Lou /tmp/stack/test % stack --resolver lts-12.21 build                                                                                                                                                                   
Linking /home/keruspe/.stack/setup-exe-cache/x86_64-linux-tinfo6/tmp-Cabal-simple_mPHDZzAJ_2.2.0.1_ghc-8.4.4 ...

@dbaynard
Copy link
Contributor

I can't reproduce in a tmp directory on arch

@dbaynard
Copy link
Contributor

@Keruspe Would you run again with --verbose and paste the output here (wrapped with <details></details>) please?

@Keruspe
Copy link
Author

Keruspe commented Dec 10, 2018

Here we go:

Version 1.9.3, Git revision 40cf7b37526b86d1676da82167ea8758a854953b (6211 commits) x86_64 hpack-0.31.1
2018-12-10 18:00:33.987175: [debug] Checking for project config at: /tmp/stack/test/stack.yaml
2018-12-10 18:00:33.987328: [debug] Loading project config file stack.yaml
2018-12-10 18:00:33.988940: [debug] Using resolver: lts-12.21 specified on command line
2018-12-10 18:00:33.989139: [debug] Decoding build plan from: /home/keruspe/.stack/build-plan/lts-12.21.yaml
2018-12-10 18:00:33.989170: [debug] Trying to decode /home/keruspe/.stack/build-plan-cache/lts-12.21.cache
2018-12-10 18:00:34.028757: [debug] Success decoding /home/keruspe/.stack/build-plan-cache/lts-12.21.cache
2018-12-10 18:00:34.029406: [debug] Run process: /sbin/ldconfig -p
2018-12-10 18:00:34.031481: [debug] Process finished in 2ms: /sbin/ldconfig -p
2018-12-10 18:00:34.032270: [debug] Did not find shared library libtinfo.so.5
2018-12-10 18:00:34.032408: [debug] Found shared library libtinfo.so.6 in /usr/lib
2018-12-10 18:00:34.032441: [debug] Found shared library libncursesw.so.6 in 'ldconfig -p' output
2018-12-10 18:00:34.032551: [debug] Found shared library libgmp.so.10 in 'ldconfig -p' output
2018-12-10 18:00:34.032601: [debug] Did not find shared library libgmp.so.3
2018-12-10 18:00:34.032684: [debug] Potential GHC builds: tinfo6, ncurses6
2018-12-10 18:00:34.032751: [debug] Found already installed GHC builds: tinfo6
2018-12-10 18:00:34.033310: [debug] Getting global package database location
2018-12-10 18:00:34.033874: [debug] Getting Cabal package version
2018-12-10 18:00:34.033928: [debug] Run process: /home/keruspe/.stack/programs/x86_64-linux/ghc-tinfo6-8.4.4/bin/ghc-pkg --no-user-package-db list --global
2018-12-10 18:00:34.034411: [debug] Asking GHC for its version
2018-12-10 18:00:34.034745: [debug] Run process: /home/keruspe/.stack/programs/x86_64-linux/ghc-tinfo6-8.4.4/bin/ghc-pkg --no-user-package-db field --simple-output Cabal version
2018-12-10 18:00:34.035509: [debug] Run process: /home/keruspe/.stack/programs/x86_64-linux/ghc-tinfo6-8.4.4/bin/ghc --numeric-version
2018-12-10 18:00:34.226872: [debug] Process finished in 193ms: /home/keruspe/.stack/programs/x86_64-linux/ghc-tinfo6-8.4.4/bin/ghc-pkg --no-user-package-db list --global
2018-12-10 18:00:34.228562: [debug] Process finished in 194ms: /home/keruspe/.stack/programs/x86_64-linux/ghc-tinfo6-8.4.4/bin/ghc-pkg --no-user-package-db field --simple-output Cabal version
2018-12-10 18:00:34.266709: [debug] Process finished in 231ms: /home/keruspe/.stack/programs/x86_64-linux/ghc-tinfo6-8.4.4/bin/ghc --numeric-version
2018-12-10 18:00:34.266778: [debug] GHC version is: ghc-8.4.4
2018-12-10 18:00:34.266887: [debug] Resolving package entries
2018-12-10 18:00:34.266968: [debug] Trying to decode /home/keruspe/.stack/loaded-snapshot-cache/x86_64-linux/ghc-8.4.4/lts-12.21.cache
2018-12-10 18:00:34.301512: [debug] Success decoding /home/keruspe/.stack/loaded-snapshot-cache/x86_64-linux/ghc-8.4.4/lts-12.21.cache
2018-12-10 18:00:34.302330: [debug] Run process: /home/keruspe/.stack/programs/x86_64-linux/ghc-tinfo6-8.4.4/bin/ghc-pkg init /tmp/stack/test/.stack-work/install/x86_64-linux-tinfo6/lts-12.21/8.4.4/pkgdb/
2018-12-10 18:00:34.318864: [debug] Process finished in 16ms: /home/keruspe/.stack/programs/x86_64-linux/ghc-tinfo6-8.4.4/bin/ghc-pkg init /tmp/stack/test/.stack-work/install/x86_64-linux-tinfo6/lts-12.21/8.4.4/pkgdb/
2018-12-10 18:00:34.319966: [debug] Starting to execute command inside EnvConfig
2018-12-10 18:00:34.320098: [debug] Parsing the targets
2018-12-10 18:00:34.320355: [debug] Running hpack on /tmp/stack/test/package.yaml
2018-12-10 18:00:34.323354: [debug] hpack output unchanged in /tmp/stack/test/test.cabal
2018-12-10 18:00:34.339661: [debug] Start: getPackageFiles /tmp/stack/test/test.cabal
2018-12-10 18:00:34.341358: [debug] Finished in 2ms: getPackageFiles /tmp/stack/test/test.cabal
2018-12-10 18:00:34.341483: [debug] Exception ignored when attempting to load /tmp/stack/test/.stack-work/dist/x86_64-linux-tinfo6/Cabal-2.2.0.1/stack-build-caches/lib: /tmp/stack/test/.stack-work/dist/x86_64-linux-tinfo6/Cabal-2.2.0.1/stack-build-caches/lib: openBinaryFile: does not exist (No such file or directory)
2018-12-10 18:00:34.341832: [debug] Exception ignored when attempting to load /tmp/stack/test/.stack-work/dist/x86_64-linux-tinfo6/Cabal-2.2.0.1/stack-build-caches/exe-test-exe: /tmp/stack/test/.stack-work/dist/x86_64-linux-tinfo6/Cabal-2.2.0.1/stack-build-caches/exe-test-exe: openBinaryFile: does not exist (No such file or directory)
2018-12-10 18:00:34.342253: [debug] Finding out which packages are already installed
2018-12-10 18:00:34.342466: [debug] Run process: /home/keruspe/.stack/programs/x86_64-linux/ghc-tinfo6-8.4.4/bin/ghc-pkg --global --no-user-package-db dump --expand-pkgroot
2018-12-10 18:00:34.382782: [debug] Process finished in 40ms: /home/keruspe/.stack/programs/x86_64-linux/ghc-tinfo6-8.4.4/bin/ghc-pkg --global --no-user-package-db dump --expand-pkgroot
2018-12-10 18:00:34.383247: [debug] Ignoring package haskeline due to wanting version 0.7.4.3 instead of 0.7.4.2
2018-12-10 18:00:34.383767: [debug] Run process: /home/keruspe/.stack/programs/x86_64-linux/ghc-tinfo6-8.4.4/bin/ghc-pkg --user --no-user-package-db --package-db /home/keruspe/.stack/snapshots/x86_64-linux-tinfo6/lts-12.21/8.4.4/pkgdb dump --expand-pkgroot
2018-12-10 18:00:34.406710: [debug] Process finished in 23ms: /home/keruspe/.stack/programs/x86_64-linux/ghc-tinfo6-8.4.4/bin/ghc-pkg --user --no-user-package-db --package-db /home/keruspe/.stack/snapshots/x86_64-linux-tinfo6/lts-12.21/8.4.4/pkgdb dump --expand-pkgroot
2018-12-10 18:00:34.406812: [debug] Run process: /home/keruspe/.stack/programs/x86_64-linux/ghc-tinfo6-8.4.4/bin/ghc-pkg --user --no-user-package-db --package-db /tmp/stack/test/.stack-work/install/x86_64-linux-tinfo6/lts-12.21/8.4.4/pkgdb dump --expand-pkgroot
2018-12-10 18:00:34.438074: [debug] Process finished in 31ms: /home/keruspe/.stack/programs/x86_64-linux/ghc-tinfo6-8.4.4/bin/ghc-pkg --user --no-user-package-db --package-db /tmp/stack/test/.stack-work/install/x86_64-linux-tinfo6/lts-12.21/8.4.4/pkgdb dump --expand-pkgroot
2018-12-10 18:00:34.438420: [debug] Constructing the build plan
2018-12-10 18:00:34.439220: [debug] Checking if we are going to build multiple executables with the same name
2018-12-10 18:00:34.439289: [debug] Executing the build plan
2018-12-10 18:00:34.440316: [debug] Run process within /tmp/stack4573/: /home/keruspe/.stack/programs/x86_64-linux/ghc-tinfo6-8.4.4/bin/ghc -rtsopts -threaded -clear-package-db -global-package-db -hide-all-packages -package base -main-is StackSetupShim.mainOverride -package Cabal-2.2.0.1 /home/keruspe/.stack/setup-exe-src/setup-mPHDZzAJ.hs /home/keruspe/.stack/setup-exe-src/setup-shim-mPHDZzAJ.hs -o /home/keruspe/.stack/setup-exe-cache/x86_64-linux-tinfo6/tmp-Cabal-simple_mPHDZzAJ_2.2.0.1_ghc-8.4.4
Linking /home/keruspe/.stack/setup-exe-cache/x86_64-linux-tinfo6/tmp-Cabal-simple_mPHDZzAJ_2.2.0.1_ghc-8.4.4 ...

@dbaynard
Copy link
Contributor

How long does it hang?

You may want to try another linker — see https://stackoverflow.com/a/43243323 — and see whether it is a linker issue.

@Keruspe
Copy link
Author

Keruspe commented Dec 10, 2018

It hangs forever, never seen it timeout or whatever (let it ran for 3h once)

@Keruspe
Copy link
Author

Keruspe commented Dec 10, 2018

Looks the same with gold and lld.

Fwiw:

keruspe@Lou ~ % gcc --version                                                   
gcc (GCC) 8.2.0
Copyright (C) 2018 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

keruspe@Lou ~ % ld.gold --version                                               
GNU gold (GNU Binutils 2.31.1) 1.16
Copyright (C) 2018 Free Software Foundation, Inc.
This program is free software; you may redistribute it under the terms of
the GNU General Public License version 3 or (at your option) a later version.
This program has absolutely no warranty.

keruspe@Lou ~ % ld.lld --version       
LLD 7.0.0 (compatible with GNU linkers)

@dbaynard
Copy link
Contributor

And running a stack clean or a stack clean --full between switches?

@Keruspe
Copy link
Author

Keruspe commented Dec 10, 2018

stack clean --full ends up with the same result

@dbaynard
Copy link
Contributor

dbaynard commented Dec 10, 2018

And if you don't do it in a subdir of tmp/?
And does lts-12 work at all on your machine?

It's looking like a platform issue, at the moment — given we can't reproduce, I'm not quite sure what other help we can give, until you can isolate further.

@Keruspe
Copy link
Author

Keruspe commented Dec 10, 2018

No, lts-12 doesn't work at all on my machine.

How can I find out why it's hanging?

@dbaynard
Copy link
Contributor

It could well be a cabal 2.2/ghc 8.4 issue. Try stackage nightly?

@dbaynard
Copy link
Contributor

Also try installing that ghc through your distro — there are lots of things to try, to isolate the issue. If it is with stack, we'll try to fix it — but right now that's far from obvious.

@Keruspe
Copy link
Author

Keruspe commented Dec 11, 2018

Nightly has the same issue fwiw, will try another ghc to see how it behaves

@Keruspe
Copy link
Author

Keruspe commented Dec 11, 2018

With stackage nightly and ghc 8.6.2 downloaded from fedora, it works

@Keruspe
Copy link
Author

Keruspe commented Dec 11, 2018

Ok, so I nuked all my ~/.stack to begin in a clean state.
Ran stack build on a project with lts-12.22 selected.
Got the same issue.
Edited ~/.stack/programs/x86_64-linux/ghc-tinfo6-8.4.4/lib/ghc-8.4.4/settings to change -fuse-ld=ldd into -fuse-ld=bfd and the ld command from ld.lld to ld.bfd and now it works.
There seem to be a problem with lld usage, and somehow stack picked it as default.

@mattaudesse
Copy link
Member

Cool, thanks for tracking down those details @Keruspe.

@dbaynard
Copy link
Contributor

Glad you've got it working — I'll see whether anybody else has any ideas for a fix.

@dbaynard dbaynard changed the title stack hangs after switching from lts-11 to lts-12 stack hangs while linking (lld) with ghc 8.4+ Dec 11, 2018
@snoyberg
Copy link
Contributor

This appears to me to be an upstream problem with either GHC or the system linker. @Keruspe are you able to reproduce this frozen linking with a direct call to the ghc executable?

@Keruspe
Copy link
Author

Keruspe commented Apr 17, 2019

Is there a 1.9.4 planned at some point?

@snoyberg
Copy link
Contributor

Not right now, no. Is that query related to this discussion? I didn't see any mention of changes to Stack.

@Keruspe
Copy link
Author

Keruspe commented Apr 17, 2019

I don't know, just saw this issue be closed by a commit to stack

@snoyberg
Copy link
Contributor

Oh, that's my mistake, I put the wrong issue number in that commit.

@snoyberg snoyberg reopened this Apr 17, 2019
@snoyberg
Copy link
Contributor

That said, I do believe this is an upstream issue that we are going to close, but still waiting for your response to the question above.

@Keruspe
Copy link
Author

Keruspe commented Apr 17, 2019

Heh, since reporting this issue I switched my system ld to lld and now I cannot seem to be able to reproduce...
I still can reproduce on some server, I'll do some testing tomorrow

@snoyberg
Copy link
Contributor

Any update?

@Keruspe
Copy link
Author

Keruspe commented Apr 25, 2019

Hangs when running ghc manually too.
Is there a reason why stack decides to try and decide which ld implementation to use instead of just using the system ld by default (and still give the ability to users to override that in the json config)?
If it did just that I wouldn't have this problem

@snoyberg
Copy link
Contributor

Is there a reason why stack decides to try and decide which ld implementation to use instead of just using the system ld by default (and still give the ability to users to override that in the json config)?

I'm not aware of Stack trying to do that. If this occurs with GHC directly as well, this sounds like behavior occurring in GHC, not Stack.

@Keruspe
Copy link
Author

Keruspe commented Apr 28, 2019

Isn't stack responsible for generating e.g. ~/.stack/programs/x86_64-linux/ghc-tinfo6-8.6.4/lib/ghc-8.6.4/settings?

@snoyberg
Copy link
Contributor

No, that's created by the GHC configure script, Stack simply runs it.

@Keruspe
Copy link
Author

Keruspe commented Apr 28, 2019

Oh, my bad then, that's definitely what needs fixing then

@snoyberg
Copy link
Contributor

Please open an issue upstream with GHC if you want to pursue this. Closing as upstream

@Keruspe
Copy link
Author

Keruspe commented May 24, 2019

@snoyberg Would that be acceptable for stack to pass --disable-ld-override to ghc configure as a workaround? (or is there already a way to tell stack to do that in some config file?)

@snoyberg
Copy link
Contributor

If GHC has the wrong default, I'd rather see it fixed in GHC, rather than having Stack override GHC's settings. I don't think Stack currently has the ability to let the user pass parameters to GHC's configure script, but that seems like a worthwhile addition.

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

No branches or pull requests

4 participants