Skip to content

Linking modifier whole-archive and link time cfg are not supported on bundled static libraries #99429

Closed
@petrochenkov

Description

@petrochenkov

This is more or less a part of #81490.

If you try to combine +whole-archive with (possibly implicit) +bundle you will encounter this error: "linking modifiers +bundle and +whole-archive are not compatible with each other when generating rlibs".
The whole-archive modifier is significantly limited due to this issue and cannot be used in foo-sys rlibs bundling their native libfoo.a dependencies, which is one of the main use cases.

We also have to enable the +whole-archive modifier implicitly in one ad hoc case (https://github.com/rust-lang/rust/blob/master/compiler/rustc_codegen_ssa/src/back/link.rs#L2209-L2213) for backward compatibility, because it cannot be enabled manually.

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-linkageArea: linking into static, shared libraries and binariesT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions