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

@joboet joboet commented Jun 20, 2026

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

@joboet joboet added O-SGX Target: SGX A-strict-provenance Area: Strict provenance for raw pointers labels Jun 20, 2026
@rustbot rustbot 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

rustbot commented Jun 20, 2026

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.

@joboet joboet force-pushed the sgx_env_oncelock branch from 17e89f0 to 2606b40 Compare June 28, 2026 21:10
@rustbot

rustbot commented Jun 28, 2026

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.

@Darksonn Darksonn 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

Darksonn commented Jul 1, 2026

Copy link
Copy Markdown
Member

@bors r+

@rust-bors

rust-bors Bot 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-bors rust-bors Bot 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-bors Bot 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)
rust-bors Bot 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-bors Bot merged commit 7f6f62f into rust-lang:main Jul 2, 2026
13 checks passed
@rustbot rustbot 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-strict-provenance Area: Strict provenance for raw pointers O-SGX Target: SGX S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-libs Relevant 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