rust/tests/run-make/mte-ffi/rmake.rs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

39 lines
1.1 KiB
Rust
Raw Permalink Normal View History

// Tests that MTE tags and values stored in the top byte of a pointer (TBI) are
// preserved across FFI boundaries (C <-> Rust).
// This test does not require MTE: whilst the test will use MTE if available, if it is not,
// arbitrary tag bits are set using TBI.
// This test is only valid for AArch64.
// The linker must be explicitly specified when cross-compiling, so it is limited to
// `aarch64-unknown-linux-gnu`.
//@ only-aarch64-unknown-linux-gnu
use run_make_support::{cc, dynamic_lib_name, extra_c_flags, run, rustc, target};
fn main() {
run_test("int");
run_test("float");
run_test("string");
run_test("function");
}
fn run_test(variant: &str) {
let flags = {
let mut flags = extra_c_flags();
flags.push("-march=armv8.5-a+memtag");
flags
};
println!("{variant} test...");
rustc()
.input(format!("foo_{variant}.rs"))
.target(target())
.linker("aarch64-linux-gnu-gcc")
.run();
cc().input(format!("bar_{variant}.c"))
.input(dynamic_lib_name("foo"))
.out_exe("test")
.args(&flags)
.run();
run("test");
}