This can be easily fixed in your GHC installation:
sed -i 's/-fno-PIE/-no-pie/g' ~/.stack/programs/x86_64-linux/ghc-nopie-8.0.1/lib/ghc-8.0.1/settings
Hopefully a fixed bindist (or the newer GHC 8.0.2 which ships with this fix already) will be released soon
Steps needed to support Linux distributions that enable PIE by default (Ubuntu 16.10, Debian Sid, etc.)
This it the same issue that I reported in this other ticket, but I now realized that my "fix" of removing ~/.stack/programs/x86_64-linux/ghc-8.0.1/ actually brought stack in an inconsistent state... and without it being aware of it, it was always selecting the system-installed ghc.
I thus moved away the whole ~/.stack/ directory, and tried to setup again... I tried both with lts version 7 and 6 (with --no-system-ghc), and the setup of ghc fails at linking step with both versions
I'm running Ubuntu 16.10, and I'm running
gcc (Ubuntu 6.2.0-5ubuntu12) 6.2.0 20161005
GNU ld (GNU Binutils for Ubuntu) 2.27
The error is the same as in the other ticket, which I'll link again here
Version 1.2.0 x86_64 hpack-0.14.0
Installed into ~/.local/bin/ via stack upgrade
I think this might be the cause:
It seems likely that is the cause! Good sleuthing. I am using ubuntu 16.04, which is before the release with gcc hardening. I have ld-2.26.1
What should be done about this? Linking is not something I am very familiar with. Do we need to have a way to compile everything -fPIC? Perhaps we need to use the --no-pie or --nopie option on new enough GCCs? Is handling this the responsibility of Cabal.
I found that there are a few issues that have already been opened:
https://github.com/commercialhaskell/stack/issues/2542
https://github.com/commercialhaskell/stack/issues/2711
Frustratingly, all of them are now closed...
The good thing, is that a fix to add a ghc-build option to disable PIE has been committed:
https://github.com/commercialhaskell/stack/commit/e3aa2388cefc083605091c55e92d9af09e048182
The bad thing is... I don't have that flag in Stack 1.2.0 :/
I'm currently building stack from sources, hopefully it'll work
(regardless if it works, stack setup --no-system-ghc cannot work on Ubuntu 16.10 for stack <= 1.2.0 ... so that should at least be mentioned/documented)
Those issues were recently resolved, they are not yet in a released version of stack. Use stack built from the git repo to get the fix!
Yeah, I tried it out.... it almost works
I'm not yet sure if the detection is broken... I'll test that soon
Anyhow, building my project still fails:
Configuring memory-0.13...
Building memory-0.13...
Preprocessing library memory-0.13...
/usr/bin/ld: .stack-work/dist/x86_64-linux-nopie/Cabal-1.24.0.0/build/Data/Memory/MemMap/Posix_hsc_make.o: relocation R_X86_64_32 against `.rodata' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: final link failed: Nonrepresentable section on output
collect2: error: ld returned 1 exit status
linking .stack-work/dist/x86_64-linux-nopie/Cabal-1.24.0.0/build/Data/Memory/MemMap/Posix_hsc_make.o failed (exit code 1)
command was: /usr/bin/gcc .stack-work/dist/x86_64-linux-nopie/Cabal-1.24.0.0/build/Data/Memory/MemMap/Posix_hsc_make.o .stack-work/dist/x86_64-linux-nopie/Cabal-1.24.0.0/build/Data/Memory/MemMap/Posix_hsc_utils.o -o .stack-work/dist/x86_64-linux-nopie/Cabal-1.24.0.0/build/Data/Memory/MemMap/Posix_hsc_make -fno-PIE -fno-stack-protector -L/home/dario/.stack/programs/x86_64-linux/ghc-nopie-8.0.1/lib/ghc-8.0.1/bytestring-0.10.8.1 -Wl,-R,/home/dario/.stack/programs/x86_64-linux/ghc-nopie-8.0.1/lib/ghc-8.0.1/bytestring-0.10.8.1 -L/home/dario/.stack/programs/x86_64-linux/ghc-nopie-8.0.1/lib/ghc-8.0.1/deepseq-1.4.2.0 -Wl,-R,/home/dario/.stack/programs/x86_64-linux/ghc-nopie-8.0.1/lib/ghc-8.0.1/deepseq-1.4.2.0 -L/home/dario/.stack/programs/x86_64-linux/ghc-nopie-8.0.1/lib/ghc-8.0.1/array-0.5.1.1 -Wl,-R,/home/dario/.stack/programs/x86_64-linux/ghc-nopie-8.0.1/lib/ghc-8.0.1/array-0.5.1.1 -L/home/dario/.stack/programs/x86_64-linux/ghc-nopie-8.0.1/lib/ghc-8.0.1/base-4.9.0.0 -Wl,-R,/home/dario/.stack/programs/x86_64-linux/ghc-nopie-8.0.1/lib/ghc-8.0.1/base-4.9.0.0 -L/home/dario/.stack/programs/x86_64-linux/ghc-nopie-8.0.1/lib/ghc-8.0.1/integer-gmp-1.0.0.1 -Wl,-R,/home/dario/.stack/programs/x86_64-linux/ghc-nopie-8.0.1/lib/ghc-8.0.1/integer-gmp-1.0.0.1 -lgmp -L/home/dario/.stack/programs/x86_64-linux/ghc-nopie-8.0.1/lib/ghc-8.0.1/ghc-prim-0.5.0.0 -Wl,-R,/home/dario/.stack/programs/x86_64-linux/ghc-nopie-8.0.1/lib/ghc-8.0.1/ghc-prim-0.5.0.0 -L/home/dario/.stack/programs/x86_64-linux/ghc-nopie-8.0.1/lib/ghc-8.0.1/rts -Wl,-R,/home/dario/.stack/programs/x86_64-linux/ghc-nopie-8.0.1/lib/ghc-8.0.1/rts -lm -lrt -ldl
I guess that hsc2hs needs to be fixed as well
(this feels like a can of worms :/ )
I confirm that the autodetection for the correct build-type works correctly.
I'd have suggested to release 1.2.1 as soon as possible, but without the fixes for hsc2hs there'll still be plenty of people who will find themselves unable to build their projects
Does this occur with GHCs from https://launchpad.net/~hvr/+archive/ubuntu/ghc as well?
I got the build working with your ghc...
I'll try again to confirm by wiping my ~/.stack and rebuilding with the stack-supplied's ghc
Since about a week I'm experiencing strange build errors within Travis (and only there, not even in a local container): https://travis-ci.org/sgraf812/feed-gipeda/jobs/170090429
This also happens for previously green builds (e.g. from 2 months ago) when I restart them, but only my LTS-2.22 and LTS-6.2* builds are affected, the LTS-3.* and LTS-7.* builds are fine.
Is this related?
I got the build working with your ghc...
I'll try again to confirm by wiping my ~/.stack and rebuilding with the stack-supplied's ghc
I mved .stack to .stack.bak, and tried again... the problem happens with hvr's packages as well
not sure how earlier I got it to work at all
@berdario it would be interesting to see how exactly hsc2hs is called; I've been using hsc2hs on Ubuntu 16.10 w/o any issue (otoh, I use cabal, so this may be a Stack specific issue; so maybe hsc2hs is called differently with Stack?)
I'm running Ubuntu 16.10 and seeing messages about fPIC as well.
/usr/bin/ld: /tmp/stack-sanity-check16859/Main.o: relocation R_X86_64_32S against symbol `stg_bh_upd_frame_info' can not be used when making a shared object; recompile with -fPIC
Same thing in _Debian Sid_ with stack 1.2.0:
Fixed in master :+1:.
Building _master_ with a snapshot that uses the same GHC version already available in the system works fine as a workaround , until stack 1.2.1 is released.
@hvr do you have any suggestions to discover how hsc2hs is being invoked by stack? The only idea I have is to use strace (but it might take me a while to use it to find it out)
This is the content of the network build log file:
[1 of 2] Compiling Main ( /tmp/stack1461/network-2.6.3.1/Setup.hs, /tmp/stack1461/network-2.6.3.1/.stack-work/dist/x86_64-linux/Cabal-1.24.0.0/setup/Main.o )
[2 of 2] Compiling StackSetupShim ( /tmp/stack1461/SetupShim.hs, /tmp/stack1461/network-2.6.3.1/.stack-work/dist/x86_64-linux/Cabal-1.24.0.0/setup/StackSetupShim.o )
Linking /tmp/stack1461/network-2.6.3.1/.stack-work/dist/x86_64-linux/Cabal-1.24.0.0/setup/setup ...
Configuring network-2.6.3.1...
configure: WARNING: unrecognized options: --with-compiler
checking build system type... x86_64-unknown-linux-gnu
checking host system type... x86_64-unknown-linux-gnu
checking for gcc... /usr/bin/gcc
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/stack1461/network-2.6.3.1':
configure: error: cannot run C compiled programs.
If you meant to cross compile, use `--host'.
See `config.log' for more details
Unfortunately, there's no config.log in the same directory. Do you have any idea where it might be?
Weirdly, memory and clock have the PIC-related error, but network has a different one...
@rbasso
to avoid confusion, be aware that's not a sufficient solution. Try to build an empty project with any of the following packages among the build-depends: network, memory, clock
I updated the issue description with a (for now quite minimal) checklist about the steps that we can take... feel free to amend it as new details are understood
@hvr This is the output of strace -f -s 10000 -v -e trace=execve stack build ^| grep hsc:
@berdario I don't use Stack myself so I can't debug this, but from the looks of it this is very likely a bug in Stack; it works flawless with cabal and my PPA Ubuntu 16.10 packages.
@hvr I see (sorry, after this I'll stop notifying you), but there's one last interesting tidbit (as I mentioned in the other issue): This also happens with Cabal, if invoked via stack (so apparently, a few environment variables are enough to trigger the problem) like stack exec -- env -u GHC_PACKAGE_PATH cabal new-build -v
In order, the following will be built:
clock-0.7.2 (lib:clock) (requires build)
network-2.6.3.1 (lib:network) (requires build)
sfoo2-0.1.0.0 (lib:sfoo2 exe:sfoo2-exe) *test (dependency rebuilt)
creating /tmp/sfoo2/dist-newstyle/build
creating /tmp/sfoo2/dist-newstyle/tmp
Extracting
/home/dario/.cabal/packages/hackage.haskell.org/clock/0.7.2/clock-0.7.2.tar.gz
to /tmp/sfoo2/dist-newstyle/tmp/clock-27928...
Extracting
/home/dario/.cabal/packages/hackage.haskell.org/network/2.6.3.1/network-2.6.3.1.tar.gz
to /tmp/sfoo2/dist-newstyle/tmp/network-27928...
Updating clock.cabal with the latest revision from the index.
creating dist
Configuring clock-0.7.2...
/home/dario/.local/bin/cabal act-as-setup --build-type=Simple -- configure
--verbose=2 --builddir=dist --ghc
--prefix=/home/dario/.cabal/store/ghc-8.0.1/clock-0.7.2-f7bbbe23389d0d21e0674117ade8b1ebfca0e0c3219d350650a9dfb98261cd3d
--bindir=/home/dario/.cabal/store/ghc-8.0.1/clock-0.7.2-f7bbbe23389d0d21e0674117ade8b1ebfca0e0c3219d350650a9dfb98261cd3d/bin
--libdir=/home/dario/.cabal/store/ghc-8.0.1/clock-0.7.2-f7bbbe23389d0d21e0674117ade8b1ebfca0e0c3219d350650a9dfb98261cd3d/lib
--libsubdir=
--libexecdir=/home/dario/.cabal/store/ghc-8.0.1/clock-0.7.2-f7bbbe23389d0d21e0674117ade8b1ebfca0e0c3219d350650a9dfb98261cd3d/libexec
--datadir=/home/dario/.cabal/store/ghc-8.0.1/clock-0.7.2-f7bbbe23389d0d21e0674117ade8b1ebfca0e0c3219d350650a9dfb98261cd3d/share
--datasubdir=
--docdir=/home/dario/.cabal/store/ghc-8.0.1/clock-0.7.2-f7bbbe23389d0d21e0674117ade8b1ebfca0e0c3219d350650a9dfb98261cd3d/share/doc
--htmldir=/home/dario/.cabal/store/ghc-8.0.1/clock-0.7.2-f7bbbe23389d0d21e0674117ade8b1ebfca0e0c3219d350650a9dfb98261cd3d/share/doc/html
--haddockdir=/home/dario/.cabal/store/ghc-8.0.1/clock-0.7.2-f7bbbe23389d0d21e0674117ade8b1ebfca0e0c3219d350650a9dfb98261cd3d/share/doc/html
--sysconfdir=/home/dario/.cabal/store/ghc-8.0.1/clock-0.7.2-f7bbbe23389d0d21e0674117ade8b1ebfca0e0c3219d350650a9dfb98261cd3d/etc
--enable-library-vanilla --disable-library-profiling --enable-shared
--disable-executable-dynamic --disable-profiling --profiling-detail=default
--library-profiling-detail=default --enable-optimization --disable-debug-info
--disable-library-for-ghci --disable-split-objs --disable-executable-stripping
--disable-library-stripping --package-db=clear --package-db=global
--package-db=/home/dario/.cabal/store/ghc-8.0.1/package.db --flags=-llvm
--ipid=clock-0.7.2-f7bbbe23389d0d21e0674117ade8b1ebfca0e0c3219d350650a9dfb98261cd3d
--dependency=base=base-4.9.0.0 --disable-tests --disable-coverage
--exact-configuration --disable-benchmarks --with-ghc=/opt/ghc/bin/ghc
--with-ghc-pkg=/opt/ghc/bin/ghc-pkg
Redirecting build log to {handle: /home/dario/.cabal/logs/clock-0.7.2.log}
Updating network.cabal with the latest revision from the index.
creating dist
Configuring network-2.6.3.1...
/home/dario/.local/bin/cabal act-as-setup --build-type=Configure -- configure
--verbose=2 --builddir=dist --ghc
--prefix=/home/dario/.cabal/store/ghc-8.0.1/network-2.6.3.1-99cda5afd75e215db7c6caec4d6b56c40df41034fae26acb83e05712eb725a4f
--bindir=/home/dario/.cabal/store/ghc-8.0.1/network-2.6.3.1-99cda5afd75e215db7c6caec4d6b56c40df41034fae26acb83e05712eb725a4f/bin
--libdir=/home/dario/.cabal/store/ghc-8.0.1/network-2.6.3.1-99cda5afd75e215db7c6caec4d6b56c40df41034fae26acb83e05712eb725a4f/lib
--libsubdir=
--libexecdir=/home/dario/.cabal/store/ghc-8.0.1/network-2.6.3.1-99cda5afd75e215db7c6caec4d6b56c40df41034fae26acb83e05712eb725a4f/libexec
--datadir=/home/dario/.cabal/store/ghc-8.0.1/network-2.6.3.1-99cda5afd75e215db7c6caec4d6b56c40df41034fae26acb83e05712eb725a4f/share
--datasubdir=
--docdir=/home/dario/.cabal/store/ghc-8.0.1/network-2.6.3.1-99cda5afd75e215db7c6caec4d6b56c40df41034fae26acb83e05712eb725a4f/share/doc
--htmldir=/home/dario/.cabal/store/ghc-8.0.1/network-2.6.3.1-99cda5afd75e215db7c6caec4d6b56c40df41034fae26acb83e05712eb725a4f/share/doc/html
--haddockdir=/home/dario/.cabal/store/ghc-8.0.1/network-2.6.3.1-99cda5afd75e215db7c6caec4d6b56c40df41034fae26acb83e05712eb725a4f/share/doc/html
--sysconfdir=/home/dario/.cabal/store/ghc-8.0.1/network-2.6.3.1-99cda5afd75e215db7c6caec4d6b56c40df41034fae26acb83e05712eb725a4f/etc
--enable-library-vanilla --disable-library-profiling --enable-shared
--disable-executable-dynamic --disable-profiling --profiling-detail=default
--library-profiling-detail=default --enable-optimization --disable-debug-info
--disable-library-for-ghci --disable-split-objs --disable-executable-stripping
--disable-library-stripping --package-db=clear --package-db=global
--package-db=/home/dario/.cabal/store/ghc-8.0.1/package.db
--ipid=network-2.6.3.1-99cda5afd75e215db7c6caec4d6b56c40df41034fae26acb83e05712eb725a4f
--dependency=base=base-4.9.0.0 --dependency=bytestring=bytestring-0.10.8.1
--dependency=unix=unix-2.7.2.0 --disable-tests --disable-coverage
--exact-configuration --disable-benchmarks --with-ghc=/opt/ghc/bin/ghc
--with-ghc-pkg=/opt/ghc/bin/ghc-pkg
Redirecting build log to {handle: /home/dario/.cabal/logs/network-2.6.3.1.log}
Building clock-0.7.2...
/home/dario/.local/bin/cabal act-as-setup --build-type=Simple -- build
--verbose=2 --builddir=dist
Redirecting build log to {handle: /home/dario/.cabal/logs/clock-0.7.2.log}
network.log:
Configuring network-2.6.3.1...
Dependency base ==4.9.0.0: using base-4.9.0.0
Dependency bytestring ==0.10.8.1: using bytestring-0.10.8.1
Dependency unix ==2.7.2.0: using unix-2.7.2.0
Using Cabal-1.24.0.0 compiled by ghc-8.0
Using compiler: ghc-8.0.1
Using install prefix:
/home/dario/.cabal/store/ghc-8.0.1/network-2.6.3.1-99cda5afd75e215db7c6caec4d6b56c40df41034fae26acb83e05712eb725a4f
Binaries installed in:
/home/dario/.cabal/store/ghc-8.0.1/network-2.6.3.1-99cda5afd75e215db7c6caec4d6b56c40df41034fae26acb83e05712eb725a4f/bin
Libraries installed in:
/home/dario/.cabal/store/ghc-8.0.1/network-2.6.3.1-99cda5afd75e215db7c6caec4d6b56c40df41034fae26acb83e05712eb725a4f/lib
Private binaries installed in:
/home/dario/.cabal/store/ghc-8.0.1/network-2.6.3.1-99cda5afd75e215db7c6caec4d6b56c40df41034fae26acb83e05712eb725a4f/libexec
Data files installed in:
/home/dario/.cabal/store/ghc-8.0.1/network-2.6.3.1-99cda5afd75e215db7c6caec4d6b56c40df41034fae26acb83e05712eb725a4f/share
Documentation installed in:
/home/dario/.cabal/store/ghc-8.0.1/network-2.6.3.1-99cda5afd75e215db7c6caec4d6b56c40df41034fae26acb83e05712eb725a4f/share/doc
Configuration files installed in:
/home/dario/.cabal/store/ghc-8.0.1/network-2.6.3.1-99cda5afd75e215db7c6caec4d6b56c40df41034fae26acb83e05712eb725a4f/etc
No alex found
Using ar found on system at: /usr/bin/ar
No c2hs found
No cpphs found
Using gcc version 6.2.0 found on system at: /usr/bin/gcc
Using ghc version 8.0.1 given by user at: /opt/ghc/bin/ghc
Using ghc-pkg version 8.0.1 given by user at: /opt/ghc/bin/ghc-pkg
No ghcjs found
No ghcjs-pkg found
No greencard found
Using haddock version 2.17.2 found on system at: /opt/ghc/bin/haddock
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.67 found on system at: /usr/bin/hpc
Using hsc2hs version 0.68 found on system at: /opt/ghc/8.0.1/bin/hsc2hs
No hscolour found
No jhc found
Using ld found on system at: /usr/bin/ld
No lhc found
No lhc-pkg found
Using pkg-config version 0.29.1 found on system at: /usr/bin/pkg-config
Using strip version 2.27 found on system at: /usr/bin/strip
Using tar found on system at: /bin/tar
No uhc found
/bin/sh ./configure '--with-compiler=ghc' '--prefix=/home/dario/.cabal/store/ghc-8.0.1/network-2.6.3.1-99cda5afd75e215db7c6caec4d6b56c40df41034fae26acb83e05712eb725a4f' '--bindir=/home/dario/.cabal/store/ghc-8.0.1/network-2.6.3.1-99cda5afd75e215db7c6caec4d6b56c40df41034fae26acb83e05712eb725a4f/bin' '--libdir=/home/dario/.cabal/store/ghc-8.0.1/network-2.6.3.1-99cda5afd75e215db7c6caec4d6b56c40df41034fae26acb83e05712eb725a4f/lib' '--libexecdir=/home/dario/.cabal/store/ghc-8.0.1/network-2.6.3.1-99cda5afd75e215db7c6caec4d6b56c40df41034fae26acb83e05712eb725a4f/libexec' '--datadir=/home/dario/.cabal/store/ghc-8.0.1/network-2.6.3.1-99cda5afd75e215db7c6caec4d6b56c40df41034fae26acb83e05712eb725a4f/share' '--sysconfdir=/home/dario/.cabal/store/ghc-8.0.1/network-2.6.3.1-99cda5afd75e215db7c6caec4d6b56c40df41034fae26acb83e05712eb725a4f/etc' 'CC=/usr/bin/gcc'
configure: WARNING: unrecognized options: --with-compiler
checking build system type... x86_64-unknown-linux-gnu
checking host system type... x86_64-unknown-linux-gnu
checking for gcc... /usr/bin/gcc
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/sfoo2/dist-newstyle/tmp/network-27928/network-2.6.3.1':
configure: error: cannot run C compiled programs.
If you meant to cross compile, use `--host'.
See `config.log' for more details
clock.log:
Configuring clock-0.7.2...
Flags chosen: llvm=False
Dependency base ==4.9.0.0: using base-4.9.0.0
Using Cabal-1.24.0.0 compiled by ghc-8.0
Using compiler: ghc-8.0.1
Using install prefix:
/home/dario/.cabal/store/ghc-8.0.1/clock-0.7.2-f7bbbe23389d0d21e0674117ade8b1ebfca0e0c3219d350650a9dfb98261cd3d
Binaries installed in:
/home/dario/.cabal/store/ghc-8.0.1/clock-0.7.2-f7bbbe23389d0d21e0674117ade8b1ebfca0e0c3219d350650a9dfb98261cd3d/bin
Libraries installed in:
/home/dario/.cabal/store/ghc-8.0.1/clock-0.7.2-f7bbbe23389d0d21e0674117ade8b1ebfca0e0c3219d350650a9dfb98261cd3d/lib
Private binaries installed in:
/home/dario/.cabal/store/ghc-8.0.1/clock-0.7.2-f7bbbe23389d0d21e0674117ade8b1ebfca0e0c3219d350650a9dfb98261cd3d/libexec
Data files installed in:
/home/dario/.cabal/store/ghc-8.0.1/clock-0.7.2-f7bbbe23389d0d21e0674117ade8b1ebfca0e0c3219d350650a9dfb98261cd3d/share
Documentation installed in:
/home/dario/.cabal/store/ghc-8.0.1/clock-0.7.2-f7bbbe23389d0d21e0674117ade8b1ebfca0e0c3219d350650a9dfb98261cd3d/share/doc
Configuration files installed in:
/home/dario/.cabal/store/ghc-8.0.1/clock-0.7.2-f7bbbe23389d0d21e0674117ade8b1ebfca0e0c3219d350650a9dfb98261cd3d/etc
No alex found
Using ar found on system at: /usr/bin/ar
No c2hs found
No cpphs found
Using gcc version 6.2.0 found on system at: /usr/bin/gcc
Using ghc version 8.0.1 given by user at: /opt/ghc/bin/ghc
Using ghc-pkg version 8.0.1 given by user at: /opt/ghc/bin/ghc-pkg
No ghcjs found
No ghcjs-pkg found
No greencard found
Using haddock version 2.17.2 found on system at: /opt/ghc/bin/haddock
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.67 found on system at: /usr/bin/hpc
Using hsc2hs version 0.68 found on system at: /opt/ghc/8.0.1/bin/hsc2hs
No hscolour found
No jhc found
Using ld found on system at: /usr/bin/ld
No lhc found
No lhc-pkg found
Using pkg-config version 0.29.1 found on system at: /usr/bin/pkg-config
Using strip version 2.27 found on system at: /usr/bin/strip
Using tar found on system at: /bin/tar
No uhc found
Component build order: library
creating dist/build
creating dist/build/autogen
Building clock-0.7.2...
/opt/ghc/bin/ghc-pkg init dist/package.conf.inplace
Preprocessing library clock-0.7.2...
creating dist/build/System
/opt/ghc/8.0.1/bin/hsc2hs '--cc=/usr/bin/gcc' '--ld=/usr/bin/gcc' '--cflag=-fno-PIE' '--cflag=-fno-stack-protector' '--lflag=-fno-PIE' '--lflag=-fno-stack-protector' '--cflag=-D__GLASGOW_HASKELL__=800' '--cflag=-Dlinux_BUILD_OS=1' '--cflag=-Dx86_64_BUILD_ARCH=1' '--cflag=-Dlinux_HOST_OS=1' '--cflag=-Dx86_64_HOST_ARCH=1' '--cflag=-Icbits' '--cflag=-Idist/build/autogen' '--cflag=-include' '--cflag=dist/build/autogen/cabal_macros.h' '--cflag=-I/opt/ghc/8.0.1/lib/ghc-8.0.1/base-4.9.0.0/include' '--cflag=-I/opt/ghc/8.0.1/lib/ghc-8.0.1/integer-gmp-1.0.0.1/include' '--cflag=-I/opt/ghc/8.0.1/lib/ghc-8.0.1/include' '--lflag=-L/opt/ghc/8.0.1/lib/ghc-8.0.1/base-4.9.0.0' '--lflag=-Wl,-R,/opt/ghc/8.0.1/lib/ghc-8.0.1/base-4.9.0.0' '--lflag=-L/opt/ghc/8.0.1/lib/ghc-8.0.1/integer-gmp-1.0.0.1' '--lflag=-Wl,-R,/opt/ghc/8.0.1/lib/ghc-8.0.1/integer-gmp-1.0.0.1' '--lflag=-lgmp' '--lflag=-L/opt/ghc/8.0.1/lib/ghc-8.0.1/ghc-prim-0.5.0.0' '--lflag=-Wl,-R,/opt/ghc/8.0.1/lib/ghc-8.0.1/ghc-prim-0.5.0.0' '--lflag=-L/opt/ghc/8.0.1/lib/ghc-8.0.1/rts' '--lflag=-Wl,-R,/opt/ghc/8.0.1/lib/ghc-8.0.1/rts' '--lflag=-lm' '--lflag=-lrt' '--lflag=-ldl' -o dist/build/System/Clock.hs System/Clock.hsc
Clock.hsc:44:0: warning: "hsc_alignment" redefined
In file included from dist/build/System/Clock_hsc_make.c:1:0:
/opt/ghc/8.0.1/lib/ghc-8.0.1/template-hsc.h:88:0: note: this is the location of the previous definition
#define hsc_alignment(t...) \
/usr/bin/ld: dist/build/System/Clock_hsc_make.o: relocation R_X86_64_32 against `.rodata' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: final link failed: Nonrepresentable section on output
collect2: error: ld returned 1 exit status
linking dist/build/System/Clock_hsc_make.o failed (exit code 1)
command was: /usr/bin/gcc dist/build/System/Clock_hsc_make.o dist/build/System/Clock_hsc_utils.o -o dist/build/System/Clock_hsc_make -fno-PIE -fno-stack-protector -L/opt/ghc/8.0.1/lib/ghc-8.0.1/base-4.9.0.0 -Wl,-R,/opt/ghc/8.0.1/lib/ghc-8.0.1/base-4.9.0.0 -L/opt/ghc/8.0.1/lib/ghc-8.0.1/integer-gmp-1.0.0.1 -Wl,-R,/opt/ghc/8.0.1/lib/ghc-8.0.1/integer-gmp-1.0.0.1 -lgmp -L/opt/ghc/8.0.1/lib/ghc-8.0.1/ghc-prim-0.5.0.0 -Wl,-R,/opt/ghc/8.0.1/lib/ghc-8.0.1/ghc-prim-0.5.0.0 -L/opt/ghc/8.0.1/lib/ghc-8.0.1/rts -Wl,-R,/opt/ghc/8.0.1/lib/ghc-8.0.1/rts -lm -lrt -ldl
@berdario That's interesting... which env-vars does stack exec inject ? does it by any chance inject CFLAGS or LDFLAGS? Those could easily cause Cabal to override the flags it would have passed to hsc2hs by default
@hvr sorry I just realized that cabal new-build fails for me even when executed outside of stack (I guess that I got confused, since cabal-install 1.24's new-build doesn't correctly set the exit code)
OTOH, I installed cabal-install via stack...
@berdario just to be sure, as I'm not able to reproduce the problem you're experiencing locally with cabal: could you try in a new empty user-account with cabal-install-1.24 & ghc-8.0.1 from my ppa? (you can try cabal-install-head instead if you want to avoid the exit-code bug ); also, I assume you have the 16.10 specific .deb installed? (e.g. ghc-8.0.1 8.0.1-13~16.10)
I already tried... it works
But it fails with cabal-install-1.22
and it seems that if I build stack from git, it's picking up Cabal-1.22
I suspect that might be the reason, but that doesn't explain why a cabal-install-1.24, built from stack doesn't work... that couldn't possibly be linked against Cabal-1.22, right?
https://github.com/commercialhaskell/stack/issues/2712#issuecomment-256856693
I am not sure how it relates to stack but I have used cabal install --hsc2hs-option=--cflag=-fPIC --configure-option='CFLAGS=-fPIC' ... to work around these compilation issues when using Cabal directly.
Btw, I was wrong: it's not due to Cabal-1.2{2,4}
cabal-install-1.22 doesn't work, but that's probably unrelated to the Cabal library itself. I just built a stack on GHC8.0 from git with cabal-install-1.24 and the problem still appears (but I now realized that from my earlier error outputs some version of stack that I used was already using Cabal-1.24
I guess that if this has been fixed in cabal-install (and not Cabal itself), it's probably just a matter of passing the correct hsc2hs flags to the build (just like wilx suggested), and stack should be patched to do it by default (always?)
PS: otoh, cabal-install itself doesn't seem to handle the -fPIC option anywhere in its code, that seems to be mostly dealt with by Cabal itself. The most recent change (after 1.22.0, but I'm not sure if it was included in 1.22.6) would probably be this:
https://github.com/haskell/cabal/commit/382143aa7322605d1a9f0480e383490e186c7ea0
which fixed this other bug: https://github.com/haskell/cabal/issues/2207
I am getting this bug also on
~ uname -a
Linux workbox 4.6.0-1-amd64 #1 SMP Debian 4.6.4-1 (2016-07-18) x86_64 GNU/Linux
~ stack --version
Version 1.2.0, Git revision 241cd07d576d9c0c0e712e83d947e3dd64541c42 (4054 commits) x86_64 hpack-0.14.0
I am now unable to build my project at all, I have tried deleting contents of .~/.stack and wiping local .stack-work to no avail.
@berdario IMO, the -fPIC option is a red herring; you should rather investigate why --flag=-no-pie is sometimes inhibited (and you won't find that flag hardcoded anywhere in Cabal/cabal's code base as it wouldn't belong there)
Running debian sid and was blocked on this. Was able to workaround using stack's docker support...(In case it helps anyone getting unblocked until the fix is released.)
Some discussion on Reddit (and a linked Haskell-cafe thread)
btw, if you're running Stack-1.2.1 from git and you have a nopie build, you'd have seen that the settings file already has the suggested options, but this is not enough (I suspect that alan_zimm on reddit might have had the same issues)
On ghc's Trac there's also a link to this
The fix is to pass -no-pie along with -Wl,-r to the compiler, but unfortunately that flag is very new as well.
Which apparently means that (unless people want to drop support of old gcc (and what about other compilers?), setting -no-pie in the gcc flags of the affected libraries is probably not the best solution
Possibly related: https://github.com/haskell/cabal/issues/4080
I ran into this on ubuntu 16.10, but enabling nix support worked around the issue (I already had nix installed, but not enabled with stack).
Encountered this issue on Debian testing.
It's really inconvenient that this issue actually prevents you from upgrading stack to the latest git master.
On the latest Ubuntu/Debian it's impossible to get Stack installed in such a way that anything at all will build correctly. I've worked around it to some extent with a few Docker hacks but it's not great by any means.
Edit: my hack is published at https://github.com/ahri/isolated-stack - just symlink the stack.sh from your path somewhere. It'll build the image the first time you execute the script. It executes in a Docker-contained Debian Jessie, dropping files in your ~/.stack and ~/.local/bin dirs, meaning you can "stack install hoogle" and have a hoogle binary sat in your normal ~/.local/bin without needing Docker at runtime for installed programs.
I should say, this is only aimed at running on Debian-derived OSs that experience these problems.
I got it working.
Go to /home/you/.stack/programs/x86_64-linux/ghc-8.0.1/lib/ghc-8.0.1/settings
and change the following values to:
("C compiler flags", "-fno-PIE -fno-stack-protector"),
("C compiler link flags", "-no-pie"),
("ld flags", "-no-pie"),
and you should be ok. If you also have a previous version of ghc installed, change the settings there too.
Alan Zimmerman mentioned this in a Haskell-Cafe email back on October 31st.
@senorhesles I already tried, it doesn't work
Try to install the packages that I mentioned earlier (network, memory, clock). I'd be surprised if it'd work for you
(but if it does, it's interesting, since the might be some other differences that trigger this problem)
@senorhesles Thank you! This worked for me perfectly! And at a really good time since my docker workaround encountered another issue. I've compiled quite few dependencies just fine. @berdario This includes network as well. I'll have to subscribe to haskell-caffe again to get stuff like this.
One thing to note though..since those flags are most likely concatenated with others it's probably required to have a space after the opening quote. Or at least that's the pattern I was with the values that were already in the settings file. So it might be worth editing your comment.
It builds in my case
Just adapt the ghc version which has the error (ghc-8.0.01 above or ghc-7.10 in my case:
~/.stack/programs/x86_64-linux/ghc-7.10.3/lib/ghc-7.10.3/settings )
cp settings settings.bak
And change the options as @senorhesles mentionned previously:
("C compiler flags", "-fno-PIE -fno-stack-protector"),
("C compiler link flags", "-no-pie"),
("ld flags", "-no-pie"),
It builds, yes, but I wonder the effects of adding such options (-no-pie) in long term use.
Ok for the hack but how long should we maintain it (mv settings.bak settings) ?
I still cannot "stack install memory", even with these settings. Does it
work for anyone else?
On Wed, Nov 16, 2016 at 10:08 AM, Alexandre Delanoë <
[email protected]> wrote:
It builds in my case
Just adapt the ghc version which has the error (ghc-8.0.01 above or
ghc-7.10 in my case:
~/.stack/programs/x86_64-linux/ghc-7.10.3/lib/ghc-7.10.3/settings )cp settings settings.bak
And change the options as @senorhesles https://github.com/senorhesles
mentionned previously:
("C compiler flags", "-fno-PIE -fno-stack-protector"),
("C compiler link flags", "-no-pie"),
("ld flags", "-no-pie"),It builds, yes, but I wonder the effects of adding such options (-no-pie)
in long term use.
Ok for the hack but how long should we maintain it (mv settings.bak
settings) ?—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
https://github.com/commercialhaskell/stack/issues/2712#issuecomment-260880515,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AAZAB9i4I2Po45oLZe1td-_Ddjke1Mi2ks5q-roHgaJpZM4KYH8P
.
@alanz nope, https://github.com/commercialhaskell/stack/issues/2712#issuecomment-260804267 didn't work for me on Ubuntu 16.10 as well
I had this issue running 16.10, so I though I would write up some instructions on how to work around it.
You run stack build and get some error mentioning can not be used when making a shared object; recompile with -fPIC.
ghc in the terminal produces a not found message)stack build not work?It seems that the ghc installed by stack has a problem. To make stack build work we thus need to use a system ghc that is not installed by stack.
Remove the ghc installed by stack. Follow the directions here to remove your project's .stack-work folder, and your ~/.stack folder. The ghc installed by stack is in ~/.stack, so deleting ~/.stack removes it.
Install ghc from this PPA. I need ghc 8.0.1, so I do: sudo add-apt-repository ppa:hvr/ghc, sudo apt update, and sudo apt install ghc-8.0.1 ghc-8.0.1-prof ghc-8.0.1-htmldocs
Add ghc to the path. Add the line PATH="$PATH:/opt/ghc/bin" to your ~/.profile. Log out and log back in again.
stack build should now work
Edit 1: To get stack build --profile or stack build --trace to work, you need to install ghc-$VER-prof, so for me I needed to do sudo apt install ghc-8.0.1-prof.
Edit 2: I just installed stack 1.3.0 via the Ubuntu software updater. I needed to do stack setup, and then stack config set system-ghc --global true to get stack build to work again.
@rgleichman whoa cool, confirm that works for 8.0.1 and ubuntu 16.10!
I used this stack.yaml with Stack 1.2.1:
compiler-check: match-exact
resolver: ghc-8.0.1.20161117
setup-info:
ghc:
linux64-nopie:
8.0.1.20161117:
url: http://downloads.haskell.org/~ghc/8.0.2-rc1/ghc-8.0.1.20161117-x86_64-deb8-linux.tar.xz
content-length: 112047972
sha1: 6a6e4c9c53c71cc84b6966a9f61948542fd2f15a
and it succeded to install memory. So maybe this issue could be solved as soon as the new GHC will be available in a LTS? (this means that GHC 8.0.1 will not be supported with Stack on recent Linuxes, but I'd personally find that acceptable)
@senorhesles @delanoe how about ghcjs? where such options?
I think I figured out the problem with network, memory, old-time, etc. ~/.stack/programs/x86_64-linux/ghc-nopie-8.0.1/lib/ghc-8.0.1/settings contains these two lines:
("C compiler flags", "-fno-PIE -fno-stack-protector"),
("C compiler link flags", "-no-pie"),
They are applied by GHC at compile time and link time, respectively and everything works. However, autoconf builds executables in one shot with GCC (for testing various things) and passes only the first set. -fno-PIE affects compilation; -no-pie affects both compilation and linking. Replacing -fno-PIE with -no-pie in the first line fixes the issue. I don't know how the bindists are generated or how the options are set, otherwise I'd offer a PR.
Works for me, editing my local ghc settings file. Thanks.
https://github.com/commercialhaskell/stack/issues/2712#issuecomment-260804267
This worked for me! Thanks!!
@enolan - thanks! That was the one that fixed it for me.
thanks to @senorhesles and @enolan , the following settings are working for me
("C compiler flags", "-no-pie -fno-stack-protector"),
("C compiler link flags", "-no-pie"),
("ld flags", "-no-pie")
With fresh stack-1.3, I have GHC installed successfully in nopie mode, without modifying settings file in GHC guts, but. as @berdario mentioned before,
Weirdly,
memoryandclockhave the PIC-related error, butnetworkhas a different one...
is still an issue.
This fixes the issue for me.
sed -i 's/-fno-PIE/-no-pie/g' ~/.stack/programs/x86_64-linux/ghc-nopie-8.0.1/lib/ghc-8.0.1/settings
Ubuntu 16.10, GCC 6.2, latest Stack
I can confirm that with stack 1.3 and ghc installed by stack in "nopie" mode one still has to edit the .stack/programs/x86_64-linux/ghc-nopie-8.0.1/lib/ghc-8.0.1/settings file and add "-fPIC" to the c compiler flags in order for the memory package to compile properly.
I've just been hit by this. Does this, or will this, affect every Ubuntu 16.10 user who is using GHC 8.0.1 as a stack resolver, without a system installed ghc-8.0.1 (i.e. relying stack to install ghc-8.0.1 with stack setup)? I would imagine that that's quite a number of stack users, no?
This might be something we can fix in the GHC bindist itself (in default settings file).
Is there concensus here that sed -i 's/-fno-PIE/-no-pie/g' ~/.stack/programs/x86_64-linux/ghc-nopie-8.0.1/lib/ghc-8.0.1/settings is always the correct change?
@robstewart57 yes that's my exact setup (with Docker)
Oh, I just realized that @enolan suggestion is right on point (I previously overlooked his comment, not realizing that he explained the difference in upper/lower case and how it affects at what time the option is used)
@borsboom
If you install the release candidate of GHC8.0.2 you'll find that its settings file already uses -no-pie, so this seems to be indeed the accepted solution
https://github.com/commercialhaskell/stack/issues/2712#issuecomment-263164470
@berdario Do you know why I still had to add "-fPIC" as per my comment above?
@denibertovic
Do you mean "-fPIC" instead of "-no-pie", or do you mean why do you have to modify the settings file at all?
If the former: I don't know...
if the latter: it's expected, since the 8.0.1 bindist doesn't ship with the fix, yet (also, maybe -no-pie implies -fPIC? or maybe you're only talking about the error that you're getting?)
Is this GHC 8.0.2 fix related? This GHC ticket was opened by @hvr 2 months ago.
@berdario I'm saying that even with latest stack which installs ghc with "no-pie" (which you can tell from the path to the settings file" I still have to add "-fPIC" to the settings file's C compiler flags for the memory package to compile.
EDIT:
GHC: 8.0.1
Originally that line in settings looked like this:
("C compiler flags", "-fno-PIE -fno-stack-protector")
After my changes it looks likes this:
("C compiler flags", "-fno-PIE -fPIC -fno-stack-protector")
The way GHC is installed on Ubuntu 16.10 etc. is by setting these environment variables before calling the ghc bindist's ./configure:
CONF_CC_OPTS_STAGE2: -fno-PIECONF_GCC_LINKER_OPTS_STAGE2: -no-pieCONF_LD_LINKER_OPTS_STAGE2: -no-pieThese are specified in stack-setup-2.yaml.
Does anyone here know whether these environment variables can be modified to do the right thing? You can experiment locally either by manually installing GHC from the bindist or by modifying a local copy of stack-setup-2.yaml and passing it into stack setup --stack-setup-yaml=stack-setup-2.yaml.
@denibertovic ¯\_(ツ)_/¯
I have
("C compiler flags", "-no-pie -fno-stack-protector"),
and it does the job
I'm on Arch Linux:
sed -i 's/-fno-PIE/-no-pie/g' ~/.stack/programs/x86_64-linux/ghc-nopie-8.0.1/lib/ghc-8.0.1/settings
error:
sed: can't read /home/alex/.stack/programs/x86_64-linux/ghc-nopie-8.0.1/lib/ghc-8.0.1/settings: No such file or directory
$ stack --version
Version 1.3.2 x86_64
and
$ ls ~/.stack/programs/x86_64-linux/
ghc-7.10.3 ghc-8.0.1
ghc-7.10.3.installed ghc-8.0.1.installed
ghc-7.10.3.tar.xz ghc-8.0.1.tar.xz
None of the configuration hacks mentioned here works on Fedora 25. Using Stack version 1.3.2, Git revision 3f675146590da4f3edf768b89355f798229da2a5.
The PR that closed this issue should've fixed this - it changes the environment variables set when ./configure is run.
@nirvinm can you delete ~/.stack/programs, run stack setup and try again?
@GildedHonour if you have ghc-8.0.1 and not ghc-nopie-8.0.1 then either your problem is not PIE or Stack isn't detecting it for some reason. The logic is in Stack.Setup IIRC.
@enolan I tried deleting the ~/.stack/* directories and run _stack setup_ again. But still getting the same linker error. Using GCC 6.3.1
UPDATE: I installed gmp-devel package on Fedora. It fixed the issue.
I successfully built network, memory and clock with nightly-2017-01-31/ghc-8.0.2 (x86_64-nopie)
On Ubuntu 16.10, I was finally able to get stack setup 7.10.3 to work by:
ghc-7.10.3 from source on my other PC with Ubuntu 16.04 using this configure command:CFLAGS="$CFLAGS -fPIC" CPPFLAGS="$CXXFLAGS -fPIC" CONF_CC_OPTS_STAGE2=-fno-PIE CONF_GCC_LINKER_OPTS_STAGE2=-no-pie CONF_LD_LINKER_OPTS_STAGE2=-no-pie ./configure --with-hs-cpp-flags='-E -undef -traditional -fPIC' && make -j && make test -j && make docs -j && sudo checkinstallsudo aptitude install hardening-wrapper. The rest of these commands are run on the Ubuntu 16.10 PC./etc/hardening-wrapper like this:DEB_BUILD_HARDENING=1
DEB_BUILD_HARDENING_DEBUG=1
DEB_BUILD_HARDENING_DEBUG_SYMLINKS=1
DEB_BUILD_HARDENING_STACKPROTECTOR=1
DEB_BUILD_HARDENING_FORTIFY=1
DEB_BUILD_HARDENING_FORMAT=1
DEB_BUILD_HARDENING_PIE=1stack setup 7.10.3 _as non-root_. It still fails for some reason when I run as root.I'm sure this is overkill but I've battled this for two days so I've thrown everything I have at it.More than happy to provide any config info anyone might need.
$ stack --version
Version 1.3.2, Git revision 3f675146590da4f3edf768b89355f798229da2a5 (4395 commits) x86_64 hpack-0.15.0
Seems to have same linking problem for clock.
OS: 4.11.9-1-ARCH
GHC: 8.0.2
Stack Version: 1.4.0
-- While building package clock-0.7.2 using:
/home/mihai/.stack/setup-exe-cache/x86_64-linux-tinfo6-nopie/Cabal-simple_mPHDZzAJ_1.24.2.0_ghc-8.0.2 --builddir=.stack-work/dist/x86_64-linux-tinfo6-nopie/Cabal-1.24.2.0 build --ghc-options " -ddump-hi -ddump-to-file"
Process exited with code: ExitFailure 1
Logs have been written to: /home/mihai/Development/qchas/.stack-work/logs/clock-0.7.2.log
Configuring clock-0.7.2...
Building clock-0.7.2...
Preprocessing library clock-0.7.2...
Clock.hsc:44:0: warning: "hsc_alignment" redefined
In file included from .stack-work/dist/x86_64-linux-tinfo6-nopie/Cabal-1.24.2.0/build/System/Clock_hsc_make.c:1:0:
/home/mihai/.stack/programs/x86_64-linux/ghc-tinfo6-nopie-8.0.2/lib/ghc-8.0.2/template-hsc.h:88:0: note: this is the location of the previous definition
#define hsc_alignment(t...) \
/usr/bin/ld: .stack-work/dist/x86_64-linux-tinfo6-nopie/Cabal-1.24.2.0/build/System/Clock_hsc_make.o: relocation R_X86_64_32 against `.rodata' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: final link failed: Nonrepresentable section on output
collect2: error: ld returned 1 exit status
linking .stack-work/dist/x86_64-linux-tinfo6-nopie/Cabal-1.24.2.0/build/System/Clock_hsc_make.o failed (exit code 1)
command was: /usr/bin/gcc .stack-work/dist/x86_64-linux-tinfo6-nopie/Cabal-1.24.2.0/build/System/Clock_hsc_make.o .stack-work/dist/x86_64-linux-tinfo6-nopie/Cabal-1.24.2.0/build/System/Clock_hsc_utils.o -o .stack-work/dist/x86_64-linux-tinfo6-nopie/Cabal-1.24.2.0/build/System/Clock_hsc_make -fno-PIE -fno-stack-protector -L/home/mihai/.stack/programs/x86_64-linux/ghc-tinfo6-nopie-8.0.2/lib/ghc-8.0.2/base-4.9.1.0 -Wl,-R,/home/mihai/.stack/programs/x86_64-linux/ghc-tinfo6-nopie-8.0.2/lib/ghc-8.0.2/base-4.9.1.0 -L/home/mihai/.stack/programs/x86_64-linux/ghc-tinfo6-nopie-8.0.2/lib/ghc-8.0.2/integer-gmp-1.0.0.1 -Wl,-R,/home/mihai/.stack/programs/x86_64-linux/ghc-tinfo6-nopie-8.0.2/lib/ghc-8.0.2/integer-gmp-1.0.0.1 -lgmp -L/home/mihai/.stack/programs/x86_64-linux/ghc-tinfo6-nopie-8.0.2/lib/ghc-8.0.2/ghc-prim-0.5.0.0 -Wl,-R,/home/mihai/.stack/programs/x86_64-linux/ghc-tinfo6-nopie-8.0.2/lib/ghc-8.0.2/ghc-prim-0.5.0.0 -L/home/mihai/.stack/programs/x86_64-linux/ghc-tinfo6-nopie-8.0.2/lib/ghc-8.0.2/rts -Wl,-R,/home/mihai/.stack/programs/x86_64-linux/ghc-tinfo6-nopie-8.0.2/lib/ghc-8.0.2/rts -lm -lrt -ldl -lpthread
is there a fix?
Edit: Seems that the problem was fixed by installing ncurses5-compat-libs.
@ardeleanasm I'm on stack 1.5.0 on Arch and reinstalling doesn't work.
@nd2s I don't have the problem anymore. I installed ncurses5-compat-libs, removed /home/user/.stack/ and reinstalled stack. hope it works!
@ardeleanasm Installing ncurses5-compat-libs fixed it, didn't need to reinstall stack. Many thanks!
@nd2s you're welcome and I'm glad I could help you!
I had the same problem since about 2 weeks. I'm on Arch Linux with stack 1.5.1 and GHC 7.10.3 (according to the build plan).
Finally, the @berdario's fix solved the problem for me.
My project is a @yesodweb Yesod app, so maybe it is related to position independent execution (PIE). I don't have hardening-wrapper installed. I tried a lot with -static, -fPIC, ... as suggested in similar problem reports.
There is a short FAQ entry on this problem, too.
I'm having this problem now and installing ncurses5-compat-libs doesn't work, even after removing ~/.stack and re-installing stack.
EDIT:
In my case I had to un-install ncurses5-compat-libs and install ncurses-full.
I've also had this problem on arch. As been said on wiki there are some troubles with dynamic and static link. So, basically, I tried to installed some libs depend on old base (<4.10) with brand new ghc, just from arch repo, and then ran into dependency hell with errors like described above. So what i've done
stack unpack old-time
cd old-time
stack init
stack build
cd ~/.stack/programs/x86_64-linux
rm -rf ghc-tinfo6-nopie-7.10.3
tar xvfJ ghc-tinfo6-nopie-7.10.3.tar.xz
cd ghc-7.10.3
./configure --with-hs-cpp-flags='-E -undef -traditional -fPIC -fno-PIE' --prefix=~/.stack/programs/x86_64-linux/ghc-tinfo6-nopie-7.10.3
make install
cd ~/.stack/programs/x86_64-linux/ghc-tinfo6-nopie-7.10.3/lib/ghc-7.10.3/
vi settings
("C compiler flags", "-fno-PIE -fPIC -fno-stack-protector")That's it! Finally I managed to install stylish-haskell.
Just ran into this issue on arch, trying to build a project that had been building fine up until now. After checking this issue and #3518 , What worked for me was a slight variation of @Gzernov 's process above:
stack from stackagestack to enter ghci (by running stack ghci)That worked for me, but unfortunately, stack build still didn't produce anything (it produced a file named a.out once I believe, but not consistently, and it seems to be ignoring the project configuration).
After that I remembered that I have --static specified in my .cabal file ld-options, and thought maybe removing that might help, and avoid trying to even do a static build at all locally (it didn't help).
Luckily for me when it's time to actually deploy I build my project inside a docker container (and during local development run from GHCI), so being able to start GHCI is enough for me as far as local development goes.
UPDATE - stack build does seem to work properly with statically linked stack executable after a while... I just used stack ghci as normal and after a while stack build produced the output I'd expect (and built the expected executables). Sorry I don't have a better timeline of what I actually did that might have affected stack build.
@t3hmrman I think the problem in Arch started a month ago after this change to the ncurses package.
Check senorhesles's workaround: adding "-no-pie" did the trick for me.
@Gzernov, @t3hmrman, @pera The following workaround alleviates this issue on Arch Linux:
Install ghc with:
stack setup --ghc-build=ncurses6
Then add ghc-build: ncurses6 to ~/.stack/config.yaml, otherwise stack will try to download and install the tinfo6-nopie build on every attempt to use stack.
This problem still exists on Arch with current stack 1.5.1 and GHC 8.0.2.
I had to change this in the settings file:
vi ~/.stack/programs/x86_64-linux/ghc-tinfo6-nopie-8.0.2/lib/ghc-8.0.2/settings
- ("C compiler flags", "-fno-PIE -fno-stack-protector"),
+ ("C compiler flags", "-no-pie -fno-stack-protector"),
Before I found this solution, I desperately removed everything related to xmonad, haskell, stack, cabal, ghc, including ~/.stack, ~/.cabal. Then I installed only stack and tried stack --install-ghc; stack install xmonad. The second command failed at the setlocale package with weired ld related errors. After the changed the settings file everything worked.
I'm having this problem with Arch and Stack 1.6.1 with ghc 8.2.2 as well. Changing to -no-pie as mentioned in https://github.com/commercialhaskell/stack/issues/2712#issuecomment-347702380 fixes the issue for me.
Adding ghc-build: nopie to ~/.stack/config.yaml fixed this for me.. Not sure if it's the same issue...
@chrissound, @drvink: This is being discussed in https://github.com/commercialhaskell/stack/issues/3518.
Most helpful comment
@Gzernov, @t3hmrman, @pera The following workaround alleviates this issue on Arch Linux:
Install ghc with:
Then add
ghc-build: ncurses6to~/.stack/config.yaml, otherwisestackwill try to download and install thetinfo6-nopiebuild on every attempt to usestack.