-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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 link_syms parameter to build targets #14004
base: master
Are you sure you want to change the base?
Conversation
I'm currently using a hack where I add '-lgcc' to link_args as that wraps the list of static libraries, the --defsym values and then -lgcc in Right now, there's no support for mapping the GNU ld |
f3468c5
to
a06972a
Compare
This parameter provides a place to add -Wl,--defsym=a=b and -Wl,--undefined=c parameters during linking. These should occur before any object files and must occur before any libraries so that the results will affect the link correctly. In the ninjabackend, this is done by adding these to the ARGS parameter during linking as that is placed in the command line before any input files or libraries. Signed-off-by: Keith Packard <keithp@keithp.com>
7d5153a
to
26d7363
Compare
Test to make sure using --defsym in the link_syms parameter causes correct linker behavior between object files and static libraries for both C and C++. The C test validates that linking redirects from a symbol not defined by the library to a symbol that is defined by the library. The C++ test validates that linking redirects from one defined symbol to another defined symbol. Signed-off-by: Keith Packard <keithp@keithp.com>
26d7363
to
7c267bb
Compare
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.
Since the feature being added seems generic enough that its effective functionality isn't actually about defsym at all, I wonder if it's worth being a bit more direct about it and calling it link_early_args or something. :)
Which link args need to come first, which link args need to come later, etc? Currently the issue is that meson essentially doesn't really define what order any custom arguments will appear in (other than, I guess, that custom args should always tend to appear after builtin args so that they will override them where relevant).
self.link_syms = extract_as_list(kwargs, 'link_syms') | ||
for i in self.link_syms: | ||
if not isinstance(i, str): | ||
raise InvalidArguments('Link_syms arguments must be strings.') |
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.
Since this (new) code does KwargInfo based checking we know for sure that by the time it gets to build.py it is a list of strings, and we shouldn't need to type check it again.
Yeah, which is one reason I asked whether this should be a set of functions that control symbol definitions instead? That would make it easier to port between linkers, and would avoid this confusion.
Hrm. You've got me wondering if meson shouldn't just look at |
... or even just passing them all early by default? Are there any (ignoring -l which should be handled via link_with / dependencies anyway) that specifically need to be passed late... |
I hesitate to suggest that big a change -- we're likely to break something. I guess the question is whether this should be managed automatically by meson or manually by the user? |
This parameter provides a place to add -Wl,--defsym=a=b and -Wl,--undefined=c parameters during linking. These should occur before any object files and must occur before any libraries so that the results will affect the link correctly.
In the ninjabackend, this is done by adding these to the ARGS parameter during linking as that is placed in the command line before any input files or libraries.