|
| 1 | +// Verifies that `Session::default_hidden_visibility` is affected when using the related cmdline |
| 2 | +// flag. This is a regression test for https://github.com/rust-lang/compiler-team/issues/656. See |
| 3 | +// also https://github.com/rust-lang/rust/issues/73295 and |
| 4 | +// https://github.com/rust-lang/rust/issues/37530. |
| 5 | + |
| 6 | +// We test 3 combinations of command-line flags: |
| 7 | +// * No extra command-line flag: DEFAULT |
| 8 | +// * Overriding to "yes": YES |
| 9 | +// * Overriding to "no": NO |
| 10 | +// |
| 11 | +// revisions:DEFAULT YES NO |
| 12 | +// [YES] compile-flags: -Zdefault-hidden-visibility=yes |
| 13 | +// [NO] compile-flags: -Zdefault-hidden-visibility=no |
| 14 | + |
| 15 | +// `compiler/rustc_target/src/spec/base/wasm.rs` has a different default value of |
| 16 | +// `default_hidden_visibility` - it wouldn't match the test expectations below. |
| 17 | +// And therefore we skip this test on WASM: |
| 18 | +// |
| 19 | +// ignore-wasm32 |
| 20 | + |
| 21 | +// We verify that using the command line marks the `exported_symbol` as `hidden` |
| 22 | +// and that it is not `hidden` otherwise. We don't verify other attributes of |
| 23 | +// the symbol, because they vary depending on the target (e.g. in the `DEFAULT` |
| 24 | +// behavior on `i686-unknown-linux-musl` the symbol is `internal constant` while |
| 25 | +// on `x86_64-unknown-linux-gnu` it is just `constant`). |
| 26 | +// |
| 27 | +// DEFAULT-NOT: @{{.*}}default_hidden_visibility{{.*}}exported_symbol{{.*}} ={{.*}} hidden |
| 28 | +// NO-NOT: @{{.*}}default_hidden_visibility{{.*}}exported_symbol{{.*}} ={{.*}} hidden |
| 29 | +// YES: @{{.*}}default_hidden_visibility{{.*}}exported_symbol{{.*}} ={{.*}} hidden |
| 30 | + |
| 31 | +// The test scenario is specifically about visibility of symbols exported out of dynamically linked |
| 32 | +// libraries. |
| 33 | +#![crate_type = "dylib"] |
| 34 | + |
| 35 | +// The test scenario needs to use a Rust-public, but non-explicitly-exported symbol |
| 36 | +// (e.g. the test doesn't use `#[no_mangle]`, because currently it implies that |
| 37 | +// the symbol should be exported; we don't want that - we want to test the *default* |
| 38 | +// export setting instead). |
| 39 | +#[used] |
| 40 | +pub static exported_symbol: [u8; 6] = *b"foobar"; |
0 commit comments