Skip to content
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

Add -Z direct-access-external-data #707

Closed
1 of 3 tasks
heiher opened this issue Dec 20, 2023 · 4 comments
Closed
1 of 3 tasks

Add -Z direct-access-external-data #707

heiher opened this issue Dec 20, 2023 · 4 comments
Labels
major-change A proposal to make a major change to rustc major-change-accepted A major change proposal that was accepted T-compiler Add this label so rfcbot knows to poll the compiler team

Comments

@heiher
Copy link

heiher commented Dec 20, 2023

Proposal

Some architectures, such as LoongArch, do not support copy relocation and are not expected to support it in the future. Consequently, regardless of whether the relocation model is static or pic, direct access to external data should be avoided, and indirect access through the GOT is recommended. However, certain special cases, such as the Linux kernel, require different approaches for accessing external data in vmlinux and modules. Therefore, I propose introducing the Clang's direct-access-external-data option into Rustc.

Option -Z direct-access-external-data controls how to access symbols of external data.

Supported values for this option are:

  • yes - Don't use GOT indirection to reference external data symbols.
  • no - Use GOT indirection to reference external data symbols.

If the option is not explicitly specified, different targets have different default values. (Equivalent to the default behavior before this)

For example:

extern "C" {
    static VAR: i32;
}

#[no_mangle]
pub fn get() -> i32 {
    unsafe { VAR }
}

direct-access-external-data=yes

@VAR = external dso_local {{.*}} global i32

direct-access-external-data=no

@VAR = external {{.*}} global i32

Mentors or Reviewers

Process

The main points of the Major Change Process are as follows:

  • File an issue describing the proposal.
  • A compiler team member or contributor who is knowledgeable in the area can second by writing @rustbot second.
    • Finding a "second" suffices for internal changes. If however, you are proposing a new public-facing feature, such as a -C flag, then full team check-off is required.
    • Compiler team members can initiate a check-off via @rfcbot fcp merge on either the MCP or the PR.
  • Once an MCP is seconded, the Final Comment Period begins. If no objections are raised after 10 days, the MCP is considered approved.

You can read more about Major Change Proposals on forge.

Comments

@heiher heiher added major-change A proposal to make a major change to rustc T-compiler Add this label so rfcbot knows to poll the compiler team labels Dec 20, 2023
@rustbot
Copy link
Collaborator

rustbot commented Dec 20, 2023

This issue is not meant to be used for technical discussion. There is a Zulip stream for that. Use this issue to leave procedural comments, such as volunteering to review, indicating that you second the proposal (or third, etc), or raising a concern that you would like to be addressed.

Concerns or objections to the proposal should be discussed on Zulip and formally registered here by adding a comment with the following syntax:

@rustbot concern reason-for-concern 
<description of the concern> 

Concerns can be lifted with:

@rustbot resolve reason-for-concern 

See documentation at https://forge.rust-lang.org

cc @rust-lang/compiler @rust-lang/compiler-contributors

@rustbot rustbot added the to-announce Announce this issue on triage meeting label Dec 20, 2023
@apiraino apiraino removed the to-announce Announce this issue on triage meeting label Dec 28, 2023
@Noratrieb
Copy link
Member

Yet another unstable codegen flag thrown into the seas of unstable codegen flags... but it seems useful, so let's not block this on figuring out what to do with them in general. No stability guarantees, so we can always change it in the future.
@rustbot second

@rustbot rustbot added the final-comment-period The FCP has started, most (if not all) team members are in agreement label Jan 23, 2024
@heiher
Copy link
Author

heiher commented Feb 6, 2024

@Nilstrieb Hello, Could you mark it accepted? Thanks.

@Noratrieb
Copy link
Member

@apiraino usually closes them after a while
But I can do it for you
@rustbot label -final-comment-period +major-change-accepted

@rustbot rustbot added major-change-accepted A major change proposal that was accepted to-announce Announce this issue on triage meeting and removed final-comment-period The FCP has started, most (if not all) team members are in agreement labels Feb 6, 2024
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Feb 7, 2024
…, r=petrochenkov

Add unstable `-Z direct-access-external-data` cmdline flag for `rustc`

The new flag has been described in the Major Change Proposal at rust-lang/compiler-team#707

Fixes rust-lang#118053
Nadrieril added a commit to Nadrieril/rust that referenced this issue Feb 7, 2024
…, r=petrochenkov

Add unstable `-Z direct-access-external-data` cmdline flag for `rustc`

The new flag has been described in the Major Change Proposal at rust-lang/compiler-team#707

Fixes rust-lang#118053
Nadrieril added a commit to Nadrieril/rust that referenced this issue Feb 7, 2024
…, r=petrochenkov

Add unstable `-Z direct-access-external-data` cmdline flag for `rustc`

The new flag has been described in the Major Change Proposal at rust-lang/compiler-team#707

Fixes rust-lang#118053
rust-timer added a commit to rust-lang-ci/rust that referenced this issue Feb 7, 2024
Rollup merge of rust-lang#119162 - heiher:direct-access-external-data, r=petrochenkov

Add unstable `-Z direct-access-external-data` cmdline flag for `rustc`

The new flag has been described in the Major Change Proposal at rust-lang/compiler-team#707

Fixes rust-lang#118053
@apiraino apiraino removed the to-announce Announce this issue on triage meeting label Feb 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
major-change A proposal to make a major change to rustc major-change-accepted A major change proposal that was accepted T-compiler Add this label so rfcbot knows to poll the compiler team
Projects
None yet
Development

No branches or pull requests

4 participants