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

rustbuild: print out env vars on verbose rustc invocations #82403

Merged

Conversation

pnkfelix
Copy link
Member

@pnkfelix pnkfelix commented Feb 22, 2021

Print out environment variables related to Rust on sufficiently verbose rustc invocations.

Output is filtered via heuristic of only printing environment variables whose keys start with "RUST" or "CARGO." This filtering is mostly motivated by my not caring to see e.g. "PATH" in my own output, though it is also motivated as a way to try to avoid printing out personal secrets like github keys that people might have stored in their environments for better or for worse, especially since build output is often pasted into bug reports or gists.

Fix #38686.

Click here to see sample output

Sample output looks like:

...
      Fresh core v0.0.0 (/home/pnkfelix/Dev/Rust/rust.git/library/core)
rustc env[0]: "CARGO"="/home/pnkfelix/Dev/Rust/rust.git/objdir-default/build/x86_64-unknown-linux-gnu/stage0/bin/cargo"
rustc env[1]: "CARGO_CRATE_NAME"="core"
rustc env[2]: "CARGO_INCREMENTAL"="0"
rustc env[3]: "CARGO_MAKEFLAGS"="--jobserver-fds=5,6 -j --jobserver-auth=5,6 -j"
rustc env[4]: "CARGO_MANIFEST_DIR"="/home/pnkfelix/Dev/Rust/rust.git/library/core"
rustc env[5]: "CARGO_PKG_AUTHORS"="The Rust Project Developers"
rustc env[6]: "CARGO_PKG_DESCRIPTION"=""
rustc env[7]: "CARGO_PKG_HOMEPAGE"=""
rustc env[8]: "CARGO_PKG_LICENSE"=""
rustc env[9]: "CARGO_PKG_LICENSE_FILE"=""
rustc env[10]: "CARGO_PKG_NAME"="core"
rustc env[11]: "CARGO_PKG_REPOSITORY"=""
rustc env[12]: "CARGO_PKG_VERSION"="0.0.0"
rustc env[13]: "CARGO_PKG_VERSION_MAJOR"="0"
rustc env[14]: "CARGO_PKG_VERSION_MINOR"="0"
rustc env[15]: "CARGO_PKG_VERSION_PATCH"="0"
rustc env[16]: "CARGO_PKG_VERSION_PRE"=""
rustc env[17]: "CARGO_PROFILE_RELEASE_CODEGEN_UNITS"="256"
rustc env[18]: "CARGO_PROFILE_RELEASE_DEBUG"="0"
rustc env[19]: "CARGO_PROFILE_RELEASE_DEBUG_ASSERTIONS"="false"
rustc env[20]: "CARGO_TARGET_DIR"="/home/pnkfelix/Dev/Rust/rust.git/objdir-default/build/x86_64-unknown-linux-gnu/stage0-std"
rustc env[21]: "RUSTBUILD_NATIVE_DIR"="/home/pnkfelix/Dev/Rust/rust.git/objdir-default/build/x86_64-unknown-linux-gnu/native"
rustc env[22]: "RUSTC"="/home/pnkfelix/Dev/Rust/rust.git/objdir-default/build/bootstrap/debug/rustc"
rustc env[23]: "RUSTC_BOOTSTRAP"="1"
rustc env[24]: "RUSTC_BREAK_ON_ICE"="1"
rustc env[25]: "RUSTC_ERROR_METADATA_DST"="/home/pnkfelix/Dev/Rust/rust.git/objdir-default/build/tmp/extended-error-metadata"
rustc env[26]: "RUSTC_FORCE_UNSTABLE"="1"
rustc env[27]: "RUSTC_INSTALL_BINDIR"="bin"
rustc env[28]: "RUSTC_LIBDIR"="/home/pnkfelix/Dev/Rust/rust.git/objdir-default/build/x86_64-unknown-linux-gnu/stage0/lib"
rustc env[29]: "RUSTC_LINT_FLAGS"="-Wrust_2018_idioms -Wunused_lifetimes -Dwarnings"
rustc env[30]: "RUSTC_PRINT_STEP_TIMINGS"="1"
rustc env[31]: "RUSTC_REAL"="/home/pnkfelix/Dev/Rust/rust.git/objdir-default/build/x86_64-unknown-linux-gnu/stage0/bin/rustc"
rustc env[32]: "RUSTC_SNAPSHOT"="/home/pnkfelix/Dev/Rust/rust.git/objdir-default/build/x86_64-unknown-linux-gnu/stage0/bin/rustc"
rustc env[33]: "RUSTC_SNAPSHOT_LIBDIR"="/home/pnkfelix/Dev/Rust/rust.git/objdir-default/build/x86_64-unknown-linux-gnu/stage0/lib"
rustc env[34]: "RUSTC_STAGE"="0"
rustc env[35]: "RUSTC_SYSROOT"="/home/pnkfelix/Dev/Rust/rust.git/objdir-default/build/x86_64-unknown-linux-gnu/stage0-sysroot"
rustc env[36]: "RUSTC_VERBOSE"="2"
rustc env[37]: "RUSTDOC"="/home/pnkfelix/Dev/Rust/rust.git/objdir-default/build/bootstrap/debug/rustdoc"
rustc env[38]: "RUSTDOCFLAGS"="--cfg=bootstrap -Dwarnings -Winvalid_codeblock_attributes --crate-version 1.52.0-dev"
rustc env[39]: "RUSTDOC_REAL"="/path/to/nowhere/rustdoc/not/required"
rustc env[40]: "RUSTFLAGS"="--cfg=bootstrap -Zmacro-backtrace -Clink-args=-Wl,-rpath,$ORIGIN/../lib -Cprefer-dynamic"
rustc env[41]: "RUST_COMPILER_RT_ROOT"="/home/pnkfelix/Dev/Rust/rust.git/src/llvm-project/compiler-rt"
rustc env[42]: "RUST_TEST_THREADS"="128"
rustc working directory: /home/pnkfelix/Dev/Rust/rust.git
rustc command: "LD_LIBRARY_PATH"="/home/pnkfelix/Dev/Rust/rust.git/objdir-default/build/x86_64-unknown-linux-gnu/stage0/lib:/home/pnkfelix/Dev/Rust/rust.git/objdi\
r-default/build/x86_64-unknown-linux-gnu/stage0-std/release/deps:/home/pnkfelix/Dev/Rust/rust.git/objdir-default/build/x86_64-unknown-linux-gnu/stage0/lib" "/home\
/pnkfelix/Dev/Rust/rust.git/objdir-default/build/x86_64-unknown-linux-gnu/stage0/bin/rustc" "--crate-name" "core" "--edition=2018" "library/core/src/lib.rs" "--er\
ror-format=json" "--json=diagnostic-rendered-ansi,artifacts" "--crate-type" "lib" "--emit=dep-info,metadata,link" "-C" "opt-level=3" "-C" "embed-bitcode=no" "-C" \
"codegen-units=256" "-C" "debuginfo=0" "-C" "metadata=6748933694d8be19" "-C" "extra-filename=-6748933694d8be19" "--out-dir" "/home/pnkfelix/Dev/Rust/rust.git/objd\
ir-default/build/x86_64-unknown-linux-gnu/stage0-std/x86_64-unknown-linux-gnu/release/deps" "--target" "x86_64-unknown-linux-gnu" "-L" "dependency=/home/pnkfelix/\
Dev/Rust/rust.git/objdir-default/build/x86_64-unknown-linux-gnu/stage0-std/x86_64-unknown-linux-gnu/release/deps" "-L" "dependency=/home/pnkfelix/Dev/Rust/rust.gi\
t/objdir-default/build/x86_64-unknown-linux-gnu/stage0-std/release/deps" "--cfg=bootstrap" "-Zmacro-backtrace" "-Clink-args=-Wl,-rpath,$ORIGIN/../lib" "-Cprefer-d\
ynamic" "-Z" "binary-dep-depinfo" "-Wrust_2018_idioms" "-Wunused_lifetimes" "-Dwarnings" "--sysroot" "/home/pnkfelix/Dev/Rust/rust.git/objdir-default/build/x86_64\
-unknown-linux-gnu/stage0-sysroot" "-Z" "force-unstable-if-unmarked"
...

