Skip to content

Conversation

makai410
Copy link
Contributor

@makai410 makai410 commented Aug 18, 2025

  • devtool: A helper for maintaining rustc_public. The main logic for commands like build is implemented here. This PR implements ./x build, ./x test [--bless], ./x fmt [--check], ./x githook install/uninstall and ./x clean. Windows is not supported yet.
  • This PR turns the compiletest crate into a single file, making it possilbe to run test suites using cargo test.

@celinval
Copy link
Contributor

Amazing! On the file structure, since this repo is also meant to store files related to the project, can I suggest that we create a rustc_public folder with the code relevant for the crate. Or would that mess up with the josh-sync?

@celinval
Copy link
Contributor

I was also wondering if you could break down the PR a bit more. I think there are changes here that are ready to be merged independently

@makai410
Copy link
Contributor Author

Amazing! On the file structure, since this repo is also meant to store files related to the project, can I suggest that we create a rustc_public folder with the code relevant for the crate. Or would that mess up with the josh-sync?

It seems feasible by writing a filter to the josh, though I haven't tried it yet. IMO it's OK to keep our rustc_public code in the src/ folder, and miri does the same.

I was also wondering if you could break down the PR a bit more. I think there are changes here that are ready to be merged independently

Yea makes sense. I'll split it up.

@makai410 makai410 marked this pull request as ready for review August 25, 2025 12:51
@oli-obk
Copy link
Contributor

oli-obk commented Aug 26, 2025

CI wants some rustfmting

env:
TOOLS_BIN: "/tmp/smir/bin"
# Note that the downloaded version is dated 2025-08-09.
toolchain: nightly-2025-08-10
Copy link
Contributor

Choose a reason for hiding this comment

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

I would prefer a toolchain toml file, as we'll update it frequently and that's easier to automate than editing a github workflow

Fine for now tho if you want to land this first and tune later

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah makes sense. I'd like to update it later together with the automation pr

Copy link
Contributor

Choose a reason for hiding this comment

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

Will that be a follow up PR?

@oli-obk
Copy link
Contributor

oli-obk commented Aug 26, 2025

This changes the rustc_public crate. Can you check that it still works inside the rust repo if synced back?

@makai410
Copy link
Contributor Author

The rustc compilation fails directly since we have a really strict msrv in our build.rs. Can we use the :exclude filter to avoid syncing those changes back?

@makai410
Copy link
Contributor Author

wait, is it possible to keep the files for the crates.io version in a separate directory? We can specify which Cargo.toml to use when building, and Cargo.toml itself can define the lib and build files.

@oli-obk
Copy link
Contributor

oli-obk commented Aug 29, 2025

wait, is it possible to keep the files for the crates.io version in a separate directory? We can specify which Cargo.toml to use when building, and Cargo.toml itself can define the lib and build files.

Yea. I think the plan was to overwrite the sources of the crates.io copy every time we make a breaking change?

@makai410
Copy link
Contributor Author

Yes the rustc version would be the base of a new major release

uses: actions/checkout@v4

- name: Rust Toolchain
uses: dtolnay/rust-toolchain@nightly
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we need nightly for format check?

env:
TOOLS_BIN: "/tmp/smir/bin"
# Note that the downloaded version is dated 2025-08-09.
toolchain: nightly-2025-08-10
Copy link
Contributor

Choose a reason for hiding this comment

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

Will that be a follow up PR?

TOOLS_BIN: "/tmp/smir/bin"
# Don't fail CI for now. See: https://github.com/rust-lang/project-stable-mir/issues/39
continue-on-error: true
latest:
Copy link
Contributor

Choose a reason for hiding this comment

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

Btw, you should be able to create an action and reuse it for these two jobs. Not a big deal at this point, but if you have a follow up PR, that might be a nice change.

I also want to add a test for latest stable

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Btw, you should be able to create an action and reuse it for these two jobs. Not a big deal at this point, but if you have a follow up PR, that might be a nice change.

