Implement `//@ target` directive for cross-compilation test directives
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 119k
- Forks
- 16.1k
- PR merge metrics
- PR metrics pending
Description
Currently, compiletest directives like needs-asm-support, needs-unwind, and others check properties of the host architecture rather than the target architecture. This creates issues for cross-compilation tests that use --target flags, as they may be incorrectly skipped or executed based on host capabilities rather than the capabilities of the target being tested.
Background
This issue arose from the discussion in #147406, where needs-asm-support was being removed from tests that explicitly cross-compile to specific targets. The directive was checking host asm support and causing tests to be skipped on hosts like ppc64le (which doesn't have stable asm support), even when testing targets like s390x or x86_64 (which do support asm).
As noted by @cuviper in that PR: for in-tree compiler tests, if someone wrote a target-specific asm test, that target obviously supports asm.
Suggestion from PR Discussion
During the review of PR #147406, @bjorn3 and @workingjubilee suggested implementing a //@ target <triple> directive as a more comprehensive solution to the host-vs-target confusion in compiletest directives.
The idea, as I understand it from the discussion, would be to create a directive that automatically handles test requirements based on the target architecture. This could potentially:
- Automatically determine required LLVM components (eliminating manual
needs-llvm-components) - Check target capabilities (asm support, unwind support, etc.) based on the target, not the host
- Set the compilation target (replacing or supplementing
--targetincompile-flags) - Default to the host target when not specified (maintaining current behavior)
If feasible, this could make cross-compilation tests simpler and less error-prone, as the test infrastructure would automatically know what's needed based on the target triple. Having a target directive makes it very clear that the test is cross-compiled as well.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Review the discussion in #147406 and the existing compiletest directives such as needs-asm-support, needs-unwind, and needs-llvm-components. Trace how --target is handled in compile-flags, then define the //@ target <triple> behavior so target capabilities and compilation use the selected target while preserving host-target defaults.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- compilers, testing-qa
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100