diff options
| author | Guillaume Gomez <guillaume1.gomez@gmail.com> | 2025-08-28 21:41:01 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-08-28 21:41:01 +0200 |
| commit | 9e4a28361570e4793ae77effd24901013e92c29b (patch) | |
| tree | 9fc4a784e2653cda8fcda8a4d491b4a32ec862c3 /tests | |
| parent | f948c79911844709ad8aeea23b211fb9790257c7 (diff) | |
| parent | cf8753e4f9c3597f04cd5d3aa261e4561d5378a6 (diff) | |
| download | rust-9e4a28361570e4793ae77effd24901013e92c29b.tar.gz rust-9e4a28361570e4793ae77effd24901013e92c29b.zip | |
Rollup merge of #145368 - rcvalle:rust-cfi-fix-142284, r=dianqk
CFI: Make `lto` and `linker-plugin-lto` work the same for `compiler_builtins` Fix rust-lang/rust#142284 by ensuring that `#![no_builtins]` crates can still emit bitcode when proper (i.e., non-rustc) LTO (i.e., -Clinker-plugin-lto) is used.
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/ui/sanitizer/cfi/no_builtins.rs | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/tests/ui/sanitizer/cfi/no_builtins.rs b/tests/ui/sanitizer/cfi/no_builtins.rs new file mode 100644 index 00000000000..949057689ab --- /dev/null +++ b/tests/ui/sanitizer/cfi/no_builtins.rs @@ -0,0 +1,22 @@ +// Verifies that `#![no_builtins]` crates can be built with linker-plugin-lto and CFI. +// See Issue #142284 +// +//@ needs-sanitizer-cfi +//@ compile-flags: -Clinker-plugin-lto -Copt-level=0 -Zsanitizer=cfi -Ctarget-feature=-crt-static +//@ compile-flags: --crate-type rlib +//@ build-pass + +#![no_builtins] +#![no_std] + +pub static FUNC: fn() = initializer; + +pub fn initializer() { + call(fma_with_fma); +} + +pub fn call(fn_ptr: fn()) { + fn_ptr(); +} + +pub fn fma_with_fma() {} |
