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

make it possible to use stage0 libtest on compiletest #139386

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

Conversation

onur-ozkan
Copy link
Member

With #119899, building the library tree will require a stage 1 compiler. This is because compiletest is defined as a ToolStd (since #68019) in order to use the in-tree library. As a result, #119899 makes certain development workflows more difficult as changes on the compiler tree will now require recompiling compiletest each time.

This PR allows switching ToolStd to ToolBootstrap with a simple boolean option in bootstrap.toml to allow compiletest to use the stage 0 libtest instead.

The changes under src/ci are clearly intended to make sure that compiletest doesn't break during future bootstrap beta bumps.

@rustbot
Copy link
Collaborator

rustbot commented Apr 4, 2025

r? @Kobzol

rustbot has assigned @Kobzol.
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) T-infra Relevant to the infrastructure team, which will review and decide on the PR/issue. labels Apr 4, 2025
@rustbot
Copy link
Collaborator

rustbot commented Apr 4, 2025

This PR modifies bootstrap.example.toml.

If appropriate, please update CONFIG_CHANGE_HISTORY in src/bootstrap/src/utils/change_tracker.rs.

This PR modifies src/bootstrap/src/core/config.

If appropriate, please update CONFIG_CHANGE_HISTORY in src/bootstrap/src/utils/change_tracker.rs.

@onur-ozkan onur-ozkan force-pushed the configurable-compiletest-libtest branch from 15d164d to 7f3da8c Compare April 4, 2025 17:59
src/ci/run.sh Outdated
@@ -134,6 +134,7 @@ if [ "$DEPLOY$DEPLOY_ALT" = "1" ]; then

CODEGEN_BACKENDS="${CODEGEN_BACKENDS:-llvm}"
RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --set rust.codegen-backends=$CODEGEN_BACKENDS"
RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --set build.compiletest-use-stage0-libtest=false"
Copy link
Contributor

@Kobzol Kobzol Apr 4, 2025

Choose a reason for hiding this comment

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

I would set this to false in the dist profile, in order to be enabled globally on CI, and then have one runner that sets it to true, to test that compiletest works also with stage0, if we want to gate on this.

Copy link
Member Author

@onur-ozkan onur-ozkan Apr 5, 2025

Choose a reason for hiding this comment

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

Not sure if using it in just one runner gives enough coverage.

Here's what I did: compiletest-use-stage0-libtest is set to false in the dist profile and run.sh script overrides it to true unless $DEPLOY or $DEPLOY_ALT is set.

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm pretty sure that most dist builders don't even build compiletest, as they don't run any tests. So if you want to have partial coverage of both true/false, we should do the split inside the test builders, not between test and dist, IMO.

Copy link
Contributor

Choose a reason for hiding this comment

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

That being said, I'm not sure if we need that much coverage of the true value? It's just a hack to make local rebuilds faster. I would put it maybe into one runner per OS.

Although, if we have both true and false on CI as blocking, can't that break beta bumps? 🤔

Copy link
Member Author

@onur-ozkan onur-ozkan Apr 5, 2025

Choose a reason for hiding this comment

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

That being said, I'm not sure if we need that much coverage of the true value? It's just a hack to make local rebuilds faster. I would put it maybe into one runner per OS.

Yeah, probably... I can do that for Linux, Mac and Windows (let me know if I am missing any other) as those are the most popular ones used by devs.

Although, if we have both true and false on CI as blocking, can't that break beta bumps? 🤔

compiletest is always built using the in-tree version of libtest. So if something breaks libtest, it would fail during development already; it wouldn't make it to beta without being caught. I guess that could happen if libtest is changed before bumping stage0 compiler, which will require cfg(bootstrap) thing there, I am not sure if this is acceptable. cc @jieyouxu

Copy link
Member

Choose a reason for hiding this comment

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

Hm yeah, I think there's a window where indeed cfg(bootstrap) might be needed, a library/testing-devex contributor who wants to modify libtest may need to cfg(bootstrap)-gate bit.

Copy link
Member

Choose a reason for hiding this comment

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

That being said, following #139317, the libtest usages in compiletest should be mostly isolated in one single module. We could add a doc comment on that about possibly needing cfg(bootstrap)-gating libtest changes.

Personally, I think this approach (possibility of compiletest using stage0 libtest for local dev) is reasonable, and I can't really think of a better solution.

