EII: only require implementations for final artifacts to support -C prefer-dynamic#158340
Closed
cezarbbb wants to merge 1 commit into
Closed
EII: only require implementations for final artifacts to support -C prefer-dynamic#158340cezarbbb wants to merge 1 commit into
-C prefer-dynamic#158340cezarbbb wants to merge 1 commit into
Conversation
Collaborator
|
|
Member
|
This effectively reverts #156319. I don't think it is correct, see the zulip thread: https://rust-lang.zulipchat.com/#narrow/channel/213817-t-lang/topic/EII.3A.20should.20dylib.2Fsdylib.2Fproc-macro.20require.20implementations.3F/near/606144824 |
Contributor
Author
|
I agree with bjorn's reply in zulip. I will close this PR and explore new ways to enable EII support |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
EII checking currently uses
CheckExistencefor any crate type that isn't rlib, which meansdylib/sdylib/proc-macrocrates that declare an EII without an implementation always fail to compile. But these are intermediate products — their EIIs can be resolved by downstream crates, just like rlibs. The linker selects the strong symbol (explicit impl) over the weak one (default impl) at final link time, so intermediate crates don't need to guarantee an implementation exists yet.This
changes get_checking_mode()inrustc_passes/src/eii.rsto only useCheckExistencewhen the crate produces a final artifact:Executable,Cdylib, orStaticLib. All other crate types (Rlib,Dylib,Sdylib,ProcMacro) only check for duplicate explicit implementations. This matches the existingCrateType::has_metadata()classification inrustc_hir/src/attrs/data_structures.rs— crate types with metadata are intermediate products that downstream crates can depend on, and those without metadata are leaf nodes in the dependency graph where no further resolution is possible.With this change the behavior for each crate type is:
Rlib/Dylib/Sdylib/ProcMacro— no explicit impl is fine, compiles successfully; duplicate explicit impls across dependencies still errorExecutable/Cdylib/StaticLib— every EII must have at least one implementation (default or explicit), otherwise EiiWithoutImpl error; duplicate explicit impls still errorThis modification's result is the
-C prefer-dynamicflag works: a dylib intermediate can declare an EII without an implementation, and the final executable provides the explicit impl — the strong alias overrides the weak one at link time.tracking issues: #125418
r? @jdonszelmann