Skip to content

Add option to define environment vars #39656

Open
@jsgf

Description

@jsgf

Right now, code can use env!() and option_env!() to query arbitrary environment variables set at the time rustc is invoked. This is a subtle leak of the compilation environment into the generated code, which can cause issues with build reproducibility, and could conceivably be considered a security problem.

I'd like to have the option to completely define the "environment" that's available to env!() on the compiler command line to an explicitly delimited set of names and values

For example:

--override-env - disable querying of real environment
--set-env name=val - define an environment variable (added to existing env if --override-env not set)
--unset-env name - make a name unset

cc @luser - this seems pertinent to caching rust-lang/cargo#3066

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-feature-requestCategory: A feature request, i.e: not implemented / a PR.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions