-
Notifications
You must be signed in to change notification settings - Fork 13k
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
Deduplicate test suites for alternative codegen backends #128741
Comments
I'm all in favor of removing the duplication here. For tests like Since cg_gcc gets frequently broken by changes in the Rust repo (because most cg_gcc's tests are not ran in its CI), I do like to have the ability to run tests that do not require compiling the sysroot since it's often broken, so having tests without it make it easier to debug. I do not know if your idea of |
Having a single mini_core file in the repo (and having it in the ui test suite) instead of 4 would already be a good improvement. ;) |
Clearly there's some logic somewhere that iterates the files in |
Doing that would be OK, unless you're doing so in Rust and somehow use a sysroot compiled with cg_gcc to compile this Rust program iterating over the tests.
Not if this requires to compile the sysroot with cg_gcc, which I believe is the case for UI tests. There might be a possibility of using a LLVM-compiled sysroot in this case, though. All I'm saying is that we should keep the ability to run these tests without having to compile the sysroot with cg_gcc. Do you know if this would be possible? |
(replying here as that seems like a better place)
No this doesn't require a GCC-built sysroot I think. You need to use the libtest harness or something similar but you don't need to build it with GCC. The test harness should be an LLVM-built binary which, for each test file, invokes rustc with the GCC backend. Probably the easiest way to do this is using the ui_test crate, which Miri and Clippy also use. |
The tests are linked against the standard library, which needs either a cg_llvm compiled standard library which is abi compatible with your codegen backend, or needs to build the standard library using your codegen backend. Neither of which is the case during early development of a codegen backend. |
I was talking about some of these tests and the mini-core tests. |
Doing that would be OK, unless you're doing so in Rust and somehow use a sysroot compiled with cg_gcc to compile this Rust program iterating over the tests.
There is currently a program doing the iteration, whatever language it is written in surely can also do that based on a file.
Also, there are literally tests there that depend on std? E.g. "std_example". Something is clearly setting up a suitable sysroot already?
|
Perhaps I was not clear: while some tests depend on the std, some don't and I'd like to keep a way to run those tests without requiring compiling the sysroot with cg_gcc to help debugging. |
Yeah seems totally fine to keep a single But it shouldn't be necessary to have 4 copies of this that all need to be updated when something abut these very unstable lang items changes. |
The reason we need multiple copies of mini_core is because it needs to be available in the rust-lang/rustc_codegen_cranelift and rust-lang/rustc_codegen_gcc repos for their respective CI to be able to use it. If it were to be put in some common location in the rust repo, it wouldn't be available in the rust-lang/rustc_codegen_cranelift and rust-lang/rustc_codegen_gcc repos. Where are you counting 4 copies of mini_core by the way? Both cg_clif and cg_gcc should only have a single copy in |
It's not great to ask rustc contributors to keep all these copies in sync, though. There's a tradeoff here between making life easier for rustc contributors vs making life easier for people working in the backend repo. I am obviously biased here since I don't work in the backend repos at all, but the current situation is tedious for rustc contributors. On top of the fact that duplication is inherently undesirable and increases maintenance cost, there are test files strewed about in random subfolders that nobody expects ( So IMO we should find a better solution here, and IMO slightly increasing the burden on backend maintainers is an okay tradeoff if it makes life better for (a much larger number of) rustc contributors.
There's two mini_core.rs and two mini_core_hello_world.rs... but now that I look at it, the latter seem to import the former somehow, so I guess it's "just" two (plus similar file(s) in the ui test suite). |
There's another minicore at |
I'm not sure what solution would work, to be honest. |
My idea for quite a while has been to move some of the definitions for lang items like Sized and Add and intrinsics into rustc itself. Possibly as a synthetic crate that only exists in-memory. This would remove the majority of the things mini_core needs to define. I haven't worked out the practical implications of that yet though. Like how to handle docs or how to allow incoherent trait impls. |
I just ran into this again in #132717 -- I thought I could at least avoid redundant work by copying the updated version of one mini_core file to the other location, but no, the files are subtly different. IMO we should only have one such file in the rustc source tree. The current situation introduces too much friction for rustc development. Maybe we can ship it with the rustc-dev component so that the CI of subtrees like the codegen backends can get it from there? Cc @rust-lang/compiler |
@workingjubilee has previously mused about something like having the |
Currently, the cranelift and gcc codegen backends have tiny test suites in their respective folders that get run in rustc CI:
My understanding is that these are basically smoke-tests, but they use a lot of low-level internal and unstable APIs that keep changing, making them a maintenance hazard. As you can easily see, there's also a lot of duplication between them. I don't even know often I had to fix the mini_core tests (looks like both backends have two of them, for some reason). PRs like #128731 would benefit from adding another test there (
ui/simd/shuffle.rs
, in that case), but I don't want to add even more duplication.Is there any way we can deduplicate this? The first idea that comes to my mind is that instead of having these example files stored as copies in the respective backends, we have a
run-tests.txt
file (or so) that lists a bunch of filenames relative totests/ui
that should be built and run with the backend. That means./x.py test ui
, without even having to do the setup required for the alternative codegen backend.Cc @bjorn3 @antoyo @GuillaumeGomez
The text was updated successfully, but these errors were encountered: