Skip to content

Commit 2fc68db

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 + 06d92f9 commit 2fc68db

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

tests/ui/darwin-ld64.rs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
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+
//@ needs-llvm-components: x86
5+
6+
// This is a regression test for https://github.com/rust-lang/rust/issues/140686.
7+
// Although this is a ld64(ld-classic) bug, we still need to support it
8+
// due to cross-compilation and support for older Xcode.
9+
10+
fn main() {
11+
let dst: Vec<u8> = Vec::new();
12+
let len = broken_func(2, dst);
13+
assert_eq!(len, 8);
14+
}
15+
16+
#[inline(never)]
17+
pub fn broken_func(version: usize, mut dst: Vec<u8>) -> usize {
18+
match version {
19+
1 => dst.extend_from_slice(b"aaaaaaaa"),
20+
2 => dst.extend_from_slice(b"bbbbbbbb"),
21+
3 => dst.extend_from_slice(b"bbbbbbbb"),
22+
_ => panic!(),
23+
}
24+
dst.len()
25+
}

0 commit comments

Comments
 (0)