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

rustdoc --version --verbose no longer displays commit hashes + date since beta 1.67 #107094

Closed
matthiaskrgr opened this issue Jan 19, 2023 · 15 comments · Fixed by #109981
Closed
Assignees
Labels
C-bug Category: This is a bug. E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. E-mentor Call for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion. regression-from-stable-to-stable Performance or correctness regression from one stable version to another. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.
Milestone

Comments

@matthiaskrgr
Copy link
Member

matthiaskrgr commented Jan 19, 2023

stable is fine:
~/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/bin/rustdoc --version --verbose

rustdoc 1.66.1 (90743e729 2023-01-10)
binary: rustdoc
commit-hash: 90743e7298aca107ddaa0c202a4d3604e29bfeb6
commit-date: 2023-01-10
host: x86_64-unknown-linux-gnu
release: 1.66.1
LLVM version: 15.0.2

but beta and nightly are no longer showing commit-hash and commit-date information:
~/.rustup/toolchains/beta-x86_64-unknown-linux-gnu/bin/rustdoc --version --verbose

rustdoc 1.67.0-beta.8 (7a9ae0ce6 2023-01-14)
binary: rustdoc
commit-hash: unknown
commit-date: unknown
host: x86_64-unknown-linux-gnu
release: 1.67.0-beta.8
LLVM version: 15.0.6

~/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/bin/rustdoc --version --verbose

rustdoc 1.68.0-nightly (333ee6c46 2023-01-18)
binary: rustdoc
commit-hash: unknown
commit-date: unknown
host: x86_64-unknown-linux-gnu
release: 1.68.0-nightly
LLVM version: 15.0.6
@matthiaskrgr matthiaskrgr added T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. C-bug Category: This is a bug. regression-untriaged Untriaged performance or correctness regression. labels Jan 19, 2023
@rustbot rustbot added the I-prioritize Issue: Indicates that prioritization has been requested for this issue. label Jan 19, 2023
@matthiaskrgr
Copy link
Member Author

it's weird because the info is still displayed correctly in the very first oneliner-summary, but if there was some tool that reads the data by looking at commit-hash or commit-date we still should display the right thing.

@ehuss
Copy link
Contributor

ehuss commented Jan 20, 2023

This appears to have been introduced by #104184. The issue is that the macro uses CFG_VER_DATE/CFG_VER_HASH which is only set when compiling rustc.

One option is to try to share some code with rustc_cargo_env. Another option is to go the other way and get rustc to share some code with prepare_tool_cargo.

@ehuss ehuss added the T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) label Jan 20, 2023
@jyn514 jyn514 added this to the 1.67.0 milestone Jan 20, 2023
@jyn514 jyn514 added regression-from-stable-to-beta Performance or correctness regression from stable to beta. and removed regression-untriaged Untriaged performance or correctness regression. labels Jan 20, 2023
@jyn514 jyn514 added the E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. label Feb 17, 2023
@jyn514
Copy link
Member

jyn514 commented Feb 17, 2023

Mentoring instructions: set