@rust-highfive
Copy link
Collaborator

r? @Mark-Simulacrum

(rust-highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Feb 22, 2021
@jyn514 jyn514 added the T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) label Feb 22, 2021
@jyn514
Copy link
Member

jyn514 commented Feb 22, 2021

Can you double check that this allows running the rustc command x.py prints without getting "variable not set" errors?

…vocations.

Fix issue 38686.

(update: placated tidy.)
@pnkfelix pnkfelix force-pushed the rustbuild-emit-env-vars-on-verbose-verbose branch from 3bc06e9 to 9fafffd Compare February 22, 2021 16:44
@pnkfelix
Copy link
Member Author

@jyn514 it won't work out of the box, the output isn't parsable by a shell script in the manner it is currently printed.

Do you just mean "double-check that this is a sufficiently large set of environment variables for a typical case" ? I can do that, I'm actually in the midst of doing it now, in fact. :)

@pnkfelix
Copy link
Member Author

(also, if people want the output to be parsable by a shell script, I can do that too. I was following existing precedent for how the "DYLD_LIBRARY_PATH" key is printed currently (namely, with double-quotes around it), but I would be happy to revise that printing as part of this work so that the key is printed without surrounding double-quotes.)

@jyn514
Copy link
Member

jyn514 commented Feb 22, 2021

