Skip to content

Commit eec2e8e

Browse files
committed
Tests to repro -Zdefault-hidden-visibility bug
1 parent ceab612 commit eec2e8e

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

tests/codegen/default-hidden-visibility.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,3 +29,18 @@ pub static tested_symbol: [u8; 6] = *b"foobar";
2929
// DEFAULT: @{{.*}}default_hidden_visibility{{.*}}tested_symbol{{.*}} = constant
3030
// YES: @{{.*}}default_hidden_visibility{{.*}}tested_symbol{{.*}} = hidden constant
3131
// NO: @{{.*}}default_hidden_visibility{{.*}}tested_symbol{{.*}} = constant
32+
33+
pub fn do_memcmp(left: &[u8], right: &[u8]) -> i32 {
34+
left.cmp(right) as i32
35+
}
36+
37+
// CHECK: define {{.*}} @{{.*}}do_memcmp{{.*}} {
38+
// CHECK: }
39+
40+
// `do_memcmp` should invoke core::intrinsic::compare_bytes which emits a call
41+
// to the C symbol `memcmp` (at least on x86_64-unknown-linux-gnu). This symbol
42+
// should *not* be `declare hidden`.
43+
44+
// DEFAULT: declare i32 @memcmp
45+
// YES: declare i32 @memcmp
46+
// NO: declare i32 @memcmp
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
//@ build-pass
2+
//@ compile-flags: -Zdefault-hidden-visibility=yes
3+
4+
#![crate_type = "dylib"]
5+
6+
pub fn do_memcmp(left: &[u8], right: &[u8]) -> i32 {
7+
left.cmp(right) as i32
8+
}

0 commit comments

Comments
 (0)