Skip to content

std: use OnceLock for SGX environment variable storage - #158180

Merged
rust-bors[bot] merged 1 commit into
rust-lang:mainfrom
joboet:sgx_env_oncelock
Jul 2, 2026
Merged

std: use OnceLock for SGX environment variable storage#158180
rust-bors[bot] merged 1 commit into
rust-lang:mainfrom
joboet:sgx_env_oncelock

Conversation

@joboet

Copy link
Copy Markdown
Member

The SGX environment code predates the existence of OnceLock and AtomicPtr and consequently violates strict provenance. By using OnceLock we can remove all the unsafe code (except for the unsafe in the function signatures, that's required by other platforms).

CC @jethrogb@raoulstrackx@aditijannu

@joboetjoboet added O-SGX Target: SGX A-strict-provenance Area: Strict provenance for raw pointers labels Jun 20, 2026
@rustbotrustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Jun 20, 2026
@rustbot

Copy link
Copy Markdown
Collaborator

r? @Darksonn

rustbot has assigned @Darksonn.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

Why was this reviewer chosen?

The reviewer was selected based on:

  • Owners of files modified in this PR: @ChrisDenton, libs
  • @ChrisDenton, libs expanded to 12 candidates
  • Random selection from Darksonn, Mark-Simulacrum, clarfonthey, jhpratt

@rust-bors

This comment has been minimized.

@rustbot

Copy link
Copy Markdown
Collaborator

This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed.

Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers.

@DarksonnDarksonn left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks reasonable to me.

@rustbot r+

View changes since this review

@Darksonn

Copy link
Copy Markdown
Member

@bors r+

@rust-bors

rust-borsBot commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

📌 Commit 2606b40 has been approved by Darksonn

It is now in the queue for this repository.

@rust-borsrust-borsBot added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jul 1, 2026
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Jul 1, 2026
std: use `OnceLock` for SGX environment variable storage
The SGX environment code predates the existence of `OnceLock` and `AtomicPtr` and consequently violates strict provenance. By using `OnceLock` we can remove all the `unsafe` code (except for the `unsafe` in the function signatures, that's required by other platforms).
CC @jethrogb@raoulstrackx@aditijannu
rust-borsBot pushed a commit that referenced this pull request Jul 1, 2026
…uwer
Rollup of 6 pull requests
Successful merges:
- #156737 (Implement `DoubleEndedIterator::next_chunk_back`)
- #158147 (std: fix stack buffer overflow in Windows junction_point)
- #158180 (std: use `OnceLock` for SGX environment variable storage)
- #158427 (Implement `ptr::{read,write}_unaligned` via `repr(packed)`)
- #158531 (Change `adjust_ident_and_get_scope` arg to `LocalDefId`)
- #158364 (rustc_target/asm: add LoongArch LSX/LASX inline asm register support)
@jhprattjhpratt mentioned this pull request Jul 1, 2026
rust-borsBot pushed a commit that referenced this pull request Jul 1, 2026
Rollup of 8 pull requests
Successful merges:
- #156737 (Implement `DoubleEndedIterator::next_chunk_back`)
- #158180 (std: use `OnceLock` for SGX environment variable storage)
- #158427 (Implement `ptr::{read,write}_unaligned` via `repr(packed)`)
- #158531 (Change `adjust_ident_and_get_scope` arg to `LocalDefId`)
- #158574 (Clarify ExitStatusExt documentation)
- #158334 (rustdoc: Show use-site paths for unevaluated const array lengths)
- #158364 (rustc_target/asm: add LoongArch LSX/LASX inline asm register support)
- #158667 (rustc_sanitizers: use twox-hash without default features)
@rust-bors
rust-borsBot merged commit 7f6f62f into rust-lang:mainJul 2, 2026
13 checks passed
@rustbotrustbot added this to the 1.98.0 milestone Jul 2, 2026
rust-timer added a commit that referenced this pull request Jul 2, 2026
Rollup merge of #158180 - joboet:sgx_env_oncelock, r=Darksonn
std: use `OnceLock` for SGX environment variable storage
The SGX environment code predates the existence of `OnceLock` and `AtomicPtr` and consequently violates strict provenance. By using `OnceLock` we can remove all the `unsafe` code (except for the `unsafe` in the function signatures, that's required by other platforms).
CC @jethrogb@raoulstrackx@aditijannu
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Jul 11, 2026
…nthey
std: use `OnceLock` for SGX argument storage
Just like rust-lang#158180, using a `OnceLock` is much better. Though I guess that in this case a `static mut` would be fine as well...
CC @jethrogb@raoulstrackx@aditijannu
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Jul 11, 2026
…nthey
std: use `OnceLock` for SGX argument storage
Just like rust-lang#158180, using a `OnceLock` is much better. Though I guess that in this case a `static mut` would be fine as well...
CC @jethrogb@raoulstrackx@aditijannu
rust-timer added a commit that referenced this pull request Jul 11, 2026
Rollup merge of #158182 - joboet:sgx_args_oncelock, r=clarfonthey
std: use `OnceLock` for SGX argument storage
Just like #158180, using a `OnceLock` is much better. Though I guess that in this case a `static mut` would be fine as well...
CC @jethrogb@raoulstrackx@aditijannu
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-strict-provenanceArea: Strict provenance for raw pointersO-SGXTarget: SGXS-waiting-on-borsStatus: Waiting on bors to run and complete tests. Bors will change the label on completion.T-libsRelevant to the library team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

@joboet@rustbot@Darksonn