Skip to content

Tracking issue for the define_in_every_cgu_used feature #141339

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
5 tasks
jbatez opened this issue May 21, 2025 · 5 comments
Open
5 tasks

Tracking issue for the define_in_every_cgu_used feature #141339

jbatez opened this issue May 21, 2025 · 5 comments
Labels
A-attributes Area: Attributes (`#[…]`, `#![…]`) A-codegen Area: Code generation A-linkage Area: linking into static, shared libraries and binaries C-tracking-issue Category: An issue tracking the progress of sth. like the implementation of an RFC T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-lang Relevant to the language team

Comments

@jbatez
Copy link

jbatez commented May 21, 2025

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

@jbatez jbatez added the C-tracking-issue Category: An issue tracking the progress of sth. like the implementation of an RFC label May 21, 2025
@jbatez

This comment has been minimized.

@rustbot

This comment has been minimized.

@jbatez

This comment has been minimized.

@rustbot

This comment has been minimized.

@jbatez
Copy link
Author

jbatez commented May 21, 2025

@rustbot label +A-attributes +A-codegen +A-linkage +T-compiler +T-lang

@rustbot rustbot added A-attributes Area: Attributes (`#[…]`, `#![…]`) A-codegen Area: Code generation A-linkage Area: linking into static, shared libraries and binaries T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-lang Relevant to the language team labels May 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-attributes Area: Attributes (`#[…]`, `#![…]`) A-codegen Area: Code generation A-linkage Area: linking into static, shared libraries and binaries C-tracking-issue Category: An issue tracking the progress of sth. like the implementation of an RFC T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-lang Relevant to the language team
Projects
None yet
Development

No branches or pull requests

2 participants