-
-
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
Add LIBLITERALPREFIX to support gcc -l:filename #4429
Conversation
Would be better to add another parameter to _stripixes() instead of having an envar LIBLITERAL.. That way any users usage of _stripixes() won't be affected by LIBLITERAL. ? |
Not sure that I follow the benefits of that. Somewhere, these things need to happen:
Doing this as an argument to |
Disagree.. You can note to users that another argument is available, but default it in the arglist to allow it to not be passed. Otherwise if this function is used for purposes other than the one's SCons itself is, there may be unpleasant surprises.. I'd like to avoid those surprises.. |
Ok. Finally figured out why this solution was bugging me (besides already stated reasons). Since |
doesn't make any sense to change it, it's internal to the linker. if you change the linker to get different value, you will get rebuilds, since binary's sig will be different (hypothetical at moment) only sane way to do this is add a new library holder type so libs can have attributes, but that's a lot more work, and api impact. |
Not completely sure I understand this part of the comment, but perhaps a small sample will illustrate: $ cat SConstruct
env = Environment(LIBLITERAL=":")
env.Program(target="hello", source="hello.c", LIBS=":libm.a")
$ scons -Q
gcc -o hello.o -c hello.c
gcc -o hello hello.o -l:libm.a
$ scons -Q
scons: `.' is up to date.
$ #EDIT SConstruct
$ cat SConstruct
env = Environment(LIBLITERAL="+")
env.Program(target="hello", source="hello.c", LIBS="+libm.a")
$ scons -Qn
gcc -o hello hello.o -l+libm.a
$ We've first set it to a |
Hmmm, merged the PR which seemed okay, but now it's failing tests, specifically |
Okay, the failure comes down to - when try:
s = eval(key, self.gvars, lvars)
except KeyboardInterrupt:
raise
except Exception as e:
if e.__class__ in AllowableExceptions:
return ''
raise_exception(e, lvars['TARGETS'], old_s) The The conclusion I make is if we're going to use |
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]>
…gument with a False default value, and add properly passing LIBLITERAL in link, dmd, ldc tools where _stripixes() is actually used in current SCons Code (#10)
16db520
to
cf7251f
Compare
* Beef up _stripixes unittests * rename LIBLITERAL to LIBLITERALPREFIX * Initialize in Platform code, takes an error if not set when StringSubber.expand() is called with a string containing LIBLITERALPREFIX * Fix some bad typing markup. * Add docs Signed-off-by: Mats Wichmann <[email protected]>
cf7251f
to
e9f5038
Compare
43ee143
to
ab77192
Compare
CHANGES.txt
Outdated
|
||
- Add a LIBLITERALPREFIX variable which can be set to the linker's | ||
prefix for considering a library argument unmodified (e.g. for the | ||
GNU linker, the ':' in '-l:libfoo.a'). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Annotate with gh defect this fixes? (Same for RELEASE)?
# be okay because if we come through here, we're normally processing | ||
# library names and won't have strings like "path:secondpath:thirdpath" | ||
# which is why PathList() otherwise wants to split strings. | ||
do_split = not literal_prefix == os.pathsep |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this handle when LIBLITERALPREFIX isn't defined now? Or did you just define this down all the likely paths?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
paths (in platform). I don't know how to fix otherwise, eval just has to have stuff in one of the two dicts, and don't see another clean way
@mwichmann Should we also set LIBLITERALPREFIX 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
andLIBLITRALPREFIX
are the same, as they are on Linux (i.e. ':'). That's becauseSCons.PathList.PathList
is called and it does: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 #3951
Submitted for initial review so no docs or changelogs yet.
Contributor Checklist:
CHANGES.txt
(and read theREADME.rst
)