Do you just mean "double-check that this is a sufficiently large set of environment variables for a typical case" ? I can do that, I'm actually in the midst of doing it now, in fact. :)

Yes, that's what I meant :)

@pnkfelix
Copy link
Member Author

Do you just mean "double-check that this is a sufficiently large set of environment variables for a typical case" ? I can do that, I'm actually in the midst of doing it now, in fact. :)

Yes, that's what I meant :)

Okay. It seemed to work for me, and I didn't include any of the CFG nor CARGO variables in my invocation.

@camelid
Copy link
Member

camelid commented Feb 22, 2021

@pnkfelix I updated the PR description from

Fix issue #38686

to

Fix #38686

so GitHub will close the issue on PR merge. Letting you know in case you intended to leave the issue open.

@Mark-Simulacrum
Copy link
Member

Since this worked for you locally, I'm going to go ahead and r+, since it seems like a strict improvement to me. We can continue to iterate (e.g., moving more variables over to a RUST_ prefix) over time if necessary.

Thanks!

@bors r+ rollup

@bors
Copy link
Contributor

bors commented Mar 1, 2021

📌 Commit 9fafffd has been approved by Mark-Simulacrum

@bors bors 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 Mar 1, 2021
bors added a commit to rust-lang-ci/rust that referenced this pull request Mar 1, 2021
Rollup of 10 pull requests

Successful merges:

 - rust-lang#82309 (Propagate RUSTDOCFLAGS in the environment when documenting)
 - rust-lang#82403 (rustbuild: print out env vars on verbose rustc invocations)
 - rust-lang#82507 (Rename the `tidy` binary to `rust-tidy`)
 - rust-lang#82531 (Add GUI tests)
 - rust-lang#82532 (Add `build.print_step_rusage` to config.toml)
 - rust-lang#82543 (fix env var name in CI)
 - rust-lang#82622 (Propagate `--test-args` for `x.py test src/tools/cargo`)
 - rust-lang#82628 (Try to clarify GlobalAlloc::realloc documentation comment.)
 - rust-lang#82630 (Fix a typo in the `find_anon_type` doc)
 - rust-lang#82643 (Add more proc-macro attribute tests)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 9720cd1 into rust-lang:master Mar 1, 2021
@rustbot rustbot added this to the 1.52.0 milestone Mar 1, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

rustbuild --verbose switch is missing env var info
7 participants