-
-
Notifications
You must be signed in to change notification settings - Fork 14.4k
compiletest/codegen-llvm: automatically add needs-target-std if needed
#150672
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
compiletest/codegen-llvm: automatically add needs-target-std if needed
#150672
Conversation
|
Some changes occurred in src/tools/compiletest cc @jieyouxu |
This comment has been minimized.
This comment has been minimized.
When running the codegen-llvm test suite, the "needs-target-std" directive is automatically added if and only if the "#![no_std]" line is not seen and the "needs-target-std" directive was not already seen. This is a best-effort utility to make running the codegen-llvm test suite for targets that do not support std slightly easier.
aab1410 to
0675c97
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The idea seems okay to me, I'll think about the impl a bit tho, because "injecting synthesized directive" feels a tad bit hacky
|
Reminder, once the PR becomes ready for a review, use |
…=Zalathar compiletest: add implied `needs-target-std` for `codegen` mode tests unless annotated with `#![no_std]`/`#![no_core]` A `codegen` mode test (such as `codegen-llvm` test suite) will now by default have an implied `//@ needs-target-std` directive, *unless* the test explicitly has an `#![no_std]`/`#![no_core]` attribute which disables this behavior. - When a test has both `#![no_std]`/`#![no_core]` and `//@ needs-target-std`, the explicit `//@ needs-target-std` directive will cause the test to be ignored for targets that do not support std still. This is to make it easier to test out-of-tree targets / custom targets (and targets not tested in r-l/r CI) without requiring target maintainers to do a bunch of manual `//@ needs-target-std` busywork. Context: [#t-compiler/help > &rust-lang#96;compiletest&rust-lang#96; cannot find &rust-lang#96;core&rust-lang#96; library for target != host](https://rust-lang.zulipchat.com/#narrow/channel/182449-t-compiler.2Fhelp/topic/.60compiletest.60.20cannot.20find.20.60core.60.20library.20for.20target.20!.3D.20host/with/568652419) ## Implementation remarks This is an alternative version of rust-lang#150672, with some differences: - *This* PR applies this implied-`needs-target-std` behavior to all `codegen` test mode tests. - *This* PR does the synthetic directive injection in the same place as implied-`codegen-run` directives. Both are of course hacks, but at least they're together next to each other.
Rollup merge of #151294 - jieyouxu:infer-needs-target-std, r=Zalathar compiletest: add implied `needs-target-std` for `codegen` mode tests unless annotated with `#![no_std]`/`#![no_core]` A `codegen` mode test (such as `codegen-llvm` test suite) will now by default have an implied `//@ needs-target-std` directive, *unless* the test explicitly has an `#![no_std]`/`#![no_core]` attribute which disables this behavior. - When a test has both `#![no_std]`/`#![no_core]` and `//@ needs-target-std`, the explicit `//@ needs-target-std` directive will cause the test to be ignored for targets that do not support std still. This is to make it easier to test out-of-tree targets / custom targets (and targets not tested in r-l/r CI) without requiring target maintainers to do a bunch of manual `//@ needs-target-std` busywork. Context: [#t-compiler/help > `compiletest` cannot find `core` library for target != host](https://rust-lang.zulipchat.com/#narrow/channel/182449-t-compiler.2Fhelp/topic/.60compiletest.60.20cannot.20find.20.60core.60.20library.20for.20target.20!.3D.20host/with/568652419) ## Implementation remarks This is an alternative version of #150672, with some differences: - *This* PR applies this implied-`needs-target-std` behavior to all `codegen` test mode tests. - *This* PR does the synthetic directive injection in the same place as implied-`codegen-run` directives. Both are of course hacks, but at least they're together next to each other.
|
☔ The latest upstream changes (presumably #151667) made this pull request unmergeable. Please resolve the merge conflicts. |
compiletest: add implied `needs-target-std` for `codegen` mode tests unless annotated with `#![no_std]`/`#![no_core]` A `codegen` mode test (such as `codegen-llvm` test suite) will now by default have an implied `//@ needs-target-std` directive, *unless* the test explicitly has an `#![no_std]`/`#![no_core]` attribute which disables this behavior. - When a test has both `#![no_std]`/`#![no_core]` and `//@ needs-target-std`, the explicit `//@ needs-target-std` directive will cause the test to be ignored for targets that do not support std still. This is to make it easier to test out-of-tree targets / custom targets (and targets not tested in r-l/r CI) without requiring target maintainers to do a bunch of manual `//@ needs-target-std` busywork. Context: [#t-compiler/help > `compiletest` cannot find `core` library for target != host](https://rust-lang.zulipchat.com/#narrow/channel/182449-t-compiler.2Fhelp/topic/.60compiletest.60.20cannot.20find.20.60core.60.20library.20for.20target.20!.3D.20host/with/568652419) ## Implementation remarks This is an alternative version of rust-lang/rust#150672, with some differences: - *This* PR applies this implied-`needs-target-std` behavior to all `codegen` test mode tests. - *This* PR does the synthetic directive injection in the same place as implied-`codegen-run` directives. Both are of course hacks, but at least they're together next to each other.
When running the codegen-llvm test suite, the
needs-target-stddirective is automatically added if and only if the#![no_std]line is not seen and theneeds-target-stddirective was not already seen.This is a best-effort help to make running the codegen-llvm test suite for targets that do not support std slightly easier. Ideally, with time, the tests that aren't marked as no_std but in fact only use types from core/alloc will be patched to reflect this, so that they can be reused for targets without std.
For an explanation of this patch instead of a patch that marks all the tests that aren't
#![no_std]withneeds-target-std, see this Zulip thread. Let me know if, instead, a patch adding theneeds-target-stdis preferred.A simple test of the introduced behaviour is
./x test tests/codegen-llvm/align-fn.rs --target=riscv32e-unknown-none-elf --force-rerun -v. The test does not have theneeds-target-stddirective, but it is ignored with this message: