-
-
Notifications
You must be signed in to change notification settings - Fork 322
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
support linker specifying "unmodified library names" #3951
Comments
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 |
Related (slightly) to #1161 |
Seems like this can be implemented in diff --git a/SCons/Defaults.py b/SCons/Defaults.py
index cabadcc67..534c57575 100644
--- 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):
if not is_String(l):
l = str(l)
+ # if special prefix is found, do not strip the name
+ if libliteral and l.startswith(libliteral):
+ stripped.append(l)
+ continue
+
for stripprefix in stripprefixes:
lsp = len(stripprefix)
if l[:lsp] == stripprefix: Verified only with a trivial unittest (pending a decision of whether this is something we even want to do): diff --git a/SCons/EnvironmentTests.py b/SCons/EnvironmentTests.py
index e7cb99f34..2fa917d2a 100644
--- a/SCons/EnvironmentTests.py
+++ b/SCons/EnvironmentTests.py
@@ -1522,6 +1522,21 @@ def exists(env):
x = e.subst('$( ${_concat(PRE, L1, SUF, __env__)} $)')
assert x == 'preasuf prebsuf precsuf predsuf precsuf predsuf', x
+
+ def test__stripixes(self) -> None:
+ """Test _stripixes()"""
+ e = self.TestEnvironment(
+ PRE='PRE',
+ SUF='SUF',
+ LIST=['xxx-a', 'b.yyy', 'zzxxx-c.yyy'],
+ LIBPREFIXES=['xxx-'],
+ LIBSUFFIXES=['.yyy'],
+ LIBLITERAL='zz',
+ )
+ x = e.subst('$( ${_stripixes(PRE, LIST, SUF, LIBPREFIXES, LIBSUFFIXES, __env__)} $)')
+ self.assertEqual(x, 'PREaSUF PREbSUF PREzzxxx-c.yyySUF')
+
+
def test_gvars(self) -> None:
"""Test the Environment gvars() method"""
env = self.TestEnvironment(XXX = 'x', YYY = 'y', ZZZ = 'z') |
Sadly, while the change works fine at the |
The "something else" is a call to |
This is done in a general way. using a construction var, although at the moment only the GNU linker is known to handle things this way. Had to do something funky, or it won't work when os.pathsep and LIBLITRAL are the same, as they are on Linux (i.e. ':'). That's because SCons.PathList.PathList is called and it does: class _Pathlist: def __init__(self, pathlist) -> None: if SCons.Util.is_String(pathlist): pathlist = pathlist.split(os.pathsep) Splitting has the effect of turning ":libm.a" into ((0, ''), (0, 'libm.a')] That is, the ':' is lost as part of the library specifier - so need to try to avoid that. Fixes SCons#3951 Signed-off-by: Mats Wichmann <[email protected]>
This is done in a general way. using a construction var, although at the moment only the GNU linker is known to handle things this way. Had to do something funky, or it won't work when os.pathsep and LIBLITRAL are the same, as they are on Linux (i.e. ':'). That's because SCons.PathList.PathList is called and it does: class _Pathlist: def __init__(self, pathlist) -> None: if SCons.Util.is_String(pathlist): pathlist = pathlist.split(os.pathsep) Splitting has the effect of turning ":libm.a" into ((0, ''), (0, 'libm.a')] That is, the ':' is lost as part of the library specifier - so need to try to avoid that. Fixes SCons#3951 Signed-off-by: Mats Wichmann <[email protected]>
Thanks a lot for the fix. I'm looking forward to version 4.6 😄 |
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:
Seems like SCons should understand this
:foo
syntax in handlingLIBS
. The alternative of trying to specify a specific library name/path which is taken without modification is to add it toLINKFLAGS
instead ofLIBS
, but that loses the library ordering of the command line, so usually isn't a desirable approach. The other approach of usingFile('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):
The text was updated successfully, but these errors were encountered: