diff options
| author | Matthias Krüger <matthias.krueger@famsik.de> | 2024-10-11 15:36:52 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-10-11 15:36:52 +0200 |
| commit | 33b1264540bade1e9122cfff7c95a7a9e20f5529 (patch) | |
| tree | 45a8fa01a5b35e43751f32ced3548b6b95be66a3 /tests/codegen | |
| parent | 103c71686aaa1f1edb92905a8f6dff701dddd70a (diff) | |
| parent | 42c0494499b3ee271bafa68bbfe5eb5176442c4d (diff) | |
| download | rust-33b1264540bade1e9122cfff7c95a7a9e20f5529.tar.gz rust-33b1264540bade1e9122cfff7c95a7a9e20f5529.zip | |
Rollup merge of #131519 - davidlattimore:intrinsics-default-vis, r=Urgau
Use Default visibility for rustc-generated C symbol declarations Non-default visibilities should only be used for definitions, not declarations, otherwise linking can fail. This is based on https://github.com/rust-lang/rust/pull/123994. Issue https://github.com/rust-lang/rust/issues/123427 When I changed `default-hidden-visibility` to `default-visibility` in https://github.com/rust-lang/rust/pull/130005, I updated all places in the code that used `default-hidden-visibility`, replicating the hidden-visibility bug to also happen for protected visibility. Without this change, trying to build rustc with `-Z default-visibility=protected` fails with a link error.
Diffstat (limited to 'tests/codegen')
| -rw-r--r-- | tests/codegen/default-visibility.rs | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/tests/codegen/default-visibility.rs b/tests/codegen/default-visibility.rs index 884d386ec20..88ff9fee254 100644 --- a/tests/codegen/default-visibility.rs +++ b/tests/codegen/default-visibility.rs @@ -31,3 +31,19 @@ pub static tested_symbol: [u8; 6] = *b"foobar"; // PROTECTED: @{{.*}}default_visibility{{.*}}tested_symbol{{.*}} = protected constant // INTERPOSABLE: @{{.*}}default_visibility{{.*}}tested_symbol{{.*}} = constant // DEFAULT: @{{.*}}default_visibility{{.*}}tested_symbol{{.*}} = constant + +pub fn do_memcmp(left: &[u8], right: &[u8]) -> i32 { + left.cmp(right) as i32 +} + +// CHECK: define {{.*}} @{{.*}}do_memcmp{{.*}} { +// CHECK: } + +// `do_memcmp` should invoke core::intrinsic::compare_bytes which emits a call +// to the C symbol `memcmp` (at least on x86_64-unknown-linux-gnu). This symbol +// should *not* be declared hidden or protected. + +// HIDDEN: declare i32 @memcmp +// PROTECTED: declare i32 @memcmp +// INTERPOSABLE: declare i32 @memcmp +// DEFAULT: declare i32 @memcmp |
