Skip to content

Commit 44dba79

Browse files
committed
Add regression test for linking issue with start-group / end-group
1 parent 3ab5965 commit 44dba79

File tree

4 files changed

+76
-0
lines changed

4 files changed

+76
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
-include ../tools.mk
2+
3+
# Test that previously triggered a linker failure with root cause
4+
# similar to one found in the issue #69368.
5+
#
6+
# The crate that provides oom lang item is missing some other lang
7+
# items. Necessary to prevent the use of start-group / end-group.
8+
#
9+
# The weak lang items are defined in a separate compilation units,
10+
# so that linker could omit them if not used.
11+
#
12+
# The crates that need those weak lang items are dependencies of
13+
# crates that provide them.
14+
15+
all:
16+
$(RUSTC) a.rs
17+
$(RUSTC) b.rs
18+
$(RUSTC) c.rs
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#![crate_type = "rlib"]
2+
#![feature(lang_items)]
3+
#![feature(panic_unwind)]
4+
#![no_std]
5+
6+
extern crate panic_unwind;
7+
8+
#[panic_handler]
9+
pub fn panic_handler(_: &core::panic::PanicInfo) -> ! {
10+
loop {}
11+
}
12+
13+
#[no_mangle]
14+
extern "C" fn __rust_drop_panic() -> ! {
15+
loop {}
16+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#![crate_type = "rlib"]
2+
#![feature(alloc_error_handler)]
3+
#![no_std]
4+
5+
#[alloc_error_handler]
6+
pub fn error_handler(_: core::alloc::Layout) -> ! {
7+
panic!();
8+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#![crate_type = "bin"]
2+
#![feature(start)]
3+
#![no_std]
4+
5+
extern crate alloc;
6+
extern crate a;
7+
extern crate b;
8+
9+
use alloc::vec::Vec;
10+
use core::alloc::*;
11+
12+
struct Allocator;
13+
14+
unsafe impl GlobalAlloc for Allocator {
15+
unsafe fn alloc(&self, _: Layout) -> *mut u8 {
16+
loop {}
17+
}
18+
19+
unsafe fn dealloc(&self, _: *mut u8, _: Layout) {
20+
loop {}
21+
}
22+
}
23+
24+
#[global_allocator]
25+
static ALLOCATOR: Allocator = Allocator;
26+
27+
#[start]
28+
fn main(argc: isize, _argv: *const *const u8) -> isize {
29+
let mut v = Vec::new();
30+
for i in 0..argc {
31+
v.push(i);
32+
}
33+
v.iter().sum()
34+
}

0 commit comments

Comments
 (0)