if let Some(ref ver_date) = builder.rust_info().commit_date() {
cargo.env("CFG_VER_DATE", ver_date);
}
in
pub fn prepare_tool_cargo(

(Maybe we should try to unify those functions so they don't duplicate so much code and problems like this don't happen in the future?)

@jyn514 jyn514 added E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. E-mentor Call for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion. and removed E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. labels Feb 17, 2023
@jyn514
Copy link
Member

jyn514 commented Feb 17, 2023

I think it should be possible to write a run-make test ensuring this works properly.

@zephaniahong
Copy link
Contributor

@rustbot claim

@anth0nyleung
Copy link

Hi @zephaniahong! im starting my journey of contributing to Rust, i found this issue a good starter for myself, do you think you would be open to let me take this chance to get familiar with the code base?

@zephaniahong
Copy link
Contributor

@anth0nyleung Hey! Go for it!🤗

@zephaniahong zephaniahong removed their assignment Feb 18, 2023
@zephaniahong
Copy link
Contributor

Alternatively, you could check out #108111. I THINK that might be more straightforward. But I'll let you decide(:

@anth0nyleung
Copy link

@rustbot claim

@anth0nyleung
Copy link

I tried doing this change in tool.rs

diff --git a/src/bootstrap/tool.rs b/src/bootstrap/tool.rs
index ca5f500f93b..6788151f806 100644
--- a/src/bootstrap/tool.rs
+++ b/src/bootstrap/tool.rs
@@ -286,6 +286,9 @@ pub fn prepare_tool_cargo(
     if let Some(date) = info.commit_date() {
         cargo.env("CFG_COMMIT_DATE", date);
     }
+    if let Some(ver_date) = info.commit_date() {
+        cargo.env("CFG_VER_DATE", ver_date);
+    }
     if !features.is_empty() {
         cargo.arg("--features").arg(&features.join(", "));
     }

Then i did a ./x.py build and tried running this command rustdoc --version --verbose on the stage2 rustodc

$> ./build/aarch64-apple-darwin/stage2/bin/rustdoc --version --verbose
rustdoc 1.69.0-dev
binary: rustdoc
commit-hash: unknown
commit-date: unknown
host: aarch64-apple-darwin
release: 1.69.0-dev
LLVM version: 15.0.7

But it appears that the commit-hash and commit-date is still unknown. Im wondering if the issue is that builder.config.ignore_git is passed as true in GitInfo::new()

let info = GitInfo::new(builder.config.ignore_git, &dir);

This is my first time making changes and testing in this project, please feel free to correct me if im testing / building in the wrong way.

@jyn514
Copy link
Member

jyn514 commented Feb 19, 2023

@anth0nyleung I'd suggest changing

unw(option_env!("CFG_VERSION")),
unw(option_env!("CFG_VER_HASH")),
unw(option_env!("CFG_VER_DATE")),
unw(option_env!("CFG_RELEASE")),
to use env! instead of option_env so it's easier to tell when these variables are unset without having to build a full stage 2 compiler.

@Mark-Simulacrum Mark-Simulacrum added regression-from-stable-to-stable Performance or correctness regression from one stable version to another. and removed regression-from-stable-to-beta Performance or correctness regression from stable to beta. labels Mar 3, 2023
@Mark-Simulacrum
Copy link
Member

Retagging as stable/stable regression, this already shipped in 1.67 as far as I can tell.

@duckymirror
Copy link
Contributor

@anth0nyleung Are you still (interested in) working on this issue? I'd like to claim it otherwise.

@anth0nyleung anth0nyleung removed their assignment Apr 4, 2023
@anth0nyleung
Copy link

@duckymirror please go ahead and claim it!

@duckymirror
Copy link
Contributor

@rustbot claim

duckymirror added a commit to duckymirror/rust that referenced this issue Apr 16, 2023
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Apr 17, 2023
…larsan68

Set commit information environment variables when building tools

This fixes rust-lang#107094.
~I'm trying to add a regression test for this issue.~
**Update**: I've added a test and a new test header `needs-git-hash` which makes sure it doesn't run when commit hashes are ignored (`bootstrap`'s `ignore-git` option).
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Apr 17, 2023
…larsan68

Set commit information environment variables when building tools

This fixes rust-lang#107094.
~I'm trying to add a regression test for this issue.~
**Update**: I've added a test and a new test header `needs-git-hash` which makes sure it doesn't run when commit hashes are ignored (`bootstrap`'s `ignore-git` option).
@bors bors closed this as completed in 06d403d Apr 18, 2023
@apiraino apiraino removed the I-prioritize Issue: Indicates that prioritization has been requested for this issue. label May 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug. E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. E-mentor Call for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion. regression-from-stable-to-stable Performance or correctness regression from one stable version to another. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

9 participants