Adjust some run-make tests on cross-compile

This commit is contained in:
Jieyou Xu
2025-06-16 20:24:50 +08:00
parent 49be6f3258
commit 2beccc4d8e
63 changed files with 143 additions and 79 deletions

View File

@@ -1,4 +1,4 @@
//@ needs-target-std
//@ ignore-cross-compile
// Test that `-Awarnings` suppresses warnings for unstable APIs.
use run_make_support::rustc;

View File

@@ -1,5 +1,5 @@
//@ needs-target-std
//
//@ ignore-cross-compile
// Test that previously triggered a linker failure with root cause
// similar to one found in the issue #69368.
//

View File

@@ -1,4 +1,5 @@
//@ needs-target-std
//@ ignore-cross-compile (needs to run doctests)
use std::path::Path;
use run_make_support::{cwd, diff, rustc, rustdoc};

View File

@@ -1,5 +1,5 @@
//@ needs-target-std
//
//@ ignore-cross-compile (needs to run host tool binary)
// Tests behavior of rustdoc `--test-runtool`.
use std::path::PathBuf;

View File

@@ -1,5 +1,6 @@
//@ needs-target-std
//
//@ ignore-cross-compile
//@ needs-crate-type: dylib
// Tests the -Zembed-metadata compiler flag.
// Tracking issue: https://github.com/rust-lang/rust/issues/139165

View File

@@ -1,6 +1,8 @@
//@ needs-target-std
//@ ignore-windows
//@ ignore-apple
//@ ignore-wasm (`object` doesn't handle wasm object files)
//@ ignore-cross-compile
// This test should be replaced with one in tests/debuginfo once we can easily
// tell via GDB or LLDB if debuginfo contains source code. Cheap tricks in LLDB

View File

