Undefined reference to weak lang items when compilation contains many codegen units #69368
Labels
A-linkage
Area: linking into static, shared libraries and binaries
C-bug
Category: This is a bug.
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
Compiling following under some circumstances result in undefined references to
rust_oom
:This linking issue occurs only under for some codegen partitioning but not the
others. Reproducing it requires controlling the options that influence the
number of codegen units. I can reproduce it with either
incremental = true
,or
incremental = false
combined withcodegen-units = 200
.The weak lang items introduce cyclic dependencies between crates. For example,
the alloc crate depends on oom lang item which is defined in std. When linking
the std comes first, and it may so happen that object file that contains
rust_oom
definition is not used and omitted (this suggest why large number ofcodegen units is necessary to reproduce the issue), and subsequently alloc
crate will fail to link.
The linking code tries to account for cyclic dependencies using
start-group and end-group, but as far as I can see it based on assumption that
weak lang items dependencies are always reversed, which no longer holds true.
The text was updated successfully, but these errors were encountered: