Skip to content

Commit

Permalink
Only run the new default-hidden-visibility test on x86_64/linux.
Browse files Browse the repository at this point in the history
  • Loading branch information
anforowicz committed Dec 13, 2023
1 parent c181b37 commit 2aa739f
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 26 deletions.
2 changes: 1 addition & 1 deletion config.example.toml
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ change-id = 118703
# Defaults to `host`. If you set this explicitly, you likely want to add all
# host triples to this list as well in order for those host toolchains to be
# able to compile programs for their native target.
#target = build.host (list of triples)
target = ["x86_64-unknown-linux-gnu", "x86_64-pc-windows-msvc", "i686-unknown-linux-gnu", "i686-pc-windows-msvc"]

# Use this directory to store build artifacts. Paths are relative to the current directory, not to
# the root of the repository.
Expand Down
42 changes: 17 additions & 25 deletions tests/codegen/default-hidden-visibility.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,30 +3,9 @@
// also https://github.com/rust-lang/rust/issues/73295 and
// https://github.com/rust-lang/rust/issues/37530.

// We test 3 combinations of command-line flags:
// * No extra command-line flag: DEFAULT
// * Overriding to "yes": YES
// * Overriding to "no": NO
//
// revisions:DEFAULT YES NO
// [YES] compile-flags: -Zdefault-hidden-visibility=yes
// [NO] compile-flags: -Zdefault-hidden-visibility=no

// `compiler/rustc_target/src/spec/base/wasm.rs` has a different default value of
// `default_hidden_visibility` - it wouldn't match the test expectations below.
// And therefore we skip this test on WASM:
//
// ignore-wasm32

// We verify that using the command line marks the `exported_symbol` as `hidden`
// and that it is not `hidden` otherwise. We don't verify other attributes of
// the symbol, because they vary depending on the target (e.g. in the `DEFAULT`
// behavior on `i686-unknown-linux-musl` the symbol is `internal constant` while
// on `x86_64-unknown-linux-gnu` it is just `constant`).
//
// DEFAULT-NOT: @{{.*}}default_hidden_visibility{{.*}}exported_symbol{{.*}} ={{.*}} hidden
// NO-NOT: @{{.*}}default_hidden_visibility{{.*}}exported_symbol{{.*}} ={{.*}} hidden
// YES: @{{.*}}default_hidden_visibility{{.*}}exported_symbol{{.*}} ={{.*}} hidden
// 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.
Expand All @@ -37,4 +16,17 @@
// the symbol should be exported; we don't want that - we want to test the *default*
// export setting instead).
#[used]
pub static exported_symbol: [u8; 6] = *b"foobar";
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
// only-linux

// DEFAULT: @{{.*}}default_hidden_visibility{{.*}}tested_symbol{{.*}} = constant
// YES: @{{.*}}default_hidden_visibility{{.*}}tested_symbol{{.*}} = hidden constant
// NO: @{{.*}}default_hidden_visibility{{.*}}tested_symbol{{.*}} = constant

0 comments on commit 2aa739f

Please sign in to comment.