Skip to content

Commit 1ec0d13

Browse files
committed
Auto merge of rust-lang#134463 - jieyouxu:filecheck-prefix, r=<try>
compiletest: don't register predefined `MSVC`/`NONMSVC` FileCheck prefixes This was fragile as it was based on host target passed to compiletest, but the user could cross-compile and run test for a different target (e.g. cross from linux to msvc, but msvc won't be set on the target). Furthermore, it was also very surprising as normally revision names (other than `CHECK`) was accepted as FileCheck prefixes. This partially reverts the `MSVC`/`NONMSVC` predefined FileCheck prefix registration introduced in rust-lang#120656 for some codegen tests. This makes some codegen tests more verbose since they now need to explicitly introduce `MSVC`/`NONMSVC` revisions, but I think that's less surprising, e.g.: ```rs //@ revisions: MSVC NONMSVC //`@[MSVC]` only-msvc //`@[NONMSVC]` ignore-msvc ``` Note that revisions are not *only* FileCheck prefixes in FileCheck-based test suites, as they also can be used to conditionally apply certain compiletest directives. r? `@Zalathar` (or reroll a `r/? compiletest` reviewer) try-job: x86_64-msvc try-job: i686-msvc try-job: x86_64-mingw-1 try-job: i686-mingw
2 parents 3378a5e + 2b41c9d commit 1ec0d13

13 files changed

+79
-67
lines changed

src/tools/compiletest/src/runtest.rs

