Bug 635581

Summary: [gold] problems building ghc with gold linker
Product: [Fedora] Fedora Reporter: Michal Nowak <mnowak>
Component: ghcAssignee: Jens Petersen <petersen>
Status: CLOSED DEFERRED QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: medium Docs Contact:
Priority: low    
Version: rawhideCC: bos, haskell-devel, loupgaroublond, ohudlick, petersen
Target Milestone: ---   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
: 635935 635965 (view as bug list) Environment:
Last Closed: 2010-09-21 08:17:17 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On: 635935, 635965    
Bug Blocks:    

Description Michal Nowak 2010-09-20 09:03:26 UTC
Description of problem:

ghc-6.12.3-5.fc15.src.rpm rebuild with gold (the alternative linker in binutils) fails because configure script won't find curses:

DEBUG:   ncurses.x86_64 0:5.7-8.20100703.fc14                                          
DEBUG:   ncurses-base.x86_64 0:5.7-8.20100703.fc14                                     
DEBUG:   ncurses-libs.x86_64 0:5.7-8.20100703.fc14                                     
DEBUG:   ncurses-base.x86_64 0:5.7-8.20100703.fc14                                     
DEBUG:   ncurses-libs.x86_64 0:5.7-8.20100703.fc14                                     
DEBUG: /usr/bin/yum --installroot /var/lib/mock/fedora-rawhide-x86_64/root/  resolvedep  ccache  'libffi-devel' 'gmp-devel' 'ghc-rpm-macros >= 0.8.0' 'ncurses-devel' 'python' 'docbook-style-xsl' 'ghc' 'libxslt' 'hscolour' 'happy'
DEBUG: Executing command: /usr/bin/yum --installroot /var/lib/mock/fedora-rawhide-x86_64/root/  resolvedep  ccache  'libffi-devel' 'gmp-devel' 'ghc-rpm-macros >= 0.8.0' 'ncurses-devel' 'python' 'docbook-style-xsl' 'ghc' 'libxslt' 'hscolour' 'happy' --setopt=tsflags=nocontexts
DEBUG: 0:ncurses-devel-5.7-8.20100703.fc14.x86_64
DEBUG: /usr/bin/yum --installroot /var/lib/mock/fedora-rawhide-x86_64/root/  install  ccache  'libffi-devel' 'gmp-devel' 'ghc-rpm-macros >= 0.8.0' 'ncurses-devel' 'python' 'docbook-style-xsl' 'ghc' 'libxslt' 'hscolour' 'happy'
DEBUG: Executing command: /usr/bin/yum --installroot /var/lib/mock/fedora-rawhide-x86_64/root/  install  ccache  'libffi-devel' 'gmp-devel' 'ghc-rpm-macros >= 0.8.0' 'ncurses-devel' 'python' 'docbook-style-xsl' 'ghc' 'libxslt' 'hscolour' 'happy' --setopt=tsflags=nocontexts
DEBUG:  ncurses-devel          x86_64      5.7-8.20100703.fc14       fedora      663 k
DEBUG:   libxslt.x86_64 0:1.1.26-3.fc14    ncurses-devel.x86_64 0:5.7-8.20100703.fc14  
DEBUG: checking ncurses.h usability... yes
DEBUG: checking ncurses.h presence... yes
DEBUG: checking for ncurses.h... yes
DEBUG: checking for setupterm in -lncursesw... no
DEBUG: checking for setupterm in -lncurses... no

Version-Release number of selected component (if applicable):

ghc-6.12.3-5.fc15

How reproducible:

always (x86_64)

Steps to Reproduce:
1. alternatives --config ld
2. set gold
3. rebuild ghc srpm
  
Actual results:


Expected results:

DEBUG:   ncurses.x86_64 0:5.7-8.20100703.fc14                                          
DEBUG:   ncurses-base.x86_64 0:5.7-8.20100703.fc14                                     
DEBUG:   ncurses-base.x86_64 0:5.7-8.20100703.fc14                                     
DEBUG:   ncurses-libs.x86_64 0:5.7-8.20100703.fc14                                     

