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

Remove uses of set_var #2783

Closed
RalfJung opened this issue Feb 10, 2023 · 2 comments · Fixed by #3168
Closed

Remove uses of set_var #2783

RalfJung opened this issue Feb 10, 2023 · 2 comments · Fixed by #3168

Comments

@RalfJung
Copy link
Member

set_var has a problem and there are plans to make it unsafe. So we should find replacements for our uses of it.

  • env::set_var("RUSTC_LOG_ENTRY_EXIT", "1");

    Needs some way to pass this flag to the rustc logging machinery without an env var.
  • miri/src/bin/miri.rs

    Lines 191 to 198 in d0fd429

    if log::Level::from_str(&var).is_ok() {
    env::set_var(
    "RUSTC_LOG",
    format!("rustc_middle::mir::interpret={var},rustc_const_eval::interpret={var}"),
    );
    } else {
    env::set_var("RUSTC_LOG", &var);
    }

    Needs a way to init rustc logging by giving it the value of the filter expression we want, instead of the name of an env var with the filter.
  • std::env::set_var("MIRI_SYSROOT", &sysroot_dir);

    This one we could already do: find some other way to propagate this information to all parts of the binary, and to all created sub-processes.
@RalfJung
Copy link
Member Author

RalfJung commented Aug 2, 2023

#3006 removes the one in cargo-miri.

The others need logging machinery extensions first, so this is blocked on there being other APIs to control rustc logging.

@RalfJung
Copy link
Member Author

All uses of set_var in Miri itself are gone now thanks to rust-lang/rust#117814. All we have left is some uses in compiletest:

miri/tests/compiletest.rs

Lines 235 to 238 in d4d85a8

// Add a test env var to do environment communication tests.
env::set_var("MIRI_ENV_VAR_TEST", "0");
// Let the tests know where to store temp files (they might run for a different target, which can make this hard to find).
env::set_var("MIRI_TEMP", env::temp_dir());

@bors bors closed this as completed in 8a27e11 Nov 16, 2023
saethlin pushed a commit to saethlin/rust that referenced this issue Nov 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant