Rollup merge of #149969 - jyn514:ibt, r=jieyouxu

don't use no_main and no_core to test IBT

The previous test was quite fragile and depended on a bunch of internal features. Simplify it.

Split out of https://github.com/rust-lang/rust/pull/149937.

cc ```@jieyouxu``` ```@Oneirical```
This commit is contained in:
Matthias Krüger
2025-12-14 20:04:57 +01:00
committed by GitHub
3 changed files with 11 additions and 9 deletions
@@ -0,0 +1 @@
#![no_std]
@@ -1,5 +0,0 @@
#![feature(no_core)]
#![allow(internal_features)]
#![no_core]
#![no_std]
#![no_main]
@@ -41,13 +41,19 @@
use run_make_support::{bare_rustc, llvm_readobj};
fn main() {
// `main.rs` is `#![no_std]` to not pull in the currently not-compiled-with-IBT precompiled std.
// `lib.rs` is `#![no_std]` to not pull in the currently not-compiled-with-IBT precompiled std.
bare_rustc()
.input("main.rs")
.input("lib.rs")
.crate_type("lib")
.emit("obj=lib.o")
.target("x86_64-unknown-linux-gnu")
.arg("-Zcf-protection=branch")
.arg("-Clink-args=-nostartfiles")
.run();
llvm_readobj().arg("-nW").input("main").run().assert_stdout_contains(".note.gnu.property");
llvm_readobj()
.arg("-nW")
.input("lib.o")
.run()
.assert_stdout_contains(".note.gnu.property")
.assert_stdout_contains("feature: IBT");
}