corsis / clock

High-resolution clock functions: monotonic, realtime, cputime.
Other
58 stars 25 forks source link

Build issue on Stackage LTS 7.4 (GHC 8.0.1) on Ubuntu Yakkety #43

Closed korayal closed 7 years ago

korayal commented 8 years ago

It seems I can't build this project using Stackage LTS 7.4, which causes me to fail building other projects that use this specific library (Tasty). Here is what I did:

stack init

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

Selecting the best among 9 snapshots...

* Matches lts-7.4

Selected resolver: lts-7.4
Initialising configuration using resolver: lts-7.4
Total number of user packages considered: 1
Writing configuration to file: stack.yaml
All done.

stack build

clock-0.7.2: configure (lib)
Configuring clock-0.7.2...
clock-0.7.2: build (lib)
Preprocessing library clock-0.7.2...
Clock.hsc:44:0: warning: "hsc_alignment" redefined
In file included from .stack-work/dist/x86_64-linux-nopie/Cabal-1.24.0.0/build/System/Clock_hsc_make.c:1:0:
/home/korayal/.stack/programs/x86_64-linux/ghc-nopie-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: .stack-work/dist/x86_64-linux-nopie/Cabal-1.24.0.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-nopie/Cabal-1.24.0.0/build/System/Clock_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/System/Clock_hsc_make.o .stack-work/dist/x86_64-linux-nopie/Cabal-1.24.0.0/build/System/Clock_hsc_utils.o -o .stack-work/dist/x86_64-linux-nopie/Cabal-1.24.0.0/build/System/Clock_hsc_make -fno-PIE -fno-stack-protector -L/home/korayal/.stack/programs/x86_64-linux/ghc-nopie-8.0.1/lib/ghc-8.0.1/base-4.9.0.0 -Wl,-R,/home/korayal/.stack/programs/x86_64-linux/ghc-nopie-8.0.1/lib/ghc-8.0.1/base-4.9.0.0 -L/home/korayal/.stack/programs/x86_64-linux/ghc-nopie-8.0.1/lib/ghc-8.0.1/integer-gmp-1.0.0.1 -Wl,-R,/home/korayal/.stack/programs/x86_64-linux/ghc-nopie-8.0.1/lib/ghc-8.0.1/integer-gmp-1.0.0.1 -lgmp -L/home/korayal/.stack/programs/x86_64-linux/ghc-nopie-8.0.1/lib/ghc-8.0.1/ghc-prim-0.5.0.0 -Wl,-R,/home/korayal/.stack/programs/x86_64-linux/ghc-nopie-8.0.1/lib/ghc-8.0.1/ghc-prim-0.5.0.0 -L/home/korayal/.stack/programs/x86_64-linux/ghc-nopie-8.0.1/lib/ghc-8.0.1/rts -Wl,-R,/home/korayal/.stack/programs/x86_64-linux/ghc-nopie-8.0.1/lib/ghc-8.0.1/rts -lm -lrt -ldl

--  While building package clock-0.7.2 using:
      /home/korayal/.stack/setup-exe-cache/x86_64-linux-nopie/Cabal-simple_qDiHe4NR_1.24.0.0_ghc-8.0.1 --builddir=.stack-work/dist/x86_64-linux-nopie/Cabal-1.24.0.0 build lib:clock --ghc-options " -ddump-hi -ddump-to-file"
    Process exited with code: ExitFailure 1
korayal commented 8 years ago

adding cc-options: -fPIC to the cabal file seems to fix the issue on my end. But I'm not sure if it'll cause any problems on older versions of GCC.

rbasso commented 8 years ago

I cannot reproduce the problem in Debian Stable (jessie) - with stack 1.2.0 or from master - but I have exactly the same problem in Debian Unstable (sid) running stack from master (cannot test with stack 1.2.0).

Setting cc-options: -fPIC also worked for me.

The problem seems restricted to stack snapshots using GHC 8.0.1 (>= lts-7.0 || >= nightly-2016-05-26).

Possibly related to commercialhaskell/stack#2712.

rbasso commented 8 years ago

Package digest seems to suffer from the exactly same problem. I bet there are other packages...

Not sure where this should be fixed.

CetinSert commented 8 years ago

So should I just add that cc-options: -fPIC to clock.cabal now?

rbasso commented 8 years ago

Considering that there are other packages displaying the same problem, I would wait until the cause is clearer before changing anything, @cetinsert. Maybe this has to be fixed elsewhere.

korayal commented 7 years ago

This issue seems to be fixed when this specific version is used instead of previous GHC 8.0.1 versions:

http://downloads.haskell.org/~ghc/8.0.2-rc1/ghc-8.0.1.20161117-x86_64-deb8-linux.tar.xz

simonmichael commented 6 years ago

Hi, we have hit this recently when building the clock package for hledger on Arch Linux. Does anyone know the cause/proper fix for it ?

simonmichael commented 6 years ago

PS, using ghc 8.0.2. Issue: https://github.com/simonmichael/hledger/issues/668

CetinSert commented 6 years ago

@simonmichael so is this fixed with -no-pie?

simonmichael commented 6 years ago

Yes, apparently.