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-tinfo6-nopie-8.2.2 requires changes to its settings file to work on Arch Linux #3648

Closed
magthe opened this issue Dec 13, 2017 · 7 comments

Comments

@magthe
Copy link

magthe commented Dec 13, 2017

General summary/comments (optional)

Using the pre-built GHC requires changes to build packages on Arch Linux. This seems related to #3488, but not identical.

Steps to reproduce

Use the pre-built stack 1.6.1 from stackage.

  1. Try to build network version 2.6.3.2 or something else using autoconf.
  2. Use the information from (the closed???) Stack gives CFLAGS=-fno-PIE to autoconf #3488
  3. Try to build, it still doesn't work.
  4. Modify the settings file again, adding -fPIC to the "C compiler flags".
  5. Attempt another build.

Expected

A successful build without having to modify files shipped with pre-build GHC.

Actual

The following error:

Configuring network-2.6.3.2...
    configure: WARNING: unrecognized options: --with-compiler
    checking build system type... x86_64-pc-linux-gnu
    checking host system type... x86_64-pc-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/stack29898/network-2.6.3.2':
    configure: error: cannot run C compiled programs.
    If you meant to cross compile, use `--host'.
    See `config.log' for more details

Based on #3488 I changed -fno-PIE to -fno-pie in .stack/programs/x86_64-linux/ghc-tinfo6-nopie-8.2.2/lib/ghc-8.2.2/settings.

Attempting another build after that results in the same error.

Now add -fPIC to the settings file.

Attempt another build. Success!

Stack version

$ stack --version
Version 1.6.1, Git revision f25811329bbc40b0c21053a8160c56f923e1201b (5435 commits) x86_64 hpack-0.20.0

Method of installation

  • Official binary, downloaded from stackage.org or fpcomplete's package repository
@magthe
Copy link
Author

magthe commented Dec 13, 2017

Same seems to be true with ghc-tinfo6-nopie-8.0.2 as well.

Steps

stack unpack stack-1.6.1
cd stack-1.6.1
stack update
stack setup
stack build

Result

    Configuring basement-0.0.4...
    Building basement-0.0.4...
    Preprocessing library basement-0.0.4...
    /usr/bin/ld: .stack-work/dist/x86_64-linux-tinfo6-nopie/Cabal-1.24.2.0/build/Basement/Terminal/Size_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/Basement/Terminal/Size_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/Basement/Terminal/Size_hsc_make.o .stack-work/dist/x86_64-linux-tinfo6-nopie/Cabal-1.24.2.0/build/Basement/Terminal/Size_hsc_utils.o -o .stack-work/dist/x86_64-linux-tinfo6-nopie/Cabal-1.24.2.0/build/Basement/Terminal/Size_hsc_make -fno-PIE -fno-stack-protector -L/home/magnus/.stack/programs/x86_64-linux/ghc-tinfo6-nopie-8.0.2/lib/ghc-8.0.2/base-4.9.1.0 -Wl,-R,/home/magnus/.stack/programs/x86_64-linux/ghc-tinfo6-nopie-8.0.2/lib/ghc-8.0.2/base-4.9.1.0 -L/home/magnus/.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/magnus/.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/magnus/.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/magnus/.stack/programs/x86_64-linux/ghc-tinfo6-nopie-8.0.2/lib/ghc-8.0.2/ghc-prim-0.5.0.0 -L/home/magnus/.stack/programs/x86_64-linux/ghc-tinfo6-nopie-8.0.2/lib/ghc-8.0.2/rts -Wl,-R,/home/magnus/.stack/programs/x86_64-linux/ghc-tinfo6-nopie-8.0.2/lib/ghc-8.0.2/rts -lm -lrt -ldl -lpthread

and

    Configuring bindings-uname-0.1...
    Building bindings-uname-0.1...
    Preprocessing library bindings-uname-0.1...
    /usr/bin/ld: .stack-work/dist/x86_64-linux-tinfo6-nopie/Cabal-1.24.2.0/build/Bindings/Uname_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/Bindings/Uname_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/Bindings/Uname_hsc_make.o .stack-work/dist/x86_64-linux-tinfo6-nopie/Cabal-1.24.2.0/build/Bindings/Uname_hsc_utils.o -o .stack-work/dist/x86_64-linux-tinfo6-nopie/Cabal-1.24.2.0/build/Bindings/Uname_hsc_make -fno-PIE -fno-stack-protector -L/home/magnus/.stack/programs/x86_64-linux/ghc-tinfo6-nopie-8.0.2/lib/ghc-8.0.2/base-4.9.1.0 -Wl,-R,/home/magnus/.stack/programs/x86_64-linux/ghc-tinfo6-nopie-8.0.2/lib/ghc-8.0.2/base-4.9.1.0 -L/home/magnus/.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/magnus/.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/magnus/.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/magnus/.stack/programs/x86_64-linux/ghc-tinfo6-nopie-8.0.2/lib/ghc-8.0.2/ghc-prim-0.5.0.0 -L/home/magnus/.stack/programs/x86_64-linux/ghc-tinfo6-nopie-8.0.2/lib/ghc-8.0.2/rts -Wl,-R,/home/magnus/.stack/programs/x86_64-linux/ghc-tinfo6-nopie-8.0.2/lib/ghc-8.0.2/rts -lm -lrt -ldl -lpthread

Fix

Add -fPIC to the "C compiler flags" in settings.

@kozross
Copy link

kozross commented Dec 14, 2017

Just ran into this issue face-first, and I can confirm that it indeed affects both versions of GHC.

@dbaynard
Copy link
Contributor

dbaynard commented Dec 14, 2017

I just (re-)ran into the tinfo issue and couldn't find how I solved it last time. Luckily, I found the sed instruction:

sed -i 's/-fno-PIE/-no-pie/g' ~/.stack/programs/x86_64-linux/ghc-tinfo6-nopie-8.0.2/lib/ghc-8.0.2/settings

This seems to be a slightly different fix — it looks like the default option name is plain wrong (though I don't really know what's going on).

@ncaq
Copy link
Contributor

ncaq commented Dec 15, 2017

This problem exist to me too.
However, I use Gentoo Linux profile 17.0.

My env.

  • Gentoo profile default/linux/amd64/17.0/desktop
  • stack Version 1.6.1, Git revision f25811329bbc40b0c21053a8160c56f923e1201b (5435 commits) x86_64 hpack-0.20.0
  • GHC version is ghc-ncurses6-nopie-8.0.2

Gentoo profile 17.0 is GCC compile with enable-default-pie.
I think this is affecting.

I also solved the problem by adding @magthe PIC flag, but I do not think that writing a compilation flag by hand is a royal road.

I do not think this is a problem of Arch alone, I think it is a problem affecting the whole PIE effective system.

@ncaq
Copy link
Contributor

ncaq commented Dec 15, 2017

Since environment changed and ghc was installed in another place, I examined it.
~/.stack/programs/x86_64-linux/ghc-ncurses6-nopie-8.0.2/lib/ghc-8.0.2/settings does not contain -fno-PIE.
~/.stack/programs/x86_64-linux/ghc-tinfo6-nopie-8.0.2/lib/ghc-8.0.2/settings contain -fno-PIE.
Only ghc-tinfo6-nopie has become special -fno-PIE, which conflicts with PIE effective system?
I do not know why the presence or absence of PIE changes in ncurses and tinfo instead of nopie at all.
I read the code but did not understand immediately.

@dbaynard
Copy link
Contributor

I think this is related to #3521

@borsboom
Copy link
Contributor

I think this is a duplicate of #3518. Please re-open if you disagree.

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

6 participants