-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Tell rustc wrappers which envs to pass through to allow env sandboxing #14444
Copy link
Copy link
Closed
Labels
A-build-executionArea: anything dealing with executing the compilerArea: anything dealing with executing the compilerA-build-scriptsArea: build.rs scriptsArea: build.rs scriptsA-configurationArea: cargo config files and env varsArea: cargo config files and env varsC-feature-requestCategory: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted`Category: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted`S-needs-infoStatus: Needs more info, such as a reproduction or more background for a feature request.Status: Needs more info, such as a reproduction or more background for a feature request.
Metadata
Metadata
Assignees
Labels
A-build-executionArea: anything dealing with executing the compilerArea: anything dealing with executing the compilerA-build-scriptsArea: build.rs scriptsArea: build.rs scriptsA-configurationArea: cargo config files and env varsArea: cargo config files and env varsC-feature-requestCategory: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted`Category: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted`S-needs-infoStatus: Needs more info, such as a reproduction or more background for a feature request.Status: Needs more info, such as a reproduction or more background for a feature request.
Type
Fields
Give feedbackNo fields configured for issues without a type.
Problem
In the process of creating a
$RUSTC_WRAPPERI realize it needs to know which environment variables build scripts and crates read in order to pass them down to my calls torustc(and not pass other, possibly sensitive, envs).These envs can be set in config as the
rustc-envmap cc https://doc.rust-lang.org/cargo/reference/config.htmlThese are also set when executing build scripts that output
cargo::rustc-env=VAR=VALUEdirectives cc https://doc.rust-lang.org/cargo/reference/build-scripts.html#rustc-envProposed Solution
A simple solution could be for
cargoto set an env when callingrustc(or just when calling a$RUSTC_WRAPPER).This env only needs to contain environment variable names (these are already set in
envbycargo).I propose to set
CARGO_BUILD_SETS_ENVSto a list of space-separated env names (or=-separated, both are illegal in var names).E.g. compiling the crate
self_updatewould setCARGO_BUILD_SETS_ENVS=HOST_PLATFORM TARGET_PLATFORMcf https://github.com/Shnatsel/current_platform/blob/57c123569e12f55c2111046f97294750f12c467d/src/build.rs
Notes
I propose
.._SETS_ENVSas I'd also like.._READS_ENVSfor names corresponding tocargo::rerun-if-env-changed=NAMEbut this feature request requires further exploration on my part and a whole new discussion.There are probably other information that my
$RUSTC_WRAPPERshould have access to (e.g.LD_PRELOADed things, ...). Maybe you have opinions, ideas on this. I'm just not done exploring yet.