@@ -5,6 +5,8 @@
// `all-shared` should only emit files that can be shared between crates.
// See https://github.com/rust-lang/rust/pull/83478
//@ needs-target-std
use run_make_support::{has_extension, has_prefix, path, rustdoc, shallow_find_files};
fn main() {

View File

@@ -7,8 +7,7 @@
// See https://github.com/rust-lang/rust/pull/51946
//@ needs-target-std
//@ ignore-windows
//@ ignore-apple
//@ only-elf
// Reason: this feature only works when the output object format is ELF.
// This won't be the case on Windows/OSX - for example, OSX produces a Mach-O binary.

View File

@@ -1,5 +1,7 @@
//@ needs-target-std
//
//@ ignore-cross-compile
//@ needs-crate-type: proc-macro
//@ ignore-musl (FIXME: can't find `-lunwind`)
// Inside dep-info emit files, #71858 made it so all accessed environment
// variables are usefully printed. This test checks that this feature works
// as intended by checking if the environment variables used in compilation

View File

@@ -1,5 +1,5 @@
//@ needs-target-std
//
//@ ignore-cross-compile
// Test that we exit with the correct exit code for successful / unsuccessful / ICE compilations
use run_make_support::{rustc, rustdoc};

View File

@@ -8,9 +8,8 @@
// Reason: the export-executable-symbols flag only works on Unix
// due to hardcoded platform-specific implementation
// (See #85673)
//@ ignore-wasm32
//@ ignore-wasm64
//@ needs-target-std
//@ ignore-cross-compile
//@ ignore-wasm
use run_make_support::{bin_name, llvm_readobj, rustc};

View File

@@ -1,4 +1,8 @@
//@ needs-target-std
//@ ignore-cross-compile
// NOTE: `sdylib`'s platform support is basically just `dylib`'s platform support.
//@ needs-crate-type: dylib
use run_make_support::rustc;
fn main() {

View File

@@ -1,4 +1,8 @@
//@ needs-target-std
//@ ignore-cross-compile
// NOTE: `sdylib`'s platform support is basically that of `dylib`.
//@ needs-crate-type: dylib
use run_make_support::{dynamic_lib_name, rustc};
fn main() {

View File

@@ -1,4 +1,8 @@
//@ needs-target-std
//@ ignore-cross-compile
// NOTE: `sdylib`'s platform support is basically that of `dylib`.
//@ needs-crate-type: dylib
use run_make_support::rustc;
fn main() {

View File

@@ -1,5 +1,5 @@
//@ needs-target-std
//
//@ ignore-cross-compile
// In the following scenario:
// 1. The crate foo, is referenced multiple times
// 2. --extern foo=./path/to/libbar.rlib is specified to rustc

View File

@@ -1,4 +1,4 @@
//@ needs-target-std
//@ ignore-cross-compile
//
// The --extern flag can override the default crate search of
// the compiler and directly fetch a given path. There are a few rules

View File

@@ -1,5 +1,5 @@
//@ needs-target-std
//
//@ ignore-cross-compile
// In this test, the rust library foo1 exists in two different locations, but only one
// is required by the --extern flag. This test checks that the copy is ignored (as --extern
// demands fetching only the original instance of foo1) and that no error is emitted, resulting

View File

@@ -1,5 +1,5 @@
//@ needs-target-std
//
//@ ignore-cross-compile
// Almost identical to `extern-multiple-copies`, but with a variation in the --extern calls
// and the addition of #[macro_use] in the rust code files, which used to break --extern
// until #33625.

View File

@@ -9,6 +9,7 @@
//@ only-x86_64
//@ only-linux
//@ ignore-cross-compile
// Reason: This is a platform-independent issue, no need to waste time testing
// everywhere.

View File

@@ -7,7 +7,9 @@
// See https://github.com/rust-lang/rust/pull/95604
// See https://github.com/rust-lang/rust/issues/47384
//@ needs-target-std
//@ ignore-cross-compile
//@ needs-crate-type: cdylib
//@ needs-dynamic-linking
//@ ignore-wasm differences in object file formats causes errors in the llvm_objdump step.
//@ ignore-windows differences in object file formats causes errors in the llvm_objdump step.

View File

@@ -7,7 +7,7 @@
// was hashed by rustc in addition to the span length, and the fix still
// works.
//@ needs-target-std
//@ ignore-cross-compile
use run_make_support::{rfs, rustc};

View File

@@ -9,7 +9,7 @@
// for successful compilation.
// See https://github.com/rust-lang/rust/issues/83112
//@ needs-target-std
//@ ignore-cross-compile
use run_make_support::{rfs, rustc};

View File

@@ -4,6 +4,7 @@
// which means the emitted artifacts should be shorter in length.
// See https://github.com/rust-lang/rust/pull/16970
//@ needs-target-std
//@ needs-asm-support
//@ ignore-windows
// Reason: Because of Windows exception handling, the code is not necessarily any shorter.

View File

@@ -1,5 +1,7 @@
//@ needs-target-std
//
//@ needs-crate-type: dylib
//@ needs-dynamic-linking
// When a fake library was given to the compiler, it would
// result in an obscure and unhelpful error message. This test
// creates a false "foo" dylib, and checks that the standard error

View File

@@ -1,5 +1,5 @@
//@ needs-target-std
//
//@ ignore-cross-compile
// Non-regression test for issues #125474, #125484, #125646, with the repro taken from #125484. Some
// queries use "used dependencies" while others use "speculatively loaded dependencies", and an
// indexing ICE appeared in some cases when these were unexpectedly used in the same context.

View File

@@ -1,5 +1,5 @@
//@ needs-target-std
//
//@ ignore-cross-compile
// The byte positions in json format error logging used to have a small, difficult
// to predict offset. This was changed to be the top of the file every time in #42973,
// and this test checks that the measurements appearing in the standard error are correct.

View File

@@ -1,5 +1,6 @@
//@ needs-target-std
//
//@ ignore-wasm (explicit linker invocations)
// Passing linker arguments to the compiler used to be lost or reordered in a messy way
// as they were passed further to the linker. This was fixed in #70665, and this test
// checks that linker arguments remain intact and in the order they were originally passed in.

View File

@@ -1,5 +1,5 @@
//@ needs-target-std
//
//@ ignore-musl (not passed consecutively)
// When native libraries are passed to the linker, there used to be an annoyance
// where multiple instances of the same library in a row would cause duplication in
// outputs. This has been fixed, and this test checks that it stays fixed.
@@ -9,7 +9,7 @@
use std::fmt::Write;
use run_make_support::{is_msvc, rustc};
use run_make_support::{is_msvc, rustc, target};
fn main() {
rustc().input("depa.rs").run();
@@ -33,9 +33,11 @@ fn needle_from_libs(libs: &[&str]) -> String {
let mut needle = String::new();
for lib in libs {
if is_msvc() {
let _ = needle.write_fmt(format_args!(r#""{lib}.lib" "#));
needle.write_fmt(format_args!(r#""{lib}.lib" "#)).unwrap();
} else if target().contains("wasm") {
needle.write_fmt(format_args!(r#""-l" "{lib}" "#)).unwrap();
} else {
let _ = needle.write_fmt(format_args!(r#""-l{lib}" "#));
needle.write_fmt(format_args!(r#""-l{lib}" "#)).unwrap();
}
}
needle.pop(); // remove trailing space

View File

@@ -1,4 +1,5 @@
//@ needs-target-std
//@ ignore-cross-compile (need to run fake linker)
use run_make_support::{Rustc, diff, regex, rustc};
fn run_rustc() -> Rustc {

View File

@@ -12,7 +12,7 @@
// sessions.
// See https://github.com/rust-lang/rust/issues/85019
//@ needs-target-std
//@ ignore-cross-compile
use run_make_support::{rfs, rust_lib_name, rustc};

View File

@@ -1,5 +1,8 @@
//@ ignore-windows
//@ only-x86_64
//@ needs-target-std
//@ needs-crate-type: dylib
use run_make_support::object::ObjectSymbol;
use run_make_support::object::read::{File, Object, Symbol};
use run_make_support::targets::is_windows;

View File

@@ -1,10 +1,8 @@
//@ needs-target-std
//
//@ ignore-cross-compile
// On MSVC the alternative naming format for static libraries (`libfoo.a`) is accepted in addition
// to the default format (`foo.lib`).
//REMOVE@ only-msvc
use run_make_support::rustc;
fn main() {

View File

@@ -3,8 +3,9 @@
// This test is the same as native-link-modifier-rustc, but without rlibs.
// See https://github.com/rust-lang/rust/issues/99425
//@ needs-target-std
//@ ignore-cross-compile
//@ ignore-apple
//@ ignore-wasm
// Reason: linking fails due to the unusual ".ext" staticlib name.
use run_make_support::rustc;

View File

@@ -1,5 +1,5 @@
CHECK: declare void @foo()
CHECK: declare{{.*}} void @foo()
CHECK-SAME: #[[ATTR_3:[0-9]+]]
CHECK: attributes #[[ATTR_3]]
CHECK: attributes #[[ATTR_3]]
CHECK-SAME: no-builtins

View File

@@ -1,5 +1,4 @@
//@ needs-target-std
//
// `no_builtins` is an attribute related to LLVM's optimizations. In order to ensure that it has an
// effect on link-time optimizations (LTO), it should be added to function declarations in a crate.
// This test uses the `llvm-filecheck` tool to determine that this attribute is successfully
@@ -11,5 +10,6 @@ use run_make_support::{llvm_filecheck, rfs, rustc};
fn main() {
rustc().input("no_builtins.rs").emit("link").run();
rustc().input("main.rs").emit("llvm-ir").run();
llvm_filecheck().patterns("filecheck.main.txt").stdin_buf(rfs::read("main.ll")).run();
}

View File

@@ -1,5 +1,5 @@
//@ needs-target-std
//
//@ ignore-cross-compile
// The rlib produced by a no_builtins crate should be explicitly linked
// during compilation, and as a result be present in the linker arguments.
// See the comments inside this file for more details.

View File

@@ -1,4 +1,4 @@
//@ needs-target-std
//@ ignore-cross-compile
use run_make_support::{rfs, rustc};
fn main() {

View File

@@ -1,5 +1,7 @@
//@ needs-target-std
//
//@ ignore-cross-compile
//@ needs-crate-type: proc-macro
//@ ignore-musl (FIXME: can't find `-lunwind`)
// A compiler bug caused the following issue:
// If a crate A depends on crate B, and crate B
// depends on crate C, and crate C contains a procedural

View File

@@ -1,6 +1,7 @@
// This tests the different -Crelro-level values, and makes sure that they work properly.
//@ only-linux
//@ ignore-cross-compile
use run_make_support::{llvm_readobj, rustc};

View File

@@ -1,4 +1,5 @@
//@ needs-target-std
//@ ignore-cross-compile
//@ ignore-wasm (`object` can't handle wasm object files)
//@ ignore-windows
// This test should be replaced with one in tests/debuginfo once GDB or LLDB support 128-bit enums.

View File

@@ -6,7 +6,7 @@
// Outputs should be identical.
// See https://github.com/rust-lang/rust/issues/34902
//@ needs-target-std
//@ ignore-cross-compile
//@ ignore-windows
// Reasons:
// 1. The object files are reproducible, but their paths are not, which causes

View File

@@ -1,5 +1,5 @@
//@ needs-target-std
//
//@ ignore-cross-compile
// `-Z packed_bundled_libs` is an unstable rustc flag that makes the compiler
// only require a native library and no supplementary object files to compile.
// This test simply checks that this flag can be passed alongside verbatim syntax

View File

@@ -1,5 +1,7 @@
//@ needs-target-std
//
//@ ignore-cross-compile
//@ needs-crate-type: proc-macro
//@ ignore-musl (FIXME: can't find `-lunwind`)
// --emit dep-info used to print all macro-generated code it could
// find as if it was part of a nonexistent file named "proc-macro source",
// which is not a valid path. After this was fixed in #36776, this test checks

View File

@@ -3,10 +3,10 @@
// ensures the output of rustdoc's help menu is as expected.
// See https://github.com/rust-lang/rust/issues/88756
use run_make_support::{diff, rustdoc};
use run_make_support::{bare_rustdoc, diff};
fn main() {
let out = rustdoc().run().stdout_utf8();
let out = bare_rustdoc().run().stdout_utf8();
diff()
.expected_file("output-default.stdout")
.actual_text("actual", out)

View File

@@ -1,6 +1,8 @@
// This is a simple smoke test for rustdoc's `--emit dep-info` feature. It prints out
// information about dependencies in a Makefile-compatible format, as a `.d` file.
//@ needs-target-std
use run_make_support::assertion_helpers::assert_contains;
use run_make_support::{path, rfs, rustdoc};

View File

@@ -1,6 +1,8 @@
// Assert that the search index is generated deterministically, regardless of the
// order that crates are documented in.
//@ needs-target-std
use run_make_support::{diff, path, rustdoc};
fn main() {

View File

@@ -1,6 +1,8 @@
// Assert that the search index is generated deterministically, regardless of the
// order that crates are documented in.
//@ needs-target-std
use run_make_support::rustdoc;
fn main() {

View File

@@ -13,6 +13,7 @@
// containers would use a non-root user, but this leads to issues with
// `mkfs.ext4 -d`, as well as mounting a loop device for the rootfs.
//@ ignore-windows - the `set_readonly` functions doesn't work on folders.
//@ needs-target-std
use run_make_support::{path, rfs, rustdoc};

View File

@@ -1,6 +1,8 @@
// This test ensures that all items from `foo` are correctly generated into the `redirect-map.json`
// file with `--generate-redirect-map` rustdoc option.
//@ needs-target-std
use run_make_support::rfs::read_to_string;
use run_make_support::{path, rustdoc, serde_json};

View File

@@ -1,5 +1,7 @@
// Checks that if the output folder doesn't exist, rustdoc will create it.
//@ needs-target-std
use run_make_support::{path, rustdoc};
fn main() {

View File

@@ -1,6 +1,8 @@
// This test verifies that rustdoc `-o -` prints JSON on stdout and doesn't generate
// a JSON file.
//@ needs-target-std
use run_make_support::path_helpers::{cwd, has_extension, read_dir_entries_recursive};
use run_make_support::{rustdoc, serde_json};

View File

@@ -1,3 +1,5 @@
//@ ignore-cross-compile (needs to run doctest binary)
use std::iter;
use std::path::Path;

View File

@@ -1,5 +1,7 @@
// Test that rustdoc will properly load in a theme file and display it in the theme selector.
//@ needs-target-std
use std::path::Path;
use run_make_support::{htmldocck, rfs, rustdoc, source_root};

View File

@@ -1,3 +1,5 @@
//@ needs-target-std
use std::path::{Path, PathBuf};
use run_make_support::{assert_dirs_are_equal, rfs, rustdoc};

View File

@@ -1,3 +1,5 @@
//@ needs-target-std
use run_make_support::{htmldocck, rustdoc};
fn main() {

View File

@@ -1,3 +1,5 @@
//@ needs-target-std
use run_make_support::{htmldocck, rustdoc};
fn main() {

View File

@@ -1,5 +1,7 @@
//@ needs-target-std
//
//@ ignore-cross-compile
//@ needs-dynamic-linking
//@ needs-crate-type: dylib
// This test makes sure all generic instances get re-exported from Rust dylibs for use by
// `-Zshare-generics`. There are two rlibs (`instance_provider_a` and `instance_provider_b`)
// which both provide an instance of `Cell<i32>::set`. There is `instance_user_dylib` which is

View File

@@ -1,5 +1,5 @@
//@ needs-target-std
//
//@ ignore-cross-compile
// Regression test for https://github.com/rust-lang/rust/issues/107407 which
// checks that rustc can read thin archive. Before the object crate added thin
// archive support rustc would add emit object files to the staticlib and after

View File

@@ -1,9 +1,9 @@
//@ needs-target-std
//@ ignore-cross-compile
//! This test checks rustc `-` (stdin) support
use std::path::PathBuf;
use run_make_support::{is_windows, rustc};
use run_make_support::{bin_name, rustc};
const HELLO_WORLD: &str = r#"
fn main() {
@@ -16,11 +16,7 @@ const NOT_UTF8: &[u8] = &[0xff, 0xff, 0xff];
fn main() {
// echo $HELLO_WORLD | rustc -
rustc().arg("-").stdin_buf(HELLO_WORLD).run();
assert!(
PathBuf::from(if !is_windows() { "rust_out" } else { "rust_out.exe" })
.try_exists()
.unwrap()
);
assert!(PathBuf::from(bin_name("rust_out")).try_exists().unwrap());
// echo $NOT_UTF8 | rustc -
rustc().arg("-").stdin_buf(NOT_UTF8).run_fail().assert_stderr_contains(

View File

@@ -1,3 +1,5 @@
//@ ignore-cross-compile (needs to run doctests)
//! This test checks rustdoc `-` (stdin) handling
use std::path::PathBuf;

View File

@@ -1,5 +1,7 @@
//@ needs-target-std
//
//@ ignore-cross-compile
//@ needs-crate-type: dylib, cdylib, proc-macro
//@ needs-dynamic-linking
// Dynamic libraries on Rust used to export a very high amount of symbols,
// going as far as filling the output with mangled names and generic function
// names. After the rework of #38117, this test checks that no mangled Rust symbols

View File

@@ -1,5 +1,7 @@
//@ needs-target-std
//
//@ ignore-cross-compile
//@ needs-crate-type: proc-macro
//@ ignore-musl (FIXME: can't find `-lunwind`)
// This test checks the functionality of `tracked_path::path`, a procedural macro
// feature that adds a dependency to another file inside the procmacro. In this case,
// the text file is added through this method, and the test checks that the compilation

View File

@@ -1,5 +1,6 @@
//@ needs-target-std
//
//@ ignore-wasm (`object` can't handle wasm object files)
// This test ensures that the compiler is keeping static variables, even if not referenced
// by another part of the program, in the output object file.
//