Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!

Bug 606666

Summary: dev-lang/ghc-7.10.3 : /.../ld: utils/.../Main.o: relocation R_X86_64_32S against `.text' can not be used when making a shared object; recompile with -fPIC
Product: Gentoo Linux Reporter: Toralf Förster <toralf>
Component: Current packagesAssignee: Gentoo's Haskell Language team <haskell>
Status: RESOLVED FIXED    
Severity: normal CC: hendrik, jarausch
Priority: Normal    
Version: unspecified   
Hardware: All   
OS: Linux   
See Also: https://bugs.gentoo.org/show_bug.cgi?id=639096
Whiteboard:
Package list:
Runtime testing required: ---
Attachments: emerge-info.txt
config.log
dev-lang:ghc-7.10.3:20170121-045138.log
emerge-history.txt
environment
etc.portage.tbz2

Description Toralf Förster gentoo-dev 2017-01-21 08:38:36 UTC
GHC target : x86_64-unknown-linux
configure: Building in-tree ghc-pwd
/usr/lib/gcc/x86_64-pc-linux-gnu/6.3.0/../../../../x86_64-pc-linux-gnu/bin/ld: utils/ghc-pwd/dist-boot/Main.o: relocation R_X86_64_32S against `.text' can not be used when making a shared object; recompile with -fPIC
utils/ghc-pwd/dist-boot/Main.o: error adding symbols: Bad value
collect2: error: ld returned 1 exit status
configure: error: Building ghc-pwd failed

  -----------------------------------------------------------------

  This is an unstable amd64 chroot image (named hardened-unstable_20170120-150937) at a hardened host acting as a tinderbox.

  -----------------------------------------------------------------

gcc-config -l:
 [1] x86_64-pc-linux-gnu-6.3.0 *
llvm-config --version:
3.9.1

Available Python interpreters, in order of preference:
  [1]   python3.4
  [2]   python2.7 (fallback)
Available Ruby profiles:
  [1]   ruby21 (with Rubygems) *
java-config:

  -----------------------------------------------------------------
