diff options
| author | Jerry Wang <jerrylwang123@gmail.com> | 2024-06-22 20:16:51 -0400 |
|---|---|---|
| committer | Jerry Wang <jerrylwang123@gmail.com> | 2024-06-22 20:18:02 -0400 |
| commit | 75a9379c0ff62aeb8e79f7f848e6c1579d31ae63 (patch) | |
| tree | e1151de49963f6fd9098dec34ae94fff4f03769b | |
| parent | ac47dbad504b892bc0f3be8fa097537c6e0544a3 (diff) | |
| download | rust-75a9379c0ff62aeb8e79f7f848e6c1579d31ae63.tar.gz rust-75a9379c0ff62aeb8e79f7f848e6c1579d31ae63.zip | |
(wip) Migrate `branch-protection-check-IBT` to `rmake`
| -rw-r--r-- | tests/run-make/branch-protection-check-IBT/Makefile | 6 | ||||
| -rw-r--r-- | tests/run-make/branch-protection-check-IBT/_rmake.rs | 31 |
2 files changed, 37 insertions, 0 deletions
diff --git a/tests/run-make/branch-protection-check-IBT/Makefile b/tests/run-make/branch-protection-check-IBT/Makefile index cabe951e1c5..ee0e034627f 100644 --- a/tests/run-make/branch-protection-check-IBT/Makefile +++ b/tests/run-make/branch-protection-check-IBT/Makefile @@ -7,6 +7,12 @@ include ../tools.mk # only-x86_64 +# ignore-test +# FIXME(jieyouxu): This test never runs because the `ifeq` check on line 17 +# compares `x86` to `x86_64`, which always evaluates to false. +# When the test does run, the compilation does not include `.note.gnu.property`. +# See https://github.com/rust-lang/rust/pull/126720 for more information. + all: ifeq ($(filter x86,$(LLVM_COMPONENTS)),x86_64) $(RUSTC) --target x86_64-unknown-linux-gnu -Z cf-protection=branch -L$(TMPDIR) -C link-args='-nostartfiles' -C save-temps ./main.rs -o $(TMPDIR)/rsmain diff --git a/tests/run-make/branch-protection-check-IBT/_rmake.rs b/tests/run-make/branch-protection-check-IBT/_rmake.rs new file mode 100644 index 00000000000..d66ecf9c005 --- /dev/null +++ b/tests/run-make/branch-protection-check-IBT/_rmake.rs @@ -0,0 +1,31 @@ +// Check for GNU Property Note + +// How to run this +// python3 x.py test --target x86_64-unknown-linux-gnu tests/run-make/branch-protection-check-IBT/ + +//@ only-x86_64 + +//@ ignore-test +// FIXME(jieyouxu): see the FIXME in the Makefile + +use run_make_support::llvm_readobj; +use run_make_support::rustc; +use run_make_support::{cwd, env_var}; + +fn main() { + let llvm_components = env_var("LLVM_COMPONENTS"); + if !format!(" {llvm_components} ").contains(" x86 ") { + return; + } + + rustc() + .input("main.rs") + .target("x86_64-unknown-linux-gnu") + .arg("-Zcf-protection=branch") + .arg(format!("-L{}", cwd().display())) + .arg("-Clink-args=-nostartfiles") + .arg("-Csave-temps") + .run(); + + llvm_readobj().arg("-nW").input("main").run().assert_stdout_contains(".note.gnu.property"); +} |
