RFC: Example autoconf code for enabling -Wl,--as-needed from upstream configure script
On Saturday 07 August 2010 18:19:30 Samuli Suominen wrote:
> On 08/07/2010 05:58 PM, Alexis Ballier wrote:
> > On Saturday 07 August 2010 17:45:02 Samuli Suominen wrote:
> >> Could use eyepair or two to doublecheck the example code in:
> >>  http://bugs.gentoo.org/attachment.cgi?id=241779
> >>  http://bugs.gentoo.org/show_bug.cgi?id=331527
> > You should use AC_TRY_LINK or something similar to check for toolchain
> > support. Hardcoding a given set of strings matching the version is
> > generally not a good way of writing a check; if you check something,
> > check it for real.
> > Also if you pass -Wl,--as-needed to the compiler that's what you should
> > check rather than if the supposed linker supports --as-needed; I suppose
> > AC_TRY_LINK will do that.
> I tend to agree but have one concern:
> What if some non-GNU ld's are accepting the syntax of -Wl,--as-needed
> but is in fact doing something entirely different?
> I just remember one of our prefix devs, not long ago, saying that
> happens. I think it was on this ML on different thread but sorry, can't
> find the post now...
> Note that flag-o-matic.eclass's check in function no-as-needed() is
> checking for GNU as well.
you can check for both if you prefer, the main problem I see in the original
check is that its not checking at all if as-needed works and appends a flag to
gcc while it checks only if ld accepts the flag