Comment 1 Toralf Förster gentoo-dev 2017-01-21 08:38:39 UTC
Created attachment 460780 [details]
emerge-info.txt
Comment 2 Toralf Förster gentoo-dev 2017-01-21 08:38:42 UTC
Created attachment 460782 [details]
config.log
Comment 3 Toralf Förster gentoo-dev 2017-01-21 08:38:46 UTC
Created attachment 460784 [details]
dev-lang:ghc-7.10.3:20170121-045138.log
Comment 4 Toralf Förster gentoo-dev 2017-01-21 08:38:50 UTC
Created attachment 460786 [details]
emerge-history.txt
Comment 5 Toralf Förster gentoo-dev 2017-01-21 08:38:53 UTC
Created attachment 460788 [details]
environment
Comment 6 Toralf Förster gentoo-dev 2017-01-21 08:38:56 UTC
Created attachment 460790 [details]
etc.portage.tbz2
Comment 7 Sergei Trofimovich (RETIRED) gentoo-dev 2017-01-21 10:56:11 UTC
It's not very clear what USEs were used for gcc-6.3.0. It's USE=pie, right?
Comment 8 Toralf Förster gentoo-dev 2017-01-21 13:30:43 UTC
(In reply to Sergei Trofimovich from comment #7)
yes, the attached emerge-info.txt rukes, and etc.portage.tbz21 would contain an appropriate package.use/<foo> file otherwise,

but here explicitely:




=================================================================
                        Package Settings
=================================================================

sys-devel/gcc-6.3.0::gentoo was built with the following:
USE="cxx hardened (multilib) nls nptl openmp (pie) (ssp) vtv (-altivec) (-awt) -cilk -debug -doc (-fixed-point) -fortran (-gcj) -go -graphite (-jit) (-libssp) -mpx -objc -objc++ -objc-gc (-pch) -regression-test (-sanitize) -vanilla" ABI_X86="64"
CXXFLAGS="-O2 -pipe -march=native"
Comment 9 Helmut Jarausch 2017-02-06 16:02:30 UTC
I have the same problem here running gcc-6.3.0, as well.

I see symbols like mkstemps@@GLIBC_2.11 which don't occur on my system (I have glibc-2.24)

After unpacking there is a directory 
/var/tmp/Big_Tmp/portage/dev-lang/ghc-7.10.3/work/usr/lib64/ghc-7.10.3 which contains old libraries (from a foreign system) which cause this error.

How can I rebuild this libraries i.e. how can I bootstrap ghc on my system?

Thanks,
Helmut
Comment 10 Sergei Trofimovich (RETIRED) gentoo-dev 2017-02-06 20:48:21 UTC
(In reply to Helmut Jarausch from comment #9)
> I have the same problem here running gcc-6.3.0, as well.
> 
> I see symbols like mkstemps@@GLIBC_2.11 which don't occur on my system (I
> have glibc-2.24)

That is unexpected.
$ readelf -a /lib/libc-2.24.so | grep mkstemps
  1635: 00000034192e1940    36 FUNC    WEAK   DEFAULT   12 mkstemps64@@GLIBC_2.11
  1797: 00000034192e1940    36 FUNC    GLOBAL DEFAULT   12 mkstemps@@GLIBC_2.11
Comment 11 Helmut Jarausch 2017-02-13 11:55:34 UTC
ghc cannot be build with gcc-6.3.0 .

(Stepping back to 5.4.0 via gcc-config does build ghc)

Even version 8.0.2 fails with (LOTS of errors like)
utils/ghc-pwd/dist-boot/Main.o: relocation R_X86_64_32S against `.text' can not be used when making a shared object; recompile with -fPIC

It looks like the prebuilt libraries should be compiled with -fPIC.

I don't think this would be harmful. But I cannot do it myself.
Any hints how to recompile these are much appreciated.
Comment 12 Sergei Trofimovich (RETIRED) gentoo-dev 2017-02-14 08:48:38 UTC
(In reply to Helmut Jarausch from comment #11)
> ghc cannot be build with gcc-6.3.0 .
> 
> (Stepping back to 5.4.0 via gcc-config does build ghc)
> 
> Even version 8.0.2 fails with (LOTS of errors like)
> utils/ghc-pwd/dist-boot/Main.o: relocation R_X86_64_32S against `.text' can
> not be used when making a shared object; recompile with -fPIC
> 
> It looks like the prebuilt libraries should be compiled with -fPIC.
> 
> I don't think this would be harmful. But I cannot do it myself.
> Any hints how to recompile these are much appreciated.

Can you provide a build.log and emerge --info so I could reproduce an error?
8.0.2 is supposed to just work on hardened.
Comment 13 Sergei Trofimovich (RETIRED) gentoo-dev 2017-02-14 09:35:06 UTC
Finally reproduced it as:

$ USE=pie emerge -1 gcc
$ USE=-ghcbootstrap emerge -1 =ghc-8.0.2

GHC build  : x86_64-unknown-linux
GHC host   : x86_64-unknown-linux
GHC target : x86_64-unknown-linux
configure: Building in-tree ghc-pwd
/usr/lib/gcc/x86_64-pc-linux-gnu/6.3.0/../../../../x86_64-pc-linux-gnu/bin/ld: utils/ghc-pwd/dist-boot/Main.o: relocation R_X86_64_32S against `.text' can not be used when making a shared object; recompile with -fPIC
/usr/lib/gcc/x86_64-pc-linux-gnu/6.3.0/../../../../x86_64-pc-linux-gnu/bin/ld: /dev/shm/portage/dev-lang/ghc-8.0.2/work/usr/lib64/ghc-8.0.2/directory-1.3.0.0/libHSdirectory-1.3.0.0.a(Directory__307.o): relocation R_X86_64_32 against symbol `directoryzm1zi3zi0zi0_SystemziDirectory_getCurrentDirectory2_closure' can not be used when making a shared object; recompile with -fPIC
/usr/lib/gcc/x86_64-pc-linux-gnu/6.3.0/../../../../x86_64-pc-linux-gnu/bin/ld: /dev/shm/portage/dev-lang/ghc-8.0.2/work/usr/lib64/ghc-8.0.2/directory-1.3.0.0/libHSdirectory-1.3.0.0.a(Directory__302.o): relocation R_X86_64_32 against symbol `directoryzm1zi3zi0zi0_SystemziDirectory_getCurrentDirectory7_closure' can not be used when making a shared object; recompile with -fPIC
...
Comment 14 Sergei Trofimovich (RETIRED) gentoo-dev 2017-02-14 09:54:17 UTC
The workaround is to use 'LDFLAGS=-no-pie' as:
    LDFLAGS=-no-pie emerge -1 =ghc-8.0.2

I'll add is to the ebuild based on gcc version switch as we did with hardened/-nopie.
Comment 15 Sergei Trofimovich (RETIRED) gentoo-dev 2017-02-14 22:24:36 UTC
(In reply to Sergei Trofimovich from comment #14)
> The workaround is to use 'LDFLAGS=-no-pie' as:
>     LDFLAGS=-no-pie emerge -1 =ghc-8.0.2
> 
> I'll add is to the ebuild based on gcc version switch as we did with
> hardened/-nopie.

Pushed hopefully working fix as:

https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=8274b84fb061ddcb1318f1ba5625b41b197e6987

Thanks everyone!