Open
Description
The feature gate for the issue is #![feature(define_in_every_cgu_used)]
.
#[unsafe(define_in_every_cgu_used)]
is an attribute that can be applied to static
item definitions. It causes codegen to generate a full definition for the item instead of just an external declaration in every codegen unit where the symbol is referenced. It can be used to implement several Objective-C ABIs and reduce the overhead of interoperating with Objective-C code.
Original issue: #53929
Zulip:
- https://rust-lang.zulipchat.com/#narrow/channel/131828-t-compiler/topic/Low-overhead.20Objective-C.20interop
- https://rust-lang.zulipchat.com/#narrow/channel/427678-t-lang.2Finterop/topic/Attribute.20Proposal.20for.20Low-Overhead.20Objective-C.20Interop
Steps
- Implement in the LLVM backend
- Implement in the Cranelift backend
- Implement in the GCC backend
- Adjust documentation (see instructions on rustc-dev-guide)
- Stabilization PR (see instructions on rustc-dev-guide)
Unresolved Questions
- Should we disallow access to these items from inline assembly to help simplify the Cranelift backend implementation?
- Should the linkage of these symbols or any other symbol metadata be adjusted as well (e.g. should they be marked as
private
orlinkonce_odr
)? - Given that this attribute is opt-in, where would it be unacceptable to have multiple copies of the same static?
- Should this be an internal
rustc_
attribute used only as an implementation detail for objc macros in the standard library without the goal of ever stabilizing the attribute?
Implementation history
Experimental branch: master...jbatez:rust:define_in_every_cgu_used
Metadata
Metadata
Assignees
Labels
Area: Attributes (`#[…]`, `#![…]`)Area: Code generationArea: linking into static, shared libraries and binariesCategory: An issue tracking the progress of sth. like the implementation of an RFCRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the language team, which will review and decide on the PR/issue.