Closed rajcspsg closed 6 years ago
Hmm, I wonder what is so different about that setup. Not sure if this will work, but it might be worth trying LDFLAGS="-pthread" stack setup
or LDFLAGS="-lpthread"
.
@mgsloan I tried both the options but still I am getting same error.
@mgsloan . Looks like this issue is fixed. Now I'm able to stack set up in OpenSuse Tumbleweed 42.3. Stack version 1.6.1. I think this issue can be closed now.
Still present in Stack 1.6.5 (installed using on curl -sSL https://get.haskellstack.org/ | sh
) on Linux Mint 18.3 (based on Ubuntu 16.04 LTS).
I'm facing the same problem with version 1.6.1. I'm using solus
Stack version:
Version 1.6.1, Git revision f25811329bbc40b0c21053a8160c56f923e1201b (5435 commits) x86_64 hpack-0.20.0
Error:
stack setup
Preparing to install GHC to an isolated location.
This will not interfere with any system-level installation.
Downloaded ghc-8.2.2.
Installed GHC.
The GHC located at /home/rodolfo/.stack/programs/x86_64-linux/ghc-8.2.2/bin/ghc failed to compile a sanity check. Please see:
http://docs.haskellstack.org/en/stable/install_and_upgrade/
for more information. Exception was:
Running /home/rodolfo/.stack/programs/x86_64-linux/ghc-8.2.2/bin/ghc /tmp/stack-sanity-check24682/Main.hs -no-user-package-db in directory /tmp/stack-sanity-check24682/ exited with ExitFailure 1
[1 of 1] Compiling Main ( /tmp/stack-sanity-check24682/Main.hs, /tmp/stack-sanity-check24682/Main.o )
Linking /tmp/stack-sanity-check24682/Main ...
/usr/bin/ld.bfd: /home/rodolfo/.stack/programs/x86_64-linux/ghc-8.2.2/lib/ghc-8.2.2/rts/libHSrts.a(OSThreads.o): undefined reference to symbol 'pthread_setname_np@@GLIBC_2.12'
/usr/lib64/libpthread.so.0: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
`gcc' failed in phase `Linker'. (Exit code: 1)
I can also confirm this issue is still present in stack v1.6.5
$ stack --version
Version 1.6.5, Git revision 24ab0d6ff07f28276e082c3ce74dfdeb1a2ca9e9 (5514 commits) x86_64 hpack-0.20.0
$ LDFLAGS="-pthread" stack setup
The GHC located at /home/autopilot/.stack/programs/x86_64-linux/ghc-8.2.2/bin/ghc failed to compile a sanity check. Please see:
http://docs.haskellstack.org/en/stable/install_and_upgrade/
for more information. Exception was:
Running /home/autopilot/.stack/programs/x86_64-linux/ghc-8.2.2/bin/ghc /tmp/stack-sanity-check16592/Main.hs -no-user-package-db in directory /tmp/stack-sanity-check16592/ exited with ExitFailure 1
[1 of 1] Compiling Main ( /tmp/stack-sanity-check16592/Main.hs, /tmp/stack-sanity-check16592/Main.o )
Linking /tmp/stack-sanity-check16592/Main ...
/usr/bin/ld.bfd: /home/autopilot/.stack/programs/x86_64-linux/ghc-8.2.2/lib/ghc-8.2.2/rts/libHSrts.a(OSThreads.o): undefined reference to symbol 'pthread_setname_np@@GLIBC_2.12'
/usr/lib64/libpthread.so.0: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
`gcc' failed in phase `Linker'. (Exit code: 1)
$ LDFLAGS="-lpthread" stack setup
The GHC located at /home/autopilot/.stack/programs/x86_64-linux/ghc-8.2.2/bin/ghc failed to compile a sanity check. Please see:
http://docs.haskellstack.org/en/stable/install_and_upgrade/
for more information. Exception was:
Running /home/autopilot/.stack/programs/x86_64-linux/ghc-8.2.2/bin/ghc /tmp/stack-sanity-check16635/Main.hs -no-user-package-db in directory /tmp/stack-sanity-check16635/ exited with ExitFailure 1
[1 of 1] Compiling Main ( /tmp/stack-sanity-check16635/Main.hs, /tmp/stack-sanity-check16635/Main.o )
Linking /tmp/stack-sanity-check16635/Main ...
/usr/bin/ld.bfd: /home/autopilot/.stack/programs/x86_64-linux/ghc-8.2.2/lib/ghc-8.2.2/rts/libHSrts.a(OSThreads.o): undefined reference to symbol 'pthread_setname_np@@GLIBC_2.12'
/usr/lib64/libpthread.so.0: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
`gcc' failed in phase `Linker'. (Exit code: 1)
Possible workaround: in your stack.yaml
use the option resolver: ghc-8.4.1
. This bug seems not to manifest with this version of GHC.
UPDATE: The error below was due to $LD_LIBRARY_PATH
being set and not including the system directories. Adding them to $LD_LIBRARY_PATH
solved the issue.
I'm still seeing this on stack 1.7.1 even with resolver: nightly-2018-05-02
(which includes GHC 8.4.2).
In particular, I am seeing this when trying to build a Haskell package with stack
in conda
(which runs on a Centos 6 container).
The full error log is
Downloading nightly-2018-05-02 build plan ...
Downloaded nightly-2018-05-02 build plan.
Preparing to install GHC (gmp4) to an isolated location.
This will not interfere with any system-level installation.
Preparing to download ghc-gmp4-8.4.2 ...
ghc-gmp4-8.4.2: download has begun
[...]
ghc-gmp4-8.4.2: 132.33 MiB / 132.33 MiB (100.00%) downloaded...
Downloaded ghc-gmp4-8.4.2.
Unpacking GHC into /opt/conda/conda-bld/ngless_1525292274450/work/ngless-0.7.1/fake- home/.stack/programs/x86_64-linux/ghc-gmp4-8.4.2.temp/ ...
Configuring GHC ...
Installing GHC ...
Installed GHC.
/opt/rh/devtoolset-2/root/usr/bin/ld.bfd: /opt/conda/conda-bld/ngless_1525292274450/work/ngless-0.7.1/fake-home/.stack/programs/x86_64-linux/ghc-gmp4-8.4.2/lib/ghc-8.4.2/rts/libHSrts.a(OSThreads.o): undefined reference to symbol 'pthread_setname_np@@GLIBC_2.12'
/opt/rh/devtoolset-2/root/usr/bin/ld.bfd: note: 'pthread_setname_np@@GLIBC_2.12' is defined in DSO /lib64/libpthread.so.0 so try adding it to the linker command line/lib64/libpthread.so.0: could not read symbols: Invalid operation
collect2: error: ld returned 1 exit status
`gcc' failed in phase `Linker'. (Exit code: 1)
The GHC located at /opt/conda/conda-bld/ngless_1525292274450/work/ngless-0.7.1/fake-home/.stack/programs/x86_64-linux/ghc-gmp4-8.4.2/bin/ghc failed to compile a sanity check. Please see:
http://docs.haskellstack.org/en/stable/install_and_upgrade/
for more information. Exception was:
Received ExitFailure 1 when running
Raw command: /opt/conda/conda-bld/ngless_1525292274450/work/ngless-0.7.1/fake-home/.stack/programs/x86_64-linux/ghc-gmp4-8.4.2/bin/ghc /tmp/stack-sanity-check2833/Main.hs -no-user-package-db
Run from: /tmp/stack-sanity-check2833/
Standard output:
[1 of 1] Compiling Main ( /tmp/stack-sanity-check2833/Main.hs, /tmp/stack-sanity-check2833/Main.o )
Linking /tmp/stack-sanity-check2833/Main ...
I had a similar issue in building cpphs and happy using stack 2.1.1 with ghc-8.2.2. The precise error was
$ stack build
....
cpphs > /opt/gnu/bin/ld.bfd: /home/dsd/.stack/programs/x86_64-linux/ghc-gmp4-8.2.2/lib/ghc-8.2.2/rts/libHSrts.a(OSThreads.o): undefined reference to symbol 'pthread_setname_np@@GLIBC_2.12'
cpphs > /lib64/libpthread.so.0: error adding symbols: DSO missing from command line
cpphs > collect2: error: ld returned 1 exit status
cpphs > `gcc' failed in phase `Linker'. (Exit code: 1)
happy > Linking .stack-work/dist/x86_64-linux-gmp4/Cabal-2.0.1.0/build/happy/happy ...
happy > /opt/gnu/bin/ld.bfd: /home/dsd/.stack/programs/x86_64-linux/ghc-gmp4-8.2.2/lib/ghc-8.2.2/rts/libHSrts.a(OSThreads.o): undefined reference to symbol 'pthread_setname_np@@GLIBC_2.12'
happy > /lib64/libpthread.so.0: error adding symbols: DSO missing from command line
happy > collect2: error: ld returned 1 exit status
happy > `gcc' failed in phase `Linker'. (Exit code: 1)
I resolved the error by editing the file ~/.stack/programs/x86_64-linux/ghc-gmp4-8.2.2/lib/ghc-8.2.2/settings
and changing the following lines:
("C compiler flags", " -std=gnu99 -fno-stack-protector"),
=======>
("C compiler flags", " -std=gnu99 -fno-stack-protector -pthread"),
("C compiler link flags", " -fuse-ld=bfd"),
=======>
("C compiler link flags", " -fuse-ld=bfd -pthread"),
("ld flags", ""),
=======>
("ld flags", "-pthread"),
Confirming that the workaround provided by @davidsd worked for me
General summary/comments (optional)
Operating System - OpenSuse 42.3 Leap
Steps to reproduce
For example:
curl -sSL https://get.haskellstack.org/ | sh
as mentioned in https://docs.haskellstack.org/en/stable/README/.~/.stack/global-project/stack.yaml
file with key valueresolver: ghc-8.2.1
.stack setup
.stack setup
.undefined reference to symbol 'pthread_setname_np@@GLIBC_2.12' /lib64/libpthread.so.0
Expected
stack setup
should go through without any error.Actual
Getting below error
Stack version
Method of installation
Install stack using
curl -sSL https://get.haskellstack.org/ | sh
as mentioned in https://docs.haskellstack.org/en/stable/README/.I have asked question regarding this on stackoverflow. Here is the link.
Please let me know if you need more details.