From 9239d141dc4e9435b036d34cf8b2cb1e37b9f454 Mon Sep 17 00:00:00 2001 From: bjorn3 <17426603+bjorn3@users.noreply.github.com> Date: Fri, 5 Sep 2025 14:46:46 +0000 Subject: Add test that __rg_oom doesn't get internalized during LTO MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Rémy Rakic --- tests/ui/lto/lto-global-allocator.rs | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 tests/ui/lto/lto-global-allocator.rs diff --git a/tests/ui/lto/lto-global-allocator.rs b/tests/ui/lto/lto-global-allocator.rs new file mode 100644 index 00000000000..03f11709c90 --- /dev/null +++ b/tests/ui/lto/lto-global-allocator.rs @@ -0,0 +1,19 @@ +//@ compile-flags: --crate-type cdylib -C lto +//@ build-pass +//@ no-prefer-dynamic +//@ needs-crate-type: cdylib + +use std::alloc::{GlobalAlloc, Layout}; + +struct MyAllocator; + +unsafe impl GlobalAlloc for MyAllocator { + unsafe fn alloc(&self, _layout: Layout) -> *mut u8 { + todo!() + } + + unsafe fn dealloc(&self, _ptr: *mut u8, _layout: Layout) {} +} + +#[global_allocator] +static GLOBAL: MyAllocator = MyAllocator; -- cgit 1.4.1-3-g733a5