Discussion:
gnu linker/--no-as-needed?
Harlan Stenn
2014-01-08 06:58:06 UTC
Permalink
I need configure to tell me if I can use --no-as-needed or --as-needed.

Right now we have been only using these flags if we're using GCC, and
I've got a case (solaris) where gcc is calling the native loader, not
gld.

The docs for LT_PATH_LD say that macro tries to find the path to the
linker used by $CC, and whether it is the GNU linker. But when I read
the code for LT_PATH_LD it's sure not obvious to me how I can see if
we're using a GNU linker.

Anybody have some suggestions for me?

If it matters, we're using this because we've got a situation where we
need to force linking libgcc_s, as it must be in the executable early
enough; if we drop privileges it's too late to call dlopen(). That's
not entirely accurate, but it's close enough.
--
Harlan Stenn <***@ntp.org>
http://networktimefoundation.org - be a member!
Peter Rosin
2014-01-08 08:50:05 UTC
Permalink
[Technically this is a Libtool question, but I'll answer here anyway]
Post by Harlan Stenn
I need configure to tell me if I can use --no-as-needed or --as-needed.
Right now we have been only using these flags if we're using GCC, and
I've got a case (solaris) where gcc is calling the native loader, not
gld.
The docs for LT_PATH_LD say that macro tries to find the path to the
linker used by $CC, and whether it is the GNU linker. But when I read
the code for LT_PATH_LD it's sure not obvious to me how I can see if
we're using a GNU linker.
Anybody have some suggestions for me?
The last thing LT_PATH_LD does is to expand _LT_PATH_LD_GNU, which runs the
linker with -v and looks for "GNU" or "with BFD" in the output and assumes
GNU ld if that is found. The result is stored in $with_gnu_ld (and a cache
variable).

If inside configure, I think it's fairly safe to just use $with_gnu_ld,
that's probably not going to change anytime soon.

Outside configure, evaluate something like:

.../libtool --config | grep '^with_gnu_ld='
Post by Harlan Stenn
If it matters, we're using this because we've got a situation where we
need to force linking libgcc_s, as it must be in the executable early
enough; if we drop privileges it's too late to call dlopen(). That's
not entirely accurate, but it's close enough.
Cheers,
Peter
Harlan Stenn
2014-01-08 11:57:55 UTC
Permalink
Post by Peter Rosin
[Technically this is a Libtool question, but I'll answer here anyway]
...
The last thing LT_PATH_LD does is to expand _LT_PATH_LD_GNU, which runs the
linker with -v and looks for "GNU" or "with BFD" in the output and assumes
GNU ld if that is found. The result is stored in $with_gnu_ld (and a cache
variable).
If inside configure, I think it's fairly safe to just use $with_gnu_ld,
that's probably not going to change anytime soon.
.../libtool --config | grep '^with_gnu_ld='
Thanks, Peter!

H

Loading...