+3-10
Original file line numberDiff line numberDiff line change
@@ -1958,23 +1958,16 @@ impl<'test> TestCx<'test> {
19581958
let mut filecheck = Command::new(self.config.llvm_filecheck.as_ref().unwrap());
19591959
filecheck.arg("--input-file").arg(output).arg(&self.testpaths.file);
19601960

1961-
// FIXME: Consider making some of these prefix flags opt-in per test,
1962-
// via `filecheck-flags` or by adding new header directives.
1963-
19641961
// Because we use custom prefixes, we also have to register the default prefix.
19651962
filecheck.arg("--check-prefix=CHECK");
19661963

1967-
// Some tests use the current revision name as a check prefix.
1964+
// Tests are allowed to use a revision name as a check prefix.
19681965
if let Some(rev) = self.revision {
19691966
filecheck.arg("--check-prefix").arg(rev);
19701967
}
19711968

1972-
// Some tests also expect either the MSVC or NONMSVC prefix to be defined.
1973-
let msvc_or_not = if self.config.target.contains("msvc") { "MSVC" } else { "NONMSVC" };
1974-
filecheck.arg("--check-prefix").arg(msvc_or_not);
1975-
1976-
// The filecheck tool normally fails if a prefix is defined but not used.
1977-
// However, we define several prefixes globally for all tests.
1969+
// The filecheck tool normally fails if a prefix is defined but not used. However, sometimes
1970+
// revisions are used to specify *compiletest* directives which are not FileCheck concerns.
19781971
filecheck.arg("--allow-unused-prefixes");
19791972

19801973
// Provide more context on failures.

tests/codegen/async-fn-debug-awaitee-field.rs

+8-4
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
1-
// This test makes sure that the coroutine field capturing the awaitee in a `.await` expression
2-
// is called "__awaitee" in debuginfo. This name must not be changed since debuggers and debugger
3-
// extensions rely on the field having this name.
4-
51
// ignore-tidy-linelength
2+
//! This test makes sure that the coroutine field capturing the awaitee in a `.await` expression
3+
//! is called `__awaitee` in debuginfo. This name must not be changed since debuggers and debugger
4+
//! extensions rely on the field having this name.
5+
6+
//@ revisions: MSVC NONMSVC
7+
//@[MSVC] only-msvc
8+
//@[NONMSVC] ignore-msvc
9+
610
//@ compile-flags: -C debuginfo=2 --edition=2018 -Copt-level=0
711

812
#![crate_type = "lib"]

tests/codegen/debug-accessibility/crate-enum.rs

+5-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
1-
//@ compile-flags: -C debuginfo=2
21
// ignore-tidy-linelength
2+
//! Checks that visibility information is present in the debuginfo for crate-visibility enums.
33
4-
#![allow(dead_code)]
4+
//@ revisions: MSVC NONMSVC
5+
//@[MSVC] only-msvc
6+
//@[NONMSVC] ignore-msvc
57

6-
// Checks that visibility information is present in the debuginfo for crate-visibility enums.
8+
//@ compile-flags: -C debuginfo=2
79

810
mod module {
911
use std::hint::black_box;

tests/codegen/debug-accessibility/private-enum.rs

+5-4
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1-
//@ compile-flags: -C debuginfo=2
21
// ignore-tidy-linelength
2+
//! Checks that visibility information is present in the debuginfo for private enums.
33
4-
#![allow(dead_code)]
5-
6-
// Checks that visibility information is present in the debuginfo for private enums.
4+
//@ revisions: MSVC NONMSVC
5+
//@[MSVC] only-msvc
6+
//@[NONMSVC] ignore-msvc
7+
//@ compile-flags: -C debuginfo=2
78

89
use std::hint::black_box;
910

tests/codegen/debug-accessibility/public-enum.rs

+5-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
1-
//@ compile-flags: -C debuginfo=2
21
// ignore-tidy-linelength
2+
//! Checks that visibility information is present in the debuginfo for types and their fields.
33
4-
#![allow(dead_code)]
4+
//@ revisions: MSVC NONMSVC
5+
//@[MSVC] only-msvc
6+
//@[NONMSVC] ignore-msvc
57

6-
// Checks that visibility information is present in the debuginfo for types and their fields.
8+
//@ compile-flags: -C debuginfo=2
79

810
use std::hint::black_box;
911

tests/codegen/debug-accessibility/super-enum.rs

+5-4
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1-
//@ compile-flags: -C debuginfo=2
21
// ignore-tidy-linelength
2+
//! Checks that visibility information is present in the debuginfo for super-visibility enums.
33
4-
#![allow(dead_code)]
5-
6-
// Checks that visibility information is present in the debuginfo for super-visibility enums.
4+
//@ revisions: MSVC NONMSVC
5+
//@[MSVC] only-msvc
6+
//@[NONMSVC] ignore-msvc
7+
//@ compile-flags: -C debuginfo=2
78

89
mod module {
910
use std::hint::black_box;

tests/codegen/debug-vtable.rs

+7-3
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,17 @@
1-
// This test checks the debuginfo for the expected 3 vtables is generated for correct names and number
2-
// of entries.
1+
// ignore-tidy-linelength
2+
//! This test checks the debuginfo for the expected 3 vtables is generated for correct names and
3+
//! number of entries.
4+
5+
//@ revisions: MSVC NONMSVC
6+
//@[MSVC] only-msvc
7+
//@[NONMSVC] ignore-msvc
38

49
// Use the v0 symbol mangling scheme to codegen order independent of rustc version.
510
// Unnamed items like shims are generated in lexicographical order of their symbol name and in the
611
// legacy mangling scheme rustc version and generic parameters are both hashed into a single part
712
// of the name, thus randomizing item order with respect to rustc version.
813

914
//@ compile-flags: -Cdebuginfo=2 -Copt-level=0 -Csymbol-mangling-version=v0
10-
// ignore-tidy-linelength
1115

1216
// Make sure that vtables don't have the unnamed_addr attribute when debuginfo is enabled.
1317
// This helps debuggers more reliably map from dyn pointer to concrete type.

tests/codegen/debuginfo-generic-closure-env-names.rs

+13-10
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,17 @@
1-
// This test checks that we get proper type names for closure environments and
2-
// async-fn environments in debuginfo, especially making sure that generic arguments
3-
// of the enclosing functions don't get lost.
4-
//
5-
// Unfortunately, the order that debuginfo gets emitted into LLVM IR becomes a bit hard
6-
// to predict once async fns are involved, so DAG allows any order.
7-
//
8-
// Note that the test does not check async-fns when targeting MSVC because debuginfo for
9-
// those does not follow the enum-fallback encoding yet and thus is incomplete.
10-
111
// ignore-tidy-linelength
2+
//! This test checks that we get proper type names for closure environments and
3+
//! async-fn environments in debuginfo, especially making sure that generic arguments
4+
//! of the enclosing functions don't get lost.
5+
//!
6+
//! Unfortunately, the order that debuginfo gets emitted into LLVM IR becomes a bit hard
7+
//! to predict once async fns are involved, so DAG allows any order.
8+
//!
9+
//! Note that the test does not check async-fns when targeting MSVC because debuginfo for
10+
//! those does not follow the enum-fallback encoding yet and thus is incomplete.
11+
12+
//@ revisions: MSVC NONMSVC
13+
//@[MSVC] only-msvc
14+
//@[NONMSVC] ignore-msvc
1215

1316
// Use the v0 symbol mangling scheme to codegen order independent of rustc version.
1417
// Unnamed items like shims are generated in lexicographical order of their symbol name and in the

tests/codegen/issues/issue-98678-async.rs

+7-5
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
1-
// This test verifies the accuracy of emitted file and line debuginfo metadata for async blocks and
2-
// async functions.
3-
//
1+
// ignore-tidy-linelength
2+
//! This test verifies the accuracy of emitted file and line debuginfo metadata for async blocks and
3+
//! async functions.
4+
5+
//@ revisions: MSVC NONMSVC
6+
//@[MSVC] only-msvc
7+
//@[NONMSVC] ignore-msvc
48
//@ edition:2021
59
//@ compile-flags: --crate-type=lib -Copt-level=0 -Cdebuginfo=2 -Zdebug-info-type-line-numbers=true
610

7-
// ignore-tidy-linelength
8-
911
// NONMSVC-DAG: ![[#FILE:]] = !DIFile({{.*}}filename:{{.*[/\\]}}issue-98678-async.rs{{".*}})
1012
// MSVC: ![[#FILE:]] = !DIFile({{.*}}filename:{{.*}}\\issue-98678-async.rs{{".*}})
1113

tests/codegen/issues/issue-98678-closure-coroutine.rs

+8-5
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
1-
// This test verifies the accuracy of emitted file and line debuginfo metadata for closures and
2-
// coroutines.
3-
//
4-
//@ compile-flags: --crate-type=lib -Copt-level=0 -Cdebuginfo=2 -Zdebug-info-type-line-numbers=true
1+
// ignore-tidy-linelength
2+
//! This test verifies the accuracy of emitted file and line debuginfo metadata for closures and
3+
//! coroutines.
4+
55
#![feature(coroutines, stmt_expr_attributes)]
66

7-
// ignore-tidy-linelength
7+
//@ revisions: MSVC NONMSVC
8+
//@[MSVC] only-msvc
9+
//@[NONMSVC] ignore-msvc
10+
//@ compile-flags: --crate-type=lib -Copt-level=0 -Cdebuginfo=2 -Zdebug-info-type-line-numbers=true
811

912
// NONMSVC-DAG: ![[#FILE:]] = !DIFile({{.*}}filename:{{.*[/\\]}}issue-98678-closure-coroutine.rs{{".*}})
1013
// MSVC-DAG: ![[#FILE:]] = !DIFile({{.*}}filename:{{.*}}\\issue-98678-closure-coroutine.rs{{".*}})

tests/codegen/issues/issue-98678-enum.rs

+6-4
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1-
// This test verifies the accuracy of emitted file and line debuginfo metadata enums.
2-
//
3-
//@ compile-flags: --crate-type=lib -Copt-level=0 -Cdebuginfo=2 -Zdebug-info-type-line-numbers=true
4-
51
// ignore-tidy-linelength
2+
//! This test verifies the accuracy of emitted file and line debuginfo metadata enums.
3+
4+
//@ revisions: MSVC NONMSVC
5+
//@[MSVC] only-msvc
6+
//@[NONMSVC] ignore-msvc
7+
//@ compile-flags: --crate-type=lib -Copt-level=0 -Cdebuginfo=2 -Zdebug-info-type-line-numbers=true
68

79
// NONMSVC: ![[#FILE:]] = !DIFile({{.*}}filename:{{.*[/\\]}}issue-98678-enum.rs{{".*}})
810
// MSVC: ![[#FILE:]] = !DIFile({{.*}}filename:{{.*}}\\issue-98678-enum.rs{{".*}})

tests/codegen/issues/issue-98678-struct-union.rs

+7-5
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
1-
// This test verifies the accuracy of emitted file and line debuginfo metadata for structs and
2-
// unions.
3-
//
4-
//@ compile-flags: --crate-type=lib -Copt-level=0 -Cdebuginfo=2 -Zdebug-info-type-line-numbers=true
5-
61
// ignore-tidy-linelength
2+
//! This test verifies the accuracy of emitted file and line debuginfo metadata for structs and
3+
//! unions.
4+
5+
//@ revisions: MSVC NONMSVC
6+
//@[MSVC] only-msvc
7+
//@[NONMSVC] ignore-msvc
8+
//@ compile-flags: --crate-type=lib -Copt-level=0 -Cdebuginfo=2 -Zdebug-info-type-line-numbers=true
79

810
// NONMSVC: ![[#FILE:]] = !DIFile({{.*}}filename:{{.*[/\\]}}issue-98678-struct-union.rs{{".*}})
911
// MSVC: ![[#FILE:]] = !DIFile({{.*}}filename:{{.*}}\\issue-98678-struct-union.rs{{".*}})

tests/codegen/meta-filecheck/msvc-prefix-good.rs

-7
This file was deleted.

0 commit comments

Comments
 (0)