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

Bug 182784

Summary: games-simulation/openttd-0.5.2 fails w/ Wl,--as-needed
Product: Gentoo Linux Reporter: Conrad Kostecki <conikost>
Component: [OLD] GamesAssignee: Lars Weiler (RETIRED) <pylon>
Severity: normal CC: games
Priority: High    
Version: 2007.0   
Hardware: All   
OS: Linux   
Package list:
Runtime testing required: ---
Bug Depends on:    
Bug Blocks: 129413    
Attachments: openttd-0.5.2-r1.patch

Description Conrad Kostecki gentoo-dev 2007-06-21 12:57:04 UTC
I would suggest, we should filter the ldflag "-Wl,--as-needed"
I know, that there are using some people this.

I can reproduce this error on all of my gentoo pcs.

So it should be filtered. If the flag is enabled, we get this error:

===> Linking openttd
thread.o: In function `OTTDJoinThread':
thread.c:(.text+0x20): undefined reference to `pthread_join'
thread.o: In function `OTTDCreateThread':
thread.c:(.text+0x62): undefined reference to `pthread_create'
collect2: ld gab 1 als Ende-Status zurück
make: *** [openttd] Fehler 1

!!! ERROR: games-simulation/openttd-0.5.2 failed.
Call stack:, line 1629:   Called dyn_compile, line 975:   Called qa_call 'src_compile', line 44:   Called src_compile
  openttd-0.5.2.ebuild, line 83:   Called die

!!! emake failed
!!! If you need support, post the topmost build error, and the call stack if relevant.
!!! A complete build log is located at '/var/tmp/portage/games-simulation/openttd-0.5.2/temp/build.log'.
Comment 1 Conrad Kostecki gentoo-dev 2007-06-21 12:57:30 UTC
Created attachment 122695 [details, diff]


patch against openttd-0.5.2.ebuild
Comment 2 Arfrever Frehtes Taifersar Arahesis (RETIRED) gentoo-dev 2007-06-21 17:51:19 UTC
Rather -lpthread should be added somewhere.
Comment 3 Conrad Kostecki gentoo-dev 2007-06-21 17:56:54 UTC
Oke, if this help? So lets add this.
Comment 4 Arfrever Frehtes Taifersar Arahesis (RETIRED) gentoo-dev 2007-06-21 18:55:22 UTC
I just checked and I can build it with -Wl,--as-needed :) .
Comment 5 Conrad Kostecki gentoo-dev 2007-06-21 19:28:30 UTC
Hmm strange. You are right. It seems to work.

-Wl,--as-needed works alone! But if i use it together with another ldflags (it doesn't matter which other!) i get this error.

USE="-lpthread" does not help.

So i would guess, we should remove -Wl,--as-needed if its not used alone!
Comment 6 Arfrever Frehtes Taifersar Arahesis (RETIRED) gentoo-dev 2007-06-22 17:49:13 UTC
I have LDFLAGS="-Wl,-O1,--as-needed,--hash-style=gnu,--sort-common,-z,relro".

(-lname is linker option, it causes linking with or libname.a, if the former isn't available or option -static is used.)
Comment 7 Conrad Kostecki gentoo-dev 2007-06-22 18:01:02 UTC
Just for testing, with your LDFLAGS i am NOT able to build openttd :(

(--hash-style=gnu does not work, as my binutils are only 2.17)

only LDFLAGS="-Wl,--as-needed" alone works here.

But --as-needed combined with another LDFLAGS like --sort-common or -z,now or other, it always fails!

===> Linking openttd
thread.o: In function `OTTDJoinThread':
thread.c:(.text+0x2c): undefined reference to `pthread_join'
thread.o: In function `OTTDCreateThread':
thread.c:(.text+0x84): undefined reference to `pthread_create'
collect2: ld gab 1 als Ende-Status zurück
make: *** [openttd] Fehler 1
Comment 8 Lars Weiler (RETIRED) gentoo-dev 2007-06-22 23:06:43 UTC
I can't reproduce your problem.  But that might be, that I built my complete system without any LDFLAGS set.  And according to we don't support fixing broken/critical LDFLAGS.  Stick with the defaults and you will be happy.

Probably one of your reverse-dependency is broken?  Check your system and build with a sane environment.
Comment 9 Conrad Kostecki gentoo-dev 2007-06-22 23:15:25 UTC
I checked this ;) On a System without LDFlags and on my System with complete LDFlags! 

Both don't compile.
Comment 10 Conrad Kostecki gentoo-dev 2007-06-22 23:43:35 UTC
Hey Guys ... is that normal?

THIS WORKS: LDFLAGS="-Wl,--as-needed -Wl,--sort-common -s -Wl,-O1 -Wl,-z,now"
THIS WORKS NOT: LDFLAGS=" -Wl,-O1 -Wl,--as-needed -Wl,--sort-common -s  -Wl,-z,now"

Could somebody explain me, why only the first works? The second only is chanced, so --as-needed is first? oO