Skip to content

Commit 2287774

Browse files
Auto merge of #143126 - dianqk:update-llvm, r=<try>
Add a regression test for ld64 We might want a test case. r? ghost try-job: x86_64-apple* try-job: aarch64-apple
2 parents d41e12f + 0a22d2d commit 2287774

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

tests/ui/darwin-ld64.rs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
//@ compile-flags: -Copt-level=3 -Ccodegen-units=256 -Clink-arg=-ld_classic --target x86_64-apple-darwin
2+
//@ run-pass
3+
//@ only-macos
4+
5+
// This is a regression test for https://github.com/rust-lang/rust/issues/140686.
6+
// Although this is a ld64(ld-classic) bug, we still need to support it
7+
// due to cross-compilation and support for older Xcode.
8+
9+
fn main() {
10+
let dst: Vec<u8> = Vec::new();
11+
let len = broken_func(2, dst);
12+
assert_eq!(len, 8);
13+
}
14+
15+
#[inline(never)]
16+
pub fn broken_func(version: usize, mut dst: Vec<u8>) -> usize {
17+
match version {
18+
1 => dst.extend_from_slice(b"aaaaaaaa"),
19+
2 => dst.extend_from_slice(b"bbbbbbbb"),
20+
3 => dst.extend_from_slice(b"bbbbbbbb"),
21+
_ => panic!(),
22+
}
23+
dst.len()
24+
}

0 commit comments

Comments
 (0)