[Scons-users] GCC Tool breaks linker for explicitly named libraries

Mats Wichmann mats at wichmann.us
Fri Dec 17 14:44:24 EST 2021


On 12/17/21 09:03, Steve Hill (Wireless) via Scons-users wrote:
> Hi,
> 
> We’ve had someone add a library as “:libfoo.a” to force the (GCC) linker 
> to link against exactly “libfoo.a” and ignore “libfoo.so”. 
> Unfortunately, when they add this, _stripixes removes the “.a” and 
> passes “-l:libfoo” to the linker. Since a library with the exact name 
> “libfoo” doesn’t exist, the link fails. If they add the library as 
> “:libfoo.a.a”, _stipixes removes one (and only one) “.a”, leaving 
> “-l:libfoo.a” and the link completes successfully.
> 
> Is this a bug or is there a workaround for this use-case?

SCons doesn't know about the GNU linker's : syntax for libraries, so the 
behavior would be unpredictable. Not surprised stripixes makes a mess of it.

I'm presuming you meant you want -l:foo rather than -l:libfoo.a, since 
the former is the approved syntax.

You'd have to put the library in by name, like /path/to/libfoo.a to 
force this the static-lib-only behavior, and since you have to put it in 
LINKFLAGS, not in LIBS, you lose control of the library ordering if it 
happens to matter. Not ideal - there are more than a few GCC-specials 
that aren't directly understood by SCons.  This is somewhat unfortunate, 
and probably the maintainer wouldn't be completely adverse to patches. 
The problem with adding too much syntax specific to one compiler suite 
is it makes it much easier to fall into traps where things are 
inadvertently non-portable.

There are some other "don't know about that" things from gcc listed in 
https://github.com/SCons/scons/issues/3064.  I added a comment there 
almost three years ago now when I was less directly involved with SCons 
development and ran into some behavior on the project I was working on 
at the time.


More information about the Scons-users mailing list