rust-lang / rust-lang/rust

Real cross-compiling tests instead of `#![no_core]` silliness

Open
#130,375 14 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

A-compiletest A-cross A-testsuite C-enhancement E-hard T-bootstrap T-compiler
Dominant language
Rust
Stars
119k
Forks
16.1k
PR merge metrics
PR metrics pending

Description

We have a zillion tests that use the #![no_core] hack, like this one: https://github.com/rust-lang/rust/blob/5e3ede22ef6fd23197629c22b9f466b3734e19f1/tests/ui/asm/bad-template.rs#L10

A given test involves:

  • Host A
  • Target B
  • Some Rust source (compiled for Target B)
  • Test tooling (run on Host A)

Most of our test infra assumes that Host A and Target B are the same thing. This greatly simplifies a lot of assumptions. But this hack we have introduced in so many tests essentially exists so that we can be sure the test runs even when cross-compiling from Host A to Target B. It's possible there's some weird finagling of test flags that can enable this without the hack, but that would be another hack itself. Cross-compiled tests should be relatively easy, like just writing something like:

//@ cross-compile-targets: arch_1-unknown-os_3-env_5 arch_2-unknown-os_4-env_6 arch_1-unknown-os_4-env_5 arch_2-unknown-os_3-env_7

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with tests/ui/asm/bad-template.rs and inspect the surrounding test infrastructure assumptions about Host A and Target B. Trace how a cross-compile-targets directive could select targets for a test, and define done as cross-compiled tests running without the #![no_core] workaround.

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.