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

centralize build stamp logic #135281

Open
wants to merge 13 commits into
base: master
Choose a base branch
from

Conversation

onur-ozkan
Copy link
Member

@onur-ozkan onur-ozkan commented Jan 9, 2025

This PR brings all the stamp file handling into one place inside build_stamp module, which takes care of everything related to build stamps. By doing this, we cut down on duplicated code and types and keep the codebase easier to maintain and more consistent.

Main goals are:

  • Make stamp handling stricter so we don't have to pass Paths around and manually join on arbitrary directories
  • Keep all stamp-related logic in one place
  • Make it easier to test and debug
  • Avoid duplication
  • Keep things simple and well-documented

Resolves #134962

@rustbot
Copy link
Collaborator

rustbot commented Jan 9, 2025

r? @albertlarsan68

rustbot has assigned @albertlarsan68.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@rustbot rustbot added A-testsuite Area: The testsuite used to check the correctness of rustc S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) labels Jan 9, 2025
@rustbot
Copy link
Collaborator

rustbot commented Jan 9, 2025

This PR changes how LLVM is built. Consider updating src/bootstrap/download-ci-llvm-stamp.

@rustbot
Copy link
Collaborator

rustbot commented Jan 9, 2025

This PR changes how LLVM is built. Consider updating src/bootstrap/download-ci-llvm-stamp.

@jieyouxu jieyouxu self-assigned this Jan 9, 2025
@jieyouxu
Copy link
Member

jieyouxu commented Jan 9, 2025

(This would close #134962)

@onur-ozkan
Copy link
Member Author

(This would close #134962)

Funny that I haven't even seen it...

@jieyouxu jieyouxu added the A-bootstrap-stamp Area: bootstrap stamp logic label Jan 9, 2025
@onur-ozkan onur-ozkan removed the A-bootstrap-stamp Area: bootstrap stamp logic label Jan 9, 2025
@rustbot rustbot added the A-meta Area: Issues & PRs about the rust-lang/rust repository itself label Jan 9, 2025
@rustbot
Copy link
Collaborator

rustbot commented Jan 9, 2025

triagebot.toml has been modified, there may have been changes to the review queue.

cc @davidtwco, @wesleywiser

@onur-ozkan onur-ozkan added the A-bootstrap-stamp Area: bootstrap stamp logic label Jan 9, 2025
@jieyouxu
Copy link
Member

jieyouxu commented Jan 9, 2025

I'll review this tmrw, I wanted to do some more manual local testing just in case. I had a brief glance at the changes, and I must say this is much easier to follow. So thank you for cleaning this up!

"prefix can not start or end with '.'"
);

let stamp_filename = self.path.components().last().unwrap().as_os_str().to_str().unwrap();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment on lines +33 to +38
/// Creates a new `BuildStamp` for a given directory.
///
/// By default, stamp will be an empty file named `.stamp` within the specified directory.
pub fn new(dir: &Path) -> Self {
Self { path: dir.join(".stamp"), stamp: String::new() }
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Expecting directory, so maybe assert that it is directory?

@klensy
Copy link
Contributor

klensy commented Jan 9, 2025

Maybe add single constructor like with_stamp_and_prefix instead of that 2 methods, or builder instead? Because currently it's possible to call with_stamp and with_prefix more than once, and i don't see why this should be needed at all.

Hmm, ok, multiple calls to with_prefix is used.

Comment on lines -138 to +139
let stamp = out_dir.join("llvm-finished-building");
let stamp = HashStamp::new(stamp, Some(smart_stamp_hash));
let stamp = BuildStamp::new(&out_dir).with_prefix("llvm").with_stamp(smart_stamp_hash);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stamp names mentioned in docs https://github.com/search?q=repo%3Arust-lang%2Frust+%22finished-building%22&type=code so need to do something with that.

Comment on lines -85 to +87
run_cargo(
builder,
cargo,
builder.config.free_args.clone(),
&libstd_stamp(builder, compiler, target),
vec![],
true,
false,
);

let stamp = build_stamp::libstd_stamp(builder, compiler, target).with_prefix("check");
run_cargo(builder, cargo, builder.config.free_args.clone(), &stamp, vec![], true, false);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes in 7b72325 for check.rs will somehow mangle prefix names?
Before: .libstd-check-stamp
After: .check-libstd-stamp

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did this intentionally to keep it simple by avoiding the need to duplicate similar functions. I assume this rename shouldn't cause any issues. Maybe, at worst, it might require running x clean after pulling these changes to remove old build artifacts.

@klensy
Copy link
Contributor

klensy commented Jan 9, 2025

Missing stamp refactor for lld:

let done_stamp = out_dir.join("lld-finished-building");
if done_stamp.exists() {
return out_dir;
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-bootstrap-stamp Area: bootstrap stamp logic A-meta Area: Issues & PRs about the rust-lang/rust repository itself A-testsuite Area: The testsuite used to check the correctness of rustc S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. 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.

Investigate if stamp logic in bootstrap could be consistently handled
5 participants