-
Notifications
You must be signed in to change notification settings - Fork 23
Add option for deduplicating linking line #113
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
base: main
Are you sure you want to change the base?
Conversation
|
I added that because I'm not sure if the deduplicated ordering is always correct, but I agree that it would be better if it did it by default with guarantees. My intuition is that since the relative ordering of the items (libs, frameworks, args, ...) is maintained for the items of each individual library it should work, but I'm not an expert on linking order so I would love to get some feedback on that. |
|
You should copy what Meson is doing for de-duplicating arguments. You don't need to copy all of it, just the code that de-dups linker args. The basic mechanism for that is:
|
|
Relevant code: Library searching: https://github.com/mesonbuild/meson/blob/master/mesonbuild/dependencies/pkgconfig.py#L375-L525 Special class to append compiler args: https://github.com/mesonbuild/meson/blob/master/mesonbuild/arglist.py Subclass for C-specific handling for compiler args https://github.com/mesonbuild/meson/blob/master/mesonbuild/compilers/mixins/clike.py#L50-L120 |
|
Thank you for all of the references! I'll try this so hopefully we can ship it as the default. For arguments other than |
|
I haven't looked in detail at this PR, but de-duplication of
You also need to account for If the scope spirals out of control, I would recommend keeping this to |
When linking libraries with many dependencies, the number of linking arguments can be so big that it exceeds
ARG_MAXand cause linking to fail. For example, this came up when linkinggstreamerwith some plugins.In reality, many of the arguments get repeated across the crates, so using deduping can help greatly with this issue. This needs to be done with care, since the order of the arguments matter.
system_depsalready had functions for getting every collection of unique linking arguments in tests, so we use those ifSYSTEM_DEPS_CLEAN_LINKERis set. While in my tests everything seems to link fine using this order, I don't think it is wise to do it by default since there may be edge cases where this isn't true.Additionally, since the two were very intertwined, this PR also includes the option
SYSTEM_DEPS_LINK=static_release. This allows to link dependencies dynamically on debug and statically on release.These changes should not modify existing behaviour, but they do modify the public API since
Dependencies::all_libshas a different return type. If needed, I could leave this function as is and create aall_libs_with_static, but it seemed redundant.TODO:
Note: This was originally part of the PR for supporting prebuilt binaries (ADD LINK). However, in an effort to make reviewing easy, I separated this feature since it works independently.