Building with recent binutils require --no-pie

Erik de Castro Lopo mle+hs at mega-nerd.com
Fri Nov 4 08:22:51 UTC 2016


Alan & Kim Zimmerman wrote:

> For anyone building on Debian testing or similar and getting linker
> failures, there is currently a workaround in progress by Ben Gamari that
> can be used.
> 
> It is based on first applying  D2672, D2673, and D2674 and then configuring
> with
> 
> ./configure \
>   CONF_CC_OPTS_STAGE2=-fno-PIE \
>   CONF_GCC_LINKER_OPTS_STAGE2=-no-pie \
>   CONF_LD_LINKER_OPTS_STAGE2=-no-pie \
>   CONF_CC_OPTS_STAGE0=-no-pie \
>   CONF_GCC_LINKER_OPTS_STAGE0=-no-pie \
>   CONF_LD_LINKER_OPTS_STAGE0=-no-pie \
>   CONF_HC_OPTS_STAGE0=-optl=-no-pie

Unfortunately, that is not sufficient. With the three patchs you listed
and the configure options above, the resulting GHC still fails to build
the 'magic' due to something going wrong with hsc2hs:

  Configuring magic-1.1...
  Building magic-1.1...
  Preprocessing library magic-1.1...
  /usr/bin/ld: dist/build/Magic/Data_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/Magic/Data_hsc_make.o failed (exit code 1)
  command was: /usr/bin/gcc dist/build/Magic/Data_hsc_make.o 
    dist/build/Magic/Data_hsc_utils.o -o dist/build/Magic/Data_hsc_make -fno-PIE 
    -fno-stack-protector -lmagic -L/usr/lib/ghc-8.0/lib/base-4.9.0.0 
    -Wl,-R,/usr/lib/ghc-8.0/lib/base-4.9.0.0 -L/usr/lib/ghc-8.0/lib/integer-gmp-1.0.0.1 
    -Wl,-R,/usr/lib/ghc-8.0/lib/integer-gmp-1.0.0.1 
    -lgmp -L/usr/lib/ghc-8.0/lib/ghc-prim-0.5.0.0 
    -Wl,-R,/usr/lib/ghc-8.0/lib/ghc-prim-0.5.0.0 -L/usr/lib/ghc-8.0/lib/rts 
    -Wl,-R,/usr/lib/ghc-8.0/lib/rts -lm -lrt -ldl -lffi


Erik
-- 
----------------------------------------------------------------------
Erik de Castro Lopo
http://www.mega-nerd.com/


More information about the ghc-devs mailing list