about summary refs log tree commit diff
path: root/tests
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2025-09-06 15:21:16 +0000
committerbors <bors@rust-lang.org>2025-09-06 15:21:16 +0000
commitbea625f3275e3c897dc965ed97a1d19ef7831f01 (patch)
treef32cdc8fb33ca70d76fade0ba3a5af10a2c7d6bf /tests
parent6d5caf3a4a358c80f09ba51d71db0dbc41381992 (diff)
parent2cf94b92ca852924ad90943a0c469f01742216a6 (diff)
downloadrust-bea625f3275e3c897dc965ed97a1d19ef7831f01.tar.gz
rust-bea625f3275e3c897dc965ed97a1d19ef7831f01.zip
Auto merge of #146232 - bjorn3:lto_allocator_shim, r=lqd
Make the allocator shim participate in LTO again

This is likely the cause of the perf regression in https://github.com/rust-lang/rust/pull/145955. It also caused some functional regressions.

Fixes https://github.com/rust-lang/rust/issues/146235
Fixes https://github.com/rust-lang/rust/issues/146239
Diffstat (limited to 'tests')
-rw-r--r--tests/ui/lto/lto-global-allocator.rs19
1 files changed, 19 insertions, 0 deletions
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;