You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
support linker specifying "unmodified library names" #3951
Issue created after discussion on libera.chat irc channel #scons.
The GNU linker now has syntax which allows specifying a library filename which will not be modified before searching for it. This is a lightly edited copy of the text from a recent manpage:
-l namespec, --library=namespec
Add the archive or object file specified by namespec to the list of files to link. This option may be used any number of times. If namespec is of the form :filename, ld will search the library path for a file called filename, otherwise it will search the library path for a file called libnamespec.a. ... on ELF and SunOS systems, ld will search a directory for a library called libnamespec.so before searching for one called libnamespec.a. (By convention, a .so extension indicates a shared library.) Note that this behavior does not apply to :filename, which always specifies a file called filename.
Seems like SCons should understand this :foo syntax in handling LIBS. The alternative of trying to specify a specific library name/path which is taken without modification is to add it to LINKFLAGS instead of LIBS, but that loses the library ordering of the command line, so usually isn't a desirable approach. The other approach of using File('libname') to specify the library is okay for a specific project-local library, but I believe will not respect the defined library search path as the colon syntax does.
A little research shows this was added in binutils 2.18 (which was 2007-ish):
Changes in 2.18:
...
* -l:foo now searches the library path for a filename called foo,
without converting it to libfoo.a or libfoo.so.
I suppose the more general purpose way to handle this is a new construction var that describes a no-modify prefix - the code could just look for a libname that starts with : and not transform it, but that wires in gcc syntax...
Seems like this can be implemented in _stripixes - simply telling it not to strip if the magic prefix is found. I'm presuming we'd want to parameterize that (construction variable). The following works for very simple tests - it's not a complete patch as we'd need to set up initialization of the "literal" prefix and documentation.
diff--gita/SCons/Defaults.pyb/SCons/Defaults.pyindexcabadcc67..534c57575100644---a/SCons/Defaults.py+++b/SCons/Defaults.py@@ -477,6+477,7 @@ def_stripixes(prefix, itms, suffix, stripprefixes, stripsuffixes, env, c=None):else:c=_concat_ixes+libliteral=env.get('LIBLITERAL')
stripprefixes=list(map(env.subst, flatten(stripprefixes)))
stripsuffixes=list(map(env.subst, flatten(stripsuffixes)))
@@ -489,6+490,11 @@ def_stripixes(prefix, itms, suffix, stripprefixes, stripsuffixes, env, c=None):ifnotis_String(l):l=str(l)+# if special prefix is found, do not strip the name+iflibliteralandl.startswith(libliteral):
+stripped.append(l)
+continue+forstripprefixinstripprefixes:
lsp=len(stripprefix)
ifl[:lsp] ==stripprefix:
Verified only with a trivial unittest (pending a decision of whether this is something we even want to do):
The "something else" is a call to PathList, which, for string-valued members, does a split on os.pathsep. Which just happens to be the same magic character as the literal-lib introducer.
Activity
mwichmann commentedon Jun 8, 2021
I suppose the more general purpose way to handle this is a new construction var that describes a no-modify prefix - the code could just look for a libname that starts with
:and not transform it, but that wires in gcc syntax...bdbaddog commentedon Jun 8, 2021
Related (slightly) to #1161
mwichmann commentedon Jun 10, 2021
These issues are related: #2743 #2925 #2912
mwichmann commentedon Aug 15, 2023
Seems like this can be implemented in
_stripixes- simply telling it not to strip if the magic prefix is found. I'm presuming we'd want to parameterize that (construction variable). The following works for very simple tests - it's not a complete patch as we'd need to set up initialization of the "literal" prefix and documentation.Verified only with a trivial unittest (pending a decision of whether this is something we even want to do):
mwichmann commentedon Aug 24, 2023
Sadly, while the change works fine at the
_stripixeslevel, but it doesn't actually work at the E2E level, so there's something else going on.mwichmann commentedon Oct 9, 2023
The "something else" is a call to
PathList, which, for string-valued members, does a split onos.pathsep. Which just happens to be the same magic character as the literal-lib introducer.Add LIBLITERAL to support gcc -l:filename
Add LIBLITERAL to support gcc -l:filename
augfab commentedon Oct 31, 2023
Thanks a lot for the fix. I'm looking forward to version 4.6 😄