-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Use -lxxx
internally rather than full library path
#14342
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
Conversation
3a7c7b6
to
aac5d8c
Compare
emcc.py
Outdated
@@ -462,7 +462,7 @@ def is_supported(f): | |||
# lld allows various flags to have either a single -foo or double --foo | |||
if f.startswith(flag) or f.startswith('-' + flag): | |||
diagnostics.warning('linkflags', 'ignoring unsupported linker flag: `%s`', f) | |||
return False, takes_arg | |||
return False, takes_arg and '=' not in f |
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.
I don't follow this. Perhaps a comment about why =
is special?
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.
Done
a7d01cd
to
1581b6e
Compare
emcc.py
Outdated
# Skip the next argument if this linker flag takes and argument and that | ||
# argument was not specified as a separately (i.e. it was specified as | ||
# single arg containing an `=` char.) |
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.
# Skip the next argument if this linker flag takes and argument and that | |
# argument was not specified as a separately (i.e. it was specified as | |
# single arg containing an `=` char.) | |
# Skip the next argument if this linker flag takes an argument and that | |
# argument was not specified separately (i.e. it was specified as | |
# single arg containing an `=` char.) |
Is that right?
If so then this makes sense to me. But then isn't this a separate fix from the PR?
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.
Ah yes, this is a bug fix, but it also happens to be needed as part of this change. I split it out as #14356.
The reason this change depends on it is that other wise test_supported_linker_flags
will start failing. The reason this change depends on that fix goes like this:
- We specify the
-L/path/to/sysroot
as the first system link flag returned byemsdk_ldflags
- System link flags get added to user link flags
- If, as in that test, that last user link flag is an ignored one of the form
-Wl,-rpath=foo
then the next argument will be ignored.. which will be the-L/path/to/sysroot
- This will cause
-lc
to not be found, but that didn't matter previously because we were using full paths the libc.a prior to this change.
8cdcef8
to
aa6e451
Compare
Since we already supply the correct `-L` path we can rely on wasm-ld to find, for example, libc.a by simply pasing `-lc` rather than its full path. This is in line with what gcc and clang do. This is almost NFC, except in that case where the user supplies and library path via `-L` which happens to contains a file called `libc.a`. In this case, as with clang or gcc, that file will be chosen over the system one. This makes the linker command lines shorter, more readable, more inline with other compilers.
aa6e451
to
fd0f829
Compare
Since we already supply the correct
-L
path we can rely on wasm-ld tofind, for example,
libc.a
by simply passing-lc
rather than its fullpath.
This is in line with what gcc and clang do.
This is almost NFC, except in that case where the user supplies a
library path via
-L
which happens to contain a system library(e.g.
libc.a
). In this case, as with clang or gcc, that file will bechosen over the system one.
This makes the linker command lines shorter, more readable, more inline
with other compilers.