Yes, that would be done as follow up

I also want to add a test for latest stable

ummm iirc the stable version can’t enable rustc_private

Copy link
Contributor

Choose a reason for hiding this comment

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

People would still need to set bootstrap env variable

Ok(())
}

macro_rules! regexes {
Copy link
Contributor

Choose a reason for hiding this comment

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

What are these regexes for? I thought ui_test handled this for us. @oli-obk?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not really, e.g., it won't normalize 0x0000000000000000 to $HEX, and the line and column info to :LL:CC.

Copy link
Contributor

Choose a reason for hiding this comment

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

Gotcha! Can you add a comment saying what patterns we are matching and why? Regex are always so painful to maintain. Thanks

harness = false

[features]
# tidy-alphabetical-start
Copy link
Contributor

Choose a reason for hiding this comment

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

Why did you remove these directives?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

because we don't have the tidy tool in our repo

Copy link
Contributor

Choose a reason for hiding this comment

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

I have mixed feelings about this one. On the one hand, this crate will get synchronized with the rust repo, where they do enforce this. It will also be consistent with other rustc crates. On the other hand, leaving it on without guardrails can make sync a bit more painful.

I would suggest we leave it on and add a comment to folks changing Cargo.toml to ensure imports are in alphabetical order. If this becomes a hassle, we can remove it.

name = "rustc_public"
version = "0.1.0-preview"
authors = ["rustc_public team"]
description = "Define compiler intermediate representation usable by external tools"
Copy link
Contributor

Choose a reason for hiding this comment

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

🙂

@celinval
Copy link
Contributor

BTW, sorry for the delay. Next time, do you mind creating separate commits for moving files and content changes. It makes it much easier to visualize the content changes. Otherwise, everything looks like new code.

@makai410
Copy link
Contributor Author

Oh sorry about that, thanks for the reminder though. I'll make sure to do that next time.

@makai410
Copy link
Contributor Author

wait, is it possible to keep the files for the crates.io version in a separate directory? We can specify which Cargo.toml to use when building, and Cargo.toml itself can define the lib and build files.

I feel like maintaining two versions of lib.rs and Cargo.toml is quite ad-hoc. The problem here is that the crates.io version wants to enable rustc_private but the rustc version shouldn't. I think the conditional compilation should be good to solve this but how can we detect if it's living in the rustc or not?
@oli-obk @celinval Any ideas?

@celinval
Copy link
Contributor

Can we use a cargo feature to indicate that we are being built as part of the compiler?

@makai410
Copy link
Contributor Author

Yea but I think we'd still have to maintain two Cargo.toml.

@celinval
Copy link
Contributor

I actually think a config is probably the right way to go. We can set the config as part of the compiler bootstrap. Wouldn't we be able to keep the same code in that case?

@makai410
Copy link
Contributor Author

Sorry for the delay. I think the problem is that they don't share the same dependencies in the Cargo.toml, so if we sync things like rustc_middle = { path = "../rustc_middle" } into our repo, the build would fail.

But TBH now I feel OK with just maintaining two versions of Cargo.toml files and using a cargo feature to indicate where we're being built. And we could add a filter for the josh sync to exclude the Cargo.toml :) What do you think?

@oli-obk
Copy link
Contributor

oli-obk commented Sep 24, 2025

If you feel comfortable implementing that, I think it would be maintainable and understandable, so I'm good with it

@celinval
Copy link
Contributor

Sorry for the delay. I think the problem is that they don't share the same dependencies in the Cargo.toml, so if we sync things like rustc_middle = { path = "../rustc_middle" } into our repo, the build would fail.

But TBH now I feel OK with just maintaining two versions of Cargo.toml files and using a cargo feature to indicate where we're being built. And we could add a filter for the josh sync to exclude the Cargo.toml :) What do you think?

Ok... let's start there. We can adjust as we go. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants