Home Explore Blog CI



rustc

6th chunk of `src/tests/directives.md`
c6c14c55866c439a3576e8e69ec6acfae2238f4ea757d24b000000010000107e
- `needs-unwind` — ignores if the target does not support unwinding
- `needs-rust-lld` — ignores if the rust lld support is not enabled (`rust.lld =
  true` in `bootstrap.toml`)
- `needs-threads` — ignores if the target does not have threading support
- `needs-subprocess`  — ignores if the target does not have subprocess support
- `needs-symlink` — ignores if the target does not support symlinks. This can be
  the case on Windows if the developer did not enable privileged symlink
  permissions.
- `ignore-std-debug-assertions` — ignores if std was built with debug
  assertions.
- `needs-std-debug-assertions` — ignores if std was not built with debug
  assertions.
- `ignore-rustc-debug-assertions` — ignores if rustc was built with debug
  assertions.
- `needs-rustc-debug-assertions` — ignores if rustc was not built with debug
  assertions.
- `needs-target-has-atomic` — ignores if target does not have support for all
  specified atomic widths, e.g. the test with `//@ needs-target-has-atomic: 8,
  16, ptr` will only run if it supports the comma-separated list of atomic
  widths.
- `needs-dynamic-linking` — ignores if target does not support dynamic linking
  (which is orthogonal to it being unable to create `dylib` and `cdylib` crate types)
- `needs-crate-type` — ignores if target platform does not support one or more
  of the comma-delimited list of specified crate types. For example,
  `//@ needs-crate-type: cdylib, proc-macro` will cause the test to be ignored
  on `wasm32-unknown-unknown` target because the target does not support the
  `proc-macro` crate type.

The following directives will check LLVM support:

- `exact-llvm-major-version: 19` — ignores if the llvm major version does not
  match the specified llvm major version.
- `min-llvm-version: 13.0` — ignored if the LLVM version is less than the given
  value
- `min-system-llvm-version: 12.0` — ignored if using a system LLVM and its
  version is less than the given value
- `max-llvm-major-version: 19` — ignored if the LLVM major version is higher
  than the given major version
- `ignore-llvm-version: 9.0` — ignores a specific LLVM version
- `ignore-llvm-version: 7.0 - 9.9.9` — ignores LLVM versions in a range
  (inclusive)
- `needs-llvm-components: powerpc` — ignores if the specific LLVM component was
  not built. Note: The test will fail on CI (when
  `COMPILETEST_REQUIRE_ALL_LLVM_COMPONENTS` is set) if the component does not
  exist.
- `needs-forced-clang-based-tests` — test is ignored unless the environment
  variable `RUSTBUILD_FORCE_CLANG_BASED_TESTS` is set, which enables building
  clang alongside LLVM
  - This is only set in two CI jobs ([`x86_64-gnu-debug`] and
    [`aarch64-gnu-debug`]), which only runs a
    subset of `run-make` tests. Other tests with this directive will not
    run at all, which is usually not what you want.

See also [Debuginfo tests](compiletest.md#debuginfo-tests) for directives for
ignoring debuggers.


### Affecting how tests are built

| Directive           | Explanation                                                                                  | Supported test suites     | Possible values                                                                            |
|---------------------|----------------------------------------------------------------------------------------------|---------------------------|--------------------------------------------------------------------------------------------|
| `compile-flags`     | Flags passed to `rustc` when building the test or aux file                                   | All except for `run-make` | Any valid `rustc` flags, e.g. `-Awarnings -Dfoo`. Cannot be `-Cincremental` or `--edition` |
| `edition`           | The edition used to build the test                                                           | All except for `run-make` | Any valid `--edition` value                                                                |
| `rustc-env`         | Env var to set when running `rustc`                                                          | All except for `run-make` | `<KEY>=<VALUE>`                                                                            |

Title: Controlling Test Execution: Target and LLVM Support Directives
Summary
This section details directives for controlling test execution based on target capabilities and LLVM support. It covers directives like `needs-unwind`, `needs-rust-lld`, `needs-threads`, `needs-subprocess`, `needs-symlink`, and directives related to debug assertions and atomic support. Additionally, it includes directives for checking LLVM versions and components, such as `exact-llvm-major-version`, `min-llvm-version`, `max-llvm-major-version`, `ignore-llvm-version`, and `needs-llvm-components`. It also mentions `needs-forced-clang-based-tests` for specific CI jobs. Finally, it provides a table outlining directives that affect how tests are built, including `compile-flags`, `edition`, and `rustc-env`, along with their explanations, supported test suites, and possible values.