DEBUG: /usr/bin/yum --installroot /var/lib/mock/fedora-rawhide-x86_64/root/  resolvedep  ccache  'libffi-devel' 'gmp-devel' 'ghc-rpm-macros >= 0.8.0' 'ncurses-devel' 'python' 'docbook-style-xsl' 'ghc' 'libxslt' 'hscolour' 'happy'
DEBUG: Executing command: /usr/bin/yum --installroot /var/lib/mock/fedora-rawhide-x86_64/root/  resolvedep  ccache  'libffi-devel' 'gmp-devel' 'ghc-rpm-macros >= 0.8.0' 'ncurses-devel' 'python' 'docbook-style-xsl' 'ghc' 'libxslt' 'hscolour' 'happy' --setopt=tsflags=nocontexts
DEBUG: 0:ncurses-devel-5.7-8.20100703.fc14.x86_64
DEBUG: /usr/bin/yum --installroot /var/lib/mock/fedora-rawhide-x86_64/root/  install  ccache  'libffi-devel' 'gmp-devel' 'ghc-rpm-macros >= 0.8.0' 'ncurses-devel' 'python' 'docbook-style-xsl' 'ghc' 'libxslt' 'hscolour' 'happy'
DEBUG: Executing command: /usr/bin/yum --installroot /var/lib/mock/fedora-rawhide-x86_64/root/  install  ccache  'libffi-devel' 'gmp-devel' 'ghc-rpm-macros >= 0.8.0' 'ncurses-devel' 'python' 'docbook-style-xsl' 'ghc' 'libxslt' 'hscolour' 'happy' --setopt=tsflags=nocontexts
DEBUG:  ncurses-devel          x86_64      5.7-8.20100703.fc14       fedora      663 k
DEBUG:   libxslt.x86_64 0:1.1.26-3.fc14    ncurses-devel.x86_64 0:5.7-8.20100703.fc14  
DEBUG: checking ncurses.h usability... yes
DEBUG: checking ncurses.h presence... yes
DEBUG: checking for ncurses.h... yes
DEBUG: checking for setupterm in -lncursesw... yes

Additional info:

