-
Notifications
You must be signed in to change notification settings - Fork 847
Description
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.)
- Release Stack 1.2.1Discover hsc2hs/config build errors cause (edit: maybe hsc2hs uses autotools directly? anyhow now we have a solution)Prepare new ghc nopie build to fix the hsc2hs errors?To pick up a draggable item, press the space bar. While dragging, use the arrow keys to move the item. Press space again to drop the item in its new position, or press escape to cancel.
Old issue description:
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
Stack version
Version 1.2.0 x86_64 hpack-0.14.0
Method of installation
Installed into ~/.local/bin/
via stack upgrade
Activity
berdario commentedon Oct 16, 2016
I think this might be the cause:
https://wiki.ubuntu.com/SecurityTeam/PIE
mgsloan commentedon Oct 17, 2016
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.berdario commentedon Oct 17, 2016
I found that there are a few issues that have already been opened:
#2542
#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:e3aa238
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 forstack <= 1.2.0
... so that should at least be mentioned/documented)mgsloan commentedon Oct 17, 2016
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!
berdario commentedon Oct 17, 2016
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:
I guess that hsc2hs needs to be fixed as well
(this feels like a can of worms :/ )
berdario commentedon Oct 17, 2016
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
hvr commentedon Oct 25, 2016
Does this occur with GHCs from https://launchpad.net/~hvr/+archive/ubuntu/ghc as well?
berdario commentedon Oct 25, 2016
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
sgraf812 commentedon Oct 25, 2016
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?
86 remaining items
t3hmrman commentedon Nov 5, 2017
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 enterghci
(by runningstack ghci
)That worked for me, but unfortunately,
stack build
still didn't produce anything (it produced a file nameda.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
fileld-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 linkedstack
executable after a while... I just usedstack ghci
as normal and after a whilestack 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 affectedstack build
.pera commentedon Nov 10, 2017
@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.
mkoloberdin commentedon Nov 18, 2017
@Gzernov, @t3hmrman, @pera The following workaround alleviates this issue on Arch Linux:
Install ghc with:
Then add
ghc-build: ncurses6
to~/.stack/config.yaml
, otherwisestack
will try to download and install thetinfo6-nopie
build on every attempt to usestack
.schoettl commentedon Nov 28, 2017
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:
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 triedstack --install-ghc; stack install xmonad
. The second command failed at thesetlocale
package with weiredld
related errors. After the changed thesettings
file everything worked.drvink commentedon Dec 20, 2017
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 #2712 (comment) fixes the issue for me.chrissound commentedon Dec 24, 2017
Adding
ghc-build: nopie
to~/.stack/config.yaml
fixed this for me.. Not sure if it's the same issue...borsboom commentedon Dec 24, 2017
@chrissound, @drvink: This is being discussed in #3518.
faq update: ld errors about recompiling with -fPIC
faq update: ld errors about recompiling with -fPIC
faq update: ld errors about recompiling with -fPIC