You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Linking modifier whole-archive and link time cfg are not supported on bundled static libraries #99429
cfg for bundled static libraries was implemented just enough to make the case of musl libc bundled into libc crate to work, but it doesn't work in general case.
(Note that musl libc no longer uses bundling, see #72274.)
Also see #88085 and #88161 for some discussion related to this issue.
Reacted by Daniel Sommermann, Luqman Aden, Bobby Reynolds and Student
libfoo.a can be passed to linker as a separate static library, with preserving all the static library semantics, thus it can be
wrapped into -whole-archive ... -no-whole-archive
not passed at all if some relevant link time cfg is false
moved to some other place on the command line if necessary, not necessarily next to libfoo-sys.rlib
it's also fast, rustc doesn't have to extract object files to some temporary .a file on the fly or something like that, when static library semantics are necessary.
The problem is that we'll have to teach cargo to track these new extra files.
Third party build systems will also need to support this (although it's possible that they never use bundling and always link their native libraries in their own way).
If the separate file solution doesn't work out we'll need to figure out how to bundle object files into rlibs in some smarter way, with preserving their old structure, and then how to repack them on the fly if they need to be represented as a static library.
Support for this was implemented in #105601 under a feature gate #![feature(packed_bundled_libs)].
I'm closing this issue, but we need to open a tracking issue for that feature.
Activity
petrochenkov commentedon Jul 18, 2022
We need to make bundled libraries behave more like regular static libraries
libfoo.a.The simplest way, which is also most compatible with traditional tooling is to literally move them out of rlibs to separate
.afiles, like thisIt solves all the issues above:
libfoo.acan be passed to linker as a separate static library, with preserving all the static library semantics, thus it can be-whole-archive ... -no-whole-archivecfgis falselibfoo-sys.rlib.afile on the fly or something like that, when static library semantics are necessary.The problem is that we'll have to teach cargo to track these new extra files.
Third party build systems will also need to support this (although it's possible that they never use bundling and always link their native libraries in their own way).
If the separate file solution doesn't work out we'll need to figure out how to bundle object files into rlibs in some smarter way, with preserving their old structure, and then how to repack them on the fly if they need to be represented as a static library.
Rollup merge of rust-lang#100074 - petrochenkov:bundledoc, r=bjorn3
Rollup merge of rust-lang#100101 - BelovDV:issue-99429, r=petrochenkov
Rollup merge of rust-lang#100101 - BelovDV:issue-99429, r=petrochenkov
Rollup merge of rust-lang#100101 - BelovDV:issue-99429, r=petrochenkov
Auto merge of rust-lang#100101 - BelovDV:issue-99429, r=petrochenkov
petrochenkov commentedon Feb 15, 2023
Support for this was implemented in #105601 under a feature gate
#![feature(packed_bundled_libs)].I'm closing this issue, but we need to open a tracking issue for that feature.
petrochenkov commentedon Feb 15, 2023
The tracking issue - #108081.
Rollup merge of #100074 - petrochenkov:bundledoc, r=bjorn3
Rollup merge of #100074 - petrochenkov:bundledoc, r=bjorn3