Skip to content

Tracking issue for the define_in_every_cgu_used feature #141339

Open
@jbatez

Description

@jbatez

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:

Steps

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 or linkonce_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

No one assigned

    Labels

    A-attributesArea: Attributes (`#[…]`, `#![…]`)A-codegenArea: Code generationA-linkageArea: linking into static, shared libraries and binariesC-tracking-issueCategory: An issue tracking the progress of sth. like the implementation of an RFCT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.T-langRelevant to the language 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