Since gold might be the default linker (per http://fedoraproject.org/wiki/Features/GoldLinkerDefault) this problem might be worth fixing.

Comment 1 Jens Petersen 2010-09-21 01:18:07 UTC
Could you please attach the full buildlog?

I tried on F14 with gold and it seems to find ncurses fine.

Comment 2 Jens Petersen 2010-09-21 02:24:19 UTC
Well as above I can't reproduce the ncurses issue on F14
(perhaps that only happens on F15?).

However later in the build I ran into:

"inplace/bin/ghc-stage1"   -H32m -O    -package-name ghc-prim-0.2.0.0 -hide-all-packages -i -ilibraries/ghc-prim/. -ilibraries/ghc-prim/dist-install/build -ilibraries/ghc-prim/dist-install/build/autogen -Ilibraries/ghc-prim/dist-install/build -Ilibraries/ghc-prim/dist-install/build/autogen -Ilibraries/ghc-prim/.    -optP-include -optPlibraries/ghc-prim/dist-install/build/autogen/cabal_macros.h -package rts-1.0 -split-objs -package-name ghc-prim -XCPP -XMagicHash -XForeignFunctionInterface -XUnliftedFFITypes -XUnboxedTuples -XEmptyDataDecls -XNoImplicitPrelude -O2 -XGenerics -fno-warn-deprecated-flags     -odir libraries/ghc-prim/dist-install/build -hidir libraries/ghc-prim/dist-install/build -stubdir libraries/ghc-prim/dist-install/build -hisuf hi -osuf  o -hcsuf hc -c libraries/ghc-prim/./GHC/Generics.hs -o libraries/ghc-prim/dist-install/build/GHC/Generics.o
/usr/bin/ld: error: cannot find libraries/ghc-prim/dist-install/build/GHC/Generics_o_split/Generics__1.o
/usr/bin/ld: error: cannot find libraries/ghc-prim/dist-install/build/GHC/Generics_o_split/.o::Generics(void)
/usr/bin/ld: error: cannot find libraries/ghc-prim/dist-install/build/GHC/Generics_o_split/Generics__3.o
/usr/bin/ld: error: cannot find libraries/ghc-prim/dist-install/build/GHC/Generics_o_split/Generics__4.o
/usr/bin/ld: error: cannot find libraries/ghc-prim/dist-install/build/GHC/Generics_o_split/Generics__5.o
/usr/bin/ld: error: cannot find libraries/ghc-prim/dist-install/build/GHC/Generics_o_split/Generics__6.o
/usr/bin/ld: error: cannot find libraries/ghc-prim/dist-install/build/GHC/Generics_o_split/Generics__7.o
/usr/bin/ld: error: cannot find libraries/ghc-prim/dist-install/build/GHC/Generics_o_split/Generics__8.o
/usr/bin/ld: error: cannot find libraries/ghc-prim/dist-install/build/GHC/Generics_o_split/Generics__9.o
/usr/bin/ld: error: cannot find libraries/ghc-prim/dist-install/build/GHC/Generics_o_split/Generics__10.o
/usr/bin/ld: error: cannot find libraries/ghc-prim/dist-install/build/GHC/Generics_o_split/Generics__11.o
/usr/bin/ld: error: cannot find libraries/ghc-prim/dist-install/build/GHC/Generics_o_split/Generics__12.o
/usr/bin/ld: error: cannot find libraries/ghc-prim/dist-install/build/GHC/Generics_o_split/Generics__13.o
/usr/bin/ld: error: cannot find libraries/ghc-prim/dist-install/build/GHC/Generics_o_split/Generics__14.o
/usr/bin/ld: error: cannot find libraries/ghc-prim/dist-install/build/GHC/Generics_o_split/Generics__15.o
/usr/bin/ld: error: cannot find libraries/ghc-prim/dist-install/build/GHC/Generics_o_split/Generics__16.o
collect2: ld returned 1 exit status
make[1]: *** [libraries/ghc-prim/dist-install/build/GHC/Generics.o] Error 1
make: *** [all] Error 2

I see a link script:

[ghc-6.12.3]$ ls libraries/ghc-prim/dist-install/build/GHC/Generics_o_split/
Generics__1.o   Generics__12.o  Generics__15.o  Generics__3.o   Generics__6.o   Generics__9.o   
Generics__10.o  Generics__13.o  Generics__16.o  Generics__4.o   Generics__7.o   ld.script       
Generics__11.o  Generics__14.o  Generics__2.o   Generics__5.o   Generics__8.o   
[petersen@localhost ghc-6.12.3]$ less libraries/ghc-prim/dist-install/build/GHC/Generics_o_split/ld.script 
[petersen@localhost ghc-6.12.3]$ cat libraries/ghc-prim/dist-install/build/GHC/Generics_o_split/ld.script 
INPUT(libraries/ghc-prim/dist-install/build/GHC/Generics_o_split/Generics__1.o libraries/ghc-prim/dist-install/build/GHC/Generics_o_split/Generics__2.o libraries/ghc-prim/dist-install/build/GHC/Generics_o_split/Generics__3.o libraries/ghc-prim/dist-install/build/GHC/Generics_o_split/Generics__4.o libraries/ghc-prim/dist-install/build/GHC/Generics_o_split/Generics__5.o libraries/ghc-prim/dist-install/build/GHC/Generics_o_split/Generics__6.o libraries/ghc-prim/dist-install/build/GHC/Generics_o_split/Generics__7.o libraries/ghc-prim/dist-install/build/GHC/Generics_o_split/Generics__8.o libraries/ghc-prim/dist-install/build/GHC/Generics_o_split/Generics__9.o libraries/ghc-prim/dist-install/build/GHC/Generics_o_split/Generics__10.o libraries/ghc-prim/dist-install/build/GHC/Generics_o_split/Generics__11.o libraries/ghc-prim/dist-install/build/GHC/Generics_o_split/Generics__12.o libraries/ghc-prim/dist-install/build/GHC/Generics_o_split/Generics__13.o libraries/ghc-prim/dist-install/build/GHC/Generics_o_split/Generics__14.o libraries/ghc-prim/dist-install/build/GHC/Generics_o_split/Generics__15.o libraries/ghc-prim/dist-install/build/GHC/Generics_o_split/Generics__16.o)

Checking the verbose ghc output the problem occurs here with :

/usr/bin/gcc -nostdlib -nodefaultlibs -Wl,-r -Wl,-x -o libraries/ghc-prim/dist-install/build/GHC/Generics.o libraries/ghc-prim/dist-install/build/GHC/Generics_o_split/ld.script

Editing the linking script generated by ghc-split:

[ghc-6.12.3]$ sed -i.orig -e "s%libraries/ghc-prim/dist-install/build/GHC/Generics_o_split/%%g" libraries/ghc-prim/dist-install/build/GHC/Generics_o_split/ld.script
[ghc-6.12.3]$ /usr/bin/gcc -nostdlib -nodefaultlibs -Wl,-r -Wl,-x -o libraries/ghc-prim/dist-install/build/GHC/Generics.o libraries/ghc-prim/dist-install/build/GHC/Generics_o_split/ld.script
[ghc-6.12.3]$ 

So question that arises is should ld.gold support relative paths in
link scripts or should ghc be changes to just like the local objects?

Comment 3 Jens Petersen 2010-09-21 02:51:14 UTC
The above sed change only works with ld.gold not ld.bfd.
So it seems to be a ld.gold change of behaviour or regression
compared to ld.bfd.  I would be willing to patch ghc for
Fedora if ld.gold and ld.bfd can agree on at least one of
the versions of link scripts working.

Comment 4 Jens Petersen 2010-09-21 03:21:28 UTC
Ah I reproduced the ncurses problem with binutils-2.20.51.0.11-1.fc15.
Interesting that binutils-2.20.51.0.7-5.fc14 is ok.

That is known issue with the libncurses*.so link script "hacks" in Fedora.
I already have a workaround patch for ghc-terminfo (in package review)
which could be applied to ghc's internal copy of terminfo too.

Comment 5 Jens Petersen 2010-09-21 07:20:39 UTC
Note that the ncurses issue is not ghc specific: I tested
less and w3m for example and they also fail to configure
ncurses.  less builds with ncurses, but w3m fails to link.

I guess ld.gold is not compatible with current ld.scripts.

Comment 6 Jens Petersen 2010-09-21 07:31:30 UTC
I filed bug 635965 for the ld.gold ncurses issue.

Perhaps this bug could be closed.

Comment 7 Michal Nowak 2010-09-21 08:17:17 UTC
Yes, we can close this one since it's not ghc specific. Thanks for investigation, Jens.