Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 215085 - dev-games/ogre - Fix --as-needed with cg
Summary: dev-games/ogre - Fix --as-needed with cg
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: [OLD] Games (show other bugs)
Hardware: All Linux
: High normal (vote)
Assignee: Gentoo Games
URL: http://www.ogre3d.org
Whiteboard:
Keywords:
Depends on:
Blocks: as-needed
  Show dependency tree
 
Reported: 2008-03-27 17:43 UTC by James Le Cuirot
Modified: 2008-04-09 17:16 UTC (History)
1 user (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
ogre-1.4.7.ebuild (ogre-1.4.7.ebuild,2.21 KB, text/plain)
2008-03-27 17:44 UTC, James Le Cuirot
Details
ogre-1.4.7-as-needed.patch (ogre-1.4.7-as-needed.patch,428 bytes, patch)
2008-04-09 17:16 UTC, James Le Cuirot
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description James Le Cuirot gentoo-dev 2008-03-27 17:43:07 UTC
Because of the way NVIDIA linked their Cg toolkit, building Ogre with the cg USE flag enabled and -Wl,--as-needed in your LDFLAGS doesn't work. Here's a new ebuild that filters the flags.
Comment 1 James Le Cuirot gentoo-dev 2008-03-27 17:44:29 UTC
Created attachment 147461 [details]
ogre-1.4.7.ebuild

Probably no point in incrementing the revision number.
Comment 2 Mr. Bones. (RETIRED) gentoo-dev 2008-04-08 16:47:40 UTC
in portage.  thanks for the bug report and patch.
Comment 3 Sander Sweers 2008-04-08 17:00:42 UTC
Filtering --as-needed is just hiding a bug. It should either be left open or fixed.
Comment 4 Mr. Bones. (RETIRED) gentoo-dev 2008-04-08 17:04:37 UTC
talk is cheap - patches welcome.
Comment 5 James Le Cuirot gentoo-dev 2008-04-08 17:24:18 UTC
The command that causes the error is...

gcc -o conftest <CFLAGS> -Wl,--as-needed conftest.c -lCg -lILU -lIL -lpthread -lz -lm -ldl

If you add (or move) -lpthread and -lm before the -Wl,--as-needed option then it works. Maybe you could do some trick with -Wl,--no-as-needed but you'd have to make sure that -Wl,--as-needed is added again afterwards and ONLY when it is wanted. It could be done but it wouldn't be too pretty.

There are two lines in the configure script that add the -lCg option and they read LIBS="-lCg $LIBS". Maybe something could be done with this.
Comment 6 Sander Sweers 2008-04-08 18:43:22 UTC
(In reply to comment #4)
> talk is cheap - patches welcome.

Sigh...

(In reply to comment #5)
> The command that causes the error is...
> 
> gcc -o conftest <CFLAGS> -Wl,--as-needed conftest.c -lCg -lILU -lIL -lpthread
> -lz -lm -ldl
> 
> If you add (or move) -lpthread and -lm before the -Wl,--as-needed option then
> it works. 
> 
> There are two lines in the configure script that add the -lCg option and they
> read LIBS="-lCg $LIBS". Maybe something could be done with this.

Probably changing the linking order from LIBS="-lCg $LIBS" to LIBS="$LIBS -lCg" will fix it. But I am not able to test that for another week. Could you have a go at it?
Comment 7 James Le Cuirot gentoo-dev 2008-04-08 19:12:36 UTC
I tried putting -lCg in various places before but that didn't work. It makes sense that you have to move -lm and -lpthread because Cg doesn't reference them when it should and so they must be linked regardless of whether they appear to be needed.
Comment 8 James Le Cuirot gentoo-dev 2008-04-09 17:16:58 UTC
Created attachment 149213 [details, diff]
ogre-1.4.7-as-needed.patch

Okay I've come up with a very simple patch. We can get away with only modifying the configure test because libm and libpthread are actually "needed" by OGRE itself any other time that libCg is linked. Thanks to the way AC_CHECK_LIB works, it is easy to add extra arguments to the test. Apply this patch before the ce-gui patch. "-Xlinker --no-as-needed" was used rather than "-Wl,--no-as-needed" because the comma confuses autoconf. Sorry for the extra work, Mr Bones!