From 2aa739f339c686af22bd5c1c6da4fe8669bf8420 Mon Sep 17 00:00:00 2001 From: Lukasz Anforowicz Date: Wed, 13 Dec 2023 01:13:58 +0000 Subject: [PATCH] Only run the new default-hidden-visibility test on x86_64/linux. --- config.example.toml | 2 +- tests/codegen/default-hidden-visibility.rs | 42 +++++++++------------- 2 files changed, 18 insertions(+), 26 deletions(-) diff --git a/config.example.toml b/config.example.toml index 14e0b9d521fde..665f1fa0ef846 100644 --- a/config.example.toml +++ b/config.example.toml @@ -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. diff --git a/tests/codegen/default-hidden-visibility.rs b/tests/codegen/default-hidden-visibility.rs index f57f3990fe181..d7becbb56e925 100644 --- a/tests/codegen/default-hidden-visibility.rs +++ b/tests/codegen/default-hidden-visibility.rs @@ -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. @@ -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