diff options
| author | bors <bors@rust-lang.org> | 2023-12-14 09:16:15 +0000 | 
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2023-12-14 09:16:15 +0000 | 
| commit | 9d49eb76c47a139ef71da4ab56aa9aeca5f24913 (patch) | |
| tree | e3b338c0d0a863ffe99b05e38897ddbd66c8f925 /tests/codegen/default-hidden-visibility.rs | |
| parent | 1a8afa0e748008708950e1a9ff62c598e2cfb3ea (diff) | |
| parent | 981c4e3ce6f3d89f681fbb0de753d03425c6a209 (diff) | |
| download | rust-9d49eb76c47a139ef71da4ab56aa9aeca5f24913.tar.gz rust-9d49eb76c47a139ef71da4ab56aa9aeca5f24913.zip  | |
Auto merge of #118417 - anforowicz:default-hidden-visibility, r=TaKO8Ki
Add unstable `-Zdefault-hidden-visibility` cmdline flag for `rustc`. The new flag has been described in the Major Change Proposal at https://github.com/rust-lang/compiler-team/issues/656
Diffstat (limited to 'tests/codegen/default-hidden-visibility.rs')
| -rw-r--r-- | tests/codegen/default-hidden-visibility.rs | 31 | 
1 files changed, 31 insertions, 0 deletions
diff --git a/tests/codegen/default-hidden-visibility.rs b/tests/codegen/default-hidden-visibility.rs new file mode 100644 index 00000000000..9e5e545f0d9 --- /dev/null +++ b/tests/codegen/default-hidden-visibility.rs @@ -0,0 +1,31 @@ +// Verifies that `Session::default_hidden_visibility` is affected when using the related cmdline +// flag. This is a regression test for https://github.com/rust-lang/compiler-team/issues/656. See +// also https://github.com/rust-lang/rust/issues/73295 and +// https://github.com/rust-lang/rust/issues/37530. + +// revisions:DEFAULT YES NO +//[YES] compile-flags: -Zdefault-hidden-visibility=yes +//[NO] compile-flags: -Zdefault-hidden-visibility=no + +// The test scenario is specifically about visibility of symbols exported out of dynamically linked +// libraries. +#![crate_type = "dylib"] + +// The test scenario needs to use a Rust-public, but non-explicitly-exported symbol +// (e.g. the test doesn't use `#[no_mangle]`, because currently it implies that +// the symbol should be exported; we don't want that - we want to test the *default* +// export setting instead). +#[used] +pub static tested_symbol: [u8; 6] = *b"foobar"; + +// Exact LLVM IR differs depending on the target triple (e.g. `hidden constant` +// vs `internal constant` vs `constant`). Because of this, we only apply the +// specific test expectations below to one specific target triple. If needed, +// additional targets can be covered by adding copies of this test file with +// a different `only-X` directive. +// +// only-x86_64-unknown-linux-gnu + +// DEFAULT: @{{.*}}default_hidden_visibility{{.*}}tested_symbol{{.*}} = constant +// YES: @{{.*}}default_hidden_visibility{{.*}}tested_symbol{{.*}} = hidden constant +// NO: @{{.*}}default_hidden_visibility{{.*}}tested_symbol{{.*}} = constant  | 