@onur-ozkan onur-ozkan force-pushed the configurable-compiletest-libtest branch from 7f3da8c to 8c17501 Compare April 5, 2025 06:05
@rustbot
Copy link
Collaborator

rustbot commented Apr 5, 2025

This PR modifies src/bootstrap/defaults.

If appropriate, please update CONFIG_CHANGE_HISTORY in src/bootstrap/src/utils/change_tracker.rs.

@onur-ozkan onur-ozkan force-pushed the configurable-compiletest-libtest branch 3 times, most recently from 2ceaed5 to 48e9c4a Compare April 5, 2025 11:19
@onur-ozkan onur-ozkan force-pushed the configurable-compiletest-libtest branch 4 times, most recently from c757f55 to c3cfdfc Compare April 5, 2025 11:25
@jieyouxu jieyouxu self-assigned this Apr 5, 2025
Copy link
Member

@jieyouxu jieyouxu left a comment

Choose a reason for hiding this comment

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

This looks good to me, cc @Kobzol in case you still have concerns.

@onur-ozkan onur-ozkan force-pushed the configurable-compiletest-libtest branch from c3cfdfc to c830665 Compare April 7, 2025 07:09
Copy link
Contributor

@Kobzol Kobzol left a comment

Choose a reason for hiding this comment

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

Left one comment. The change otherwise looks fine. I'm not sure if we shouldn't do an MCP for this, but I think that libtest changed very rarely recently, so this shouldn't require a lot of cfg(bootstrap) places in compiletest. If it becomes a problem in the future, we can discuss it further.

@@ -27,7 +27,7 @@ runners:
<<: *base-job
envs:
env-x86_64-apple-tests: &env-x86_64-apple-tests
SCRIPT: ./x.py --stage 2 test --skip tests/ui --skip tests/rustdoc -- --exact
SCRIPT: ./x.py check compiletest --set build.compiletest-use-stage0-libtest=true && ./x.py --stage 2 test --skip tests/ui --skip tests/rustdoc -- --exact
Copy link
Contributor

Choose a reason for hiding this comment

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

x check doesn't actually go through the same codepath as x build; I think that for x check the stage0 config is not used at all, all the tools are checked with Mode::ToolRustc (

).

Copy link
Member Author

Choose a reason for hiding this comment

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

d2840fa makes x check compiletest to respect build.compiletest-use-stage0-libtest option.

Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks. This specific file contains just tests mock data btw, it doesn't need to be updated 😆

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 am aware, I just wanted them to be 1:1 equal.

@onur-ozkan
Copy link
Member Author

Left one comment. The change otherwise looks fine. I'm not sure if we shouldn't do an MCP for this, but I think that libtest changed very rarely recently, so this shouldn't require a lot of cfg(bootstrap) places in compiletest.

In my opinion, the point we are discussing (whether compiletest should support stage0 with cfg(bootstrap) or require a stage1 compiler) seems more suitable for a Zulip thread (which is already ongoing). I'm not sure if this will change in the near future with other possible workarounds, so I wouldn't go for an MCP at this point.

Copy link
Contributor

@Kobzol Kobzol left a comment

Choose a reason for hiding this comment

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

Ok, I'm fine with this now, so no other concerns.

It seems like you committed a LLVM submodule update by accident.

@@ -27,7 +27,7 @@ runners:
<<: *base-job
envs:
env-x86_64-apple-tests: &env-x86_64-apple-tests
SCRIPT: ./x.py --stage 2 test --skip tests/ui --skip tests/rustdoc -- --exact
SCRIPT: ./x.py check compiletest --set build.compiletest-use-stage0-libtest=true && ./x.py --stage 2 test --skip tests/ui --skip tests/rustdoc -- --exact
Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks. This specific file contains just tests mock data btw, it doesn't need to be updated 😆

&[],
);

cargo.allow_features("test");
Copy link
Contributor

Choose a reason for hiding this comment

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

It kinds sucks that we have to duplicate the code in this way. Would be maybe nice to merge build/check logic into the same step. But that's not relevant for this PR, anyway.

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 think the macro will be super complicated and ugly with compiletest specific changes, it's better to re-write the whole macro to make it more generic so...

@onur-ozkan onur-ozkan force-pushed the configurable-compiletest-libtest branch from d2840fa to cae28b5 Compare April 7, 2025 13:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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) T-infra Relevant to the infrastructure team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants