Skip to content

Establish Infrastructure#105

Merged
celinval merged 7 commits intorust-lang:mainfrom
makai410:infra-cl
Oct 22, 2025
Merged

Establish Infrastructure#105
celinval merged 7 commits intorust-lang:mainfrom
makai410:infra-cl

Conversation

@makai410
Copy link
Member

@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
Member 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
Member 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
Member 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
Member 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
Member Author

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

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
Member 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
Member 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

@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
Member Author

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

@makai410
Copy link
Member 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
Member 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
Member 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!

@celinval
Copy link
Contributor

celinval commented Oct 2, 2025

Hey @makai410 is this ready?

@makai410
Copy link
Member Author

Sorry for the delay again... I think it's ready now.

Copy link
Contributor

@celinval celinval left a comment

Choose a reason for hiding this comment

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

Let me know if the comments make sense. If so, feel free to merge once you address them. Thanks!!

license = "MIT OR Apache-2.0"
repository = "https://github.com/rust-lang/project-stable-mir"
edition = "2024"
build = "../build.rs"
Copy link
Contributor

Choose a reason for hiding this comment

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

Sorry, I just noticed this change now. Why are we moving the build script to a different folder?

Copy link
Member Author

Choose a reason for hiding this comment

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

The build script checks the rustc version and would fail if synced back to rustc. So moving it to a different folder fixes this.

Copy link
Member Author

Choose a reason for hiding this comment

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

We'd enable the build script only 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.

Can you wrap the logic inside #[cfg(not(feature = "rustc-build"))] feature and keep the build script as is? I know you are planning to keep two separate copies of Cargo.toml, but I don't think we need to do the same for the build.rs.

Copy link
Member Author

Choose a reason for hiding this comment

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

Ah makes sense.

@celinval celinval merged commit 6500c72 into rust-lang:main Oct 22, 2025
2 checks passed
makai410 added a commit to makai410/rustc_public that referenced this pull request Nov 10, 2025
* make rustc_public a `crates.io` crate

* establish infrastructrure

* move `tests/` to `rustc_public/`

s

* conditional compilation of rustc crates

* remove redundant content in rustfmt.toml

* remove rust-toolchain.toml of rustc_public

* add `Cargo.lock`
makai410 added a commit to makai410/rustc_public that referenced this pull request Dec 1, 2025
* make rustc_public a `crates.io` crate

* establish infrastructrure

* move `tests/` to `rustc_public/`

s

* conditional compilation of rustc crates

* remove redundant content in rustfmt.toml

* remove rust-toolchain.toml of rustc_public

* add `Cargo.lock`
makai410 added a commit to makai410/rustc_public that referenced this pull request Dec 2, 2025
* make rustc_public a `crates.io` crate

* establish infrastructrure

* move `tests/` to `rustc_public/`

s

* conditional compilation of rustc crates

* remove redundant content in rustfmt.toml

* remove rust-toolchain.toml of rustc_public

* add `Cargo.lock`
makai410 added a commit to makai410/rustc_public that referenced this pull request Dec 2, 2025
* make rustc_public a `crates.io` crate

* establish infrastructrure

* move `tests/` to `rustc_public/`

s

* conditional compilation of rustc crates

* remove redundant content in rustfmt.toml

* remove rust-toolchain.toml of rustc_public

* add `Cargo.lock`
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