bootstrap: add bootstrap step to run stdarch-gen checks in CI#156674
bootstrap: add bootstrap step to run stdarch-gen checks in CI#156674xonx4l wants to merge 5 commits into
Conversation
|
|
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
cc @Amanieu, @folkertdev, @sayantn |
| }); | ||
|
|
||
| let mut path_dirs: Vec<PathBuf> = Vec::new(); | ||
| if let Some(cargo_dir) = builder.initial_cargo.parent() { |
There was a problem hiding this comment.
Why does cargo need to be in PATH?
There was a problem hiding this comment.
Because cargo_dir is providing rustc . As cargo run build looks up rustc on PATH .
There was a problem hiding this comment.
In that case we should set RUSTC to point to the rustc that we want to invoke directly, I think.
There was a problem hiding this comment.
Okay makes sense can do.
| let work_dir = builder.out.join("stdarch-gen-check"); | ||
| let cargo_target_dir = work_dir.join("target"); | ||
|
|
||
| // Writable copy of `crates/core_arch` that the generators write into. |
There was a problem hiding this comment.
| // Writable copy of `crates/core_arch` that the generators write into. | |
| // Writable copy of `crates/core_arch` that the generators write into when blessing. |
| if out_core_arch.exists() { | ||
| t!(fs::remove_dir_all(&out_core_arch)); | ||
| } | ||
| cp_writable_r(&src_core_arch, &out_core_arch); |
There was a problem hiding this comment.
Why do we need to copy things over? My mental model of how this should work is:
- When running the test, we generate the output code into some temporary directory on disk
- We then check if the generated files are the same as the files committed in the repo.
- If not, and we are not blessing, the test fails.
- If not, and we are blessing, the generated files override the committed files (we also need to ensure that any leftover files are deleted, so the committed dir should probably be emptied first).
There was a problem hiding this comment.
Your mental model is right it's just the copy is mainly there for the arm generator. It writes its output files directly into existing folders under core_arch/src but doesn't create those folders itself so they have to already exist. Copying core_arch over gives it those folders. Having the full copy also let run a single git diff over the whole folder instead of listing every generated file by hand. It's the same thing stdarch's own check-stdarch-gen CI does.
There was a problem hiding this comment.
I'd rather edit the generator to create those directories and make it so that it doesn't write to the source dirs, than do hacks with cp_writable_r.
In fact, to ensure that we run the same logic, it might be better if the check + bless logic actually lived within the generators themselves, and maybe we could also unify them under a single crate, it looks like they are separate right now? I wonder if there's an opportunity to do some refactoring there to make the whole setup less hacky.
There was a problem hiding this comment.
I approached with cp_writable_r to keep the changes minimal and strictly around bootstrap step only but if you want then I think we can edit the generator and can get rid of cp_writable_r . Yes they are separate right now and yeah by unifying it will make the whole setup less hacky for sure .
There was a problem hiding this comment.
Yeah I'd rather also do targeted refactorings to stdarch to make the overall testing infra better, rather than to just try hacking bootstrap around whatever stdarch is currently doing.
There was a problem hiding this comment.
Such changes are welcome. You can experiment here, and once you're happy we can see how to sync the changes back into stdarch
|
|
||
| /// Recursively copy src to dst clearing the read-only bit so the destination can be | ||
| /// regenerated even when src lives on a read-only filesystem. | ||
| fn cp_writable_r(src: &Path, dst: &Path) { |
There was a problem hiding this comment.
This shouldn't be needed. We shouldn't ever bless on CI, nor copy any files on CI, only locally.
There was a problem hiding this comment.
The read-only handling isn't for bless it only runs locally never on CI. It's there because we copy core_arch into the work folder at the start of every run and on CI the original files are read-only so the copies come out read-only too.
| run_gen("-p", "stdarch-gen-hexagon", &[hexagon_out.as_os_str()], None); | ||
| run_gen("-p", "stdarch-gen-hexagon-scalar", &[hexagon_out.as_os_str()], None); | ||
|
|
||
| let mut git = helpers::git(Some(&stdarch_root)); |
There was a problem hiding this comment.
Hmm, I was kinda thinking that we would check the files using Rust code, but I checked bootstrap and it doesn't seem like we already do any diffing at the moment, so git diff seems fine.
|
☔ The latest upstream changes (presumably #153957) made this pull request unmergeable. Please resolve the merge conflicts. |
This PR ports stdarch-gen checks into the bootstrap test runner as a step, so that we can run the stdarch-gen checks via x.py test.
Changes -:
-> Adds a new
StdarchGenCheckbootstrap step.-> Mirrors
https://github.com/rust-lang/stdarch/blob/f71ac102d30d5d1957277cbffc6ba631b67bffd1/.github/workflows/main.yml#L309-L333(check-stdarch-gen job)->
stdarch-gen-armuses a nightly only feature (#![feature(pattern)]) but bootstrap's cargo runs on the beta toolchain thus we setRUSTC_BOOTSTRAP=1on the child process so it builds.-> The generators call out to
rustfmtto format their output sorustfmtneeds to be onPATH. So added bootstrap's rustfmt toPATHbefore each run. If rustfmt isn't available, the step fails early and tells the user to setrustfmt = trueinbootstrap.toml.r? @Kobzol