https://github.com/simpal01 created https://github.com/llvm/llvm-project/pull/181805
Test failures started after https://github.com/llvm/llvm-project/pull/178077 which introduced Darwin-specific system checks in several tests, including checks for the presence of SDKSettings.json. These tests are intended to validate features in Clang’s driver that require Clang to target a Darwin platform while running on a Darwin host. Currently, their execution is gated by the REQUIRES: system-darwin annotation. This approach breaks down when running the tests on a cross-compiling build of Clang on a Darwin host. If the build does not include any Darwin targets, the tests will still run (because the host is Darwin) but will fail spuriously due to the absence of a Darwin target in the build. This patch updates the affected tests by adding an additional constraint to their REQUIRES annotation: target={{.*}}-(darwin|macos){{.*}}. This ensures the tests only run when the build actually includes a Darwin target. >From 73b1cf1292754f747226d4965b3df7d2d2173ad2 Mon Sep 17 00:00:00 2001 From: Simi Pallipurath <[email protected]> Date: Tue, 17 Feb 2026 11:28:07 +0000 Subject: [PATCH] [clang][tests] Fix cross-build test failures on Darwin. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Test failures started after https://github.com/llvm/llvm-project/pull/178077 which introduced Darwin-specific system checks in several tests, including checks for the presence of SDKSettings.json. These tests are intended to validate features in Clang’s driver that require Clang to target a Darwin platform while running on a Darwin host. Currently, their execution is gated by the REQUIRES: system-darwin annotation. This approach breaks down when running the tests on a cross-compiling build of Clang on a Darwin host. If the build does not include any Darwin targets, the tests will still run (because the host is Darwin) but will fail spuriously due to the absence of a Darwin target in the build. This patch updates the affected tests by adding an additional constraint to their REQUIRES annotation: target={{.*}}-(darwin|macos){{.*}}. This ensures the tests only run when the build actually includes a Darwin target. --- clang/test/ClangScanDeps/P1689.cppm | 2 +- clang/test/ClangScanDeps/header_stat_before_open.m | 2 +- clang/test/ClangScanDeps/headerwithdirname.cpp | 2 +- .../headerwithdirnamefollowedbyinclude.cpp | 2 +- clang/test/ClangScanDeps/macro-expansions.cpp | 2 +- clang/test/ClangScanDeps/modules.cpp | 10 +++++----- clang/test/ClangScanDeps/regular_cdb.cpp | 12 ++++++------ clang/test/ClangScanDeps/relative_directory.cpp | 6 +++--- .../ClangScanDeps/subframework_header_dir_symlink.m | 2 +- clang/test/ClangScanDeps/target-filename.cpp | 2 +- clang/test/ClangScanDeps/vfsoverlay.cpp | 4 ++-- clang/test/Frontend/dependency-gen-phony.c | 4 ++-- 12 files changed, 25 insertions(+), 25 deletions(-) diff --git a/clang/test/ClangScanDeps/P1689.cppm b/clang/test/ClangScanDeps/P1689.cppm index c3ab80d4b19f6..a1e2215b2c591 100644 --- a/clang/test/ClangScanDeps/P1689.cppm +++ b/clang/test/ClangScanDeps/P1689.cppm @@ -59,7 +59,7 @@ // RUN: -MT impl_part.o.ddi -MD -MF impl_part.dep // RUN: cat impl_part.dep \ // RUN: | sed 's:\\\\\?:/:g' \ -// RUN: | FileCheck impl_part.cppm -DPREFIX=%/t --check-prefix=%if system-darwin %{CHECK-MAKE-RELATIVE-DARWIN %} %else %{CHECK-MAKE-RELATIVE %} +// RUN: | FileCheck impl_part.cppm -DPREFIX=%/t --check-prefix=%if system-darwin && target={{.*}}-{{darwin|macos}}{{.*}} %{CHECK-MAKE-RELATIVE-DARWIN %} %else %{CHECK-MAKE-RELATIVE %} //--- P1689.json.in diff --git a/clang/test/ClangScanDeps/header_stat_before_open.m b/clang/test/ClangScanDeps/header_stat_before_open.m index 770d025824081..f7f9d437d7df5 100644 --- a/clang/test/ClangScanDeps/header_stat_before_open.m +++ b/clang/test/ClangScanDeps/header_stat_before_open.m @@ -8,7 +8,7 @@ // RUN: sed -e "s|DIR|%/t.dir|g" %S/Inputs/header_stat_before_open_cdb.json > %t.cdb // // RUN: clang-scan-deps -compilation-database %t.cdb -j 1 | \ -// RUN: FileCheck %s %if system-darwin %{ --check-prefixes=CHECK,CHECK-DARWIN %} +// RUN: FileCheck %s %if system-darwin && target={{.*}}-{{darwin|macos}}{{.*}} %{ --check-prefixes=CHECK,CHECK-DARWIN %} #include "Framework/Framework.h" #include "Framework/PrivateHeader.h" diff --git a/clang/test/ClangScanDeps/headerwithdirname.cpp b/clang/test/ClangScanDeps/headerwithdirname.cpp index 364274723107f..80ffe6c8eb3fa 100644 --- a/clang/test/ClangScanDeps/headerwithdirname.cpp +++ b/clang/test/ClangScanDeps/headerwithdirname.cpp @@ -9,7 +9,7 @@ // RUN: cp %S/Inputs/foodir %t.dir/Inputs/foodir // RUN: sed -e "s|DIR|%/t.dir|g" %S/Inputs/headerwithdirname.json > %t.cdb // -// RUN: clang-scan-deps -compilation-database %t.cdb -j 1 | FileCheck %s %if system-darwin %{ --check-prefixes=CHECK,CHECK-DARWIN %} +// RUN: clang-scan-deps -compilation-database %t.cdb -j 1 | FileCheck %s %if system-darwin && target={{.*}}-{{darwin|macos}}{{.*}} %{ --check-prefixes=CHECK,CHECK-DARWIN %} #include <foodir> diff --git a/clang/test/ClangScanDeps/headerwithdirnamefollowedbyinclude.cpp b/clang/test/ClangScanDeps/headerwithdirnamefollowedbyinclude.cpp index 149cc9beb0b27..33bf649336d0b 100644 --- a/clang/test/ClangScanDeps/headerwithdirnamefollowedbyinclude.cpp +++ b/clang/test/ClangScanDeps/headerwithdirnamefollowedbyinclude.cpp @@ -12,7 +12,7 @@ // RUN: cp %S/Inputs/foodir %t.dir/Inputs/foodir // RUN: sed -e "s|DIR|%/t.dir|g" %S/Inputs/headerwithdirnamefollowedbyinclude.json > %t.cdb // -// RUN: clang-scan-deps -compilation-database %t.cdb -j 1 | FileCheck %s %if system-darwin %{ --check-prefixes=CHECK,CHECK-DARWIN %} +// RUN: clang-scan-deps -compilation-database %t.cdb -j 1 | FileCheck %s %if system-darwin && target={{.*}}-{{darwin|macos}}{{.*}} %{ --check-prefixes=CHECK,CHECK-DARWIN %} #include <foodir> #include "foodir/foodirheader.h" diff --git a/clang/test/ClangScanDeps/macro-expansions.cpp b/clang/test/ClangScanDeps/macro-expansions.cpp index d99dc599ac9a4..4a1038993ffcd 100644 --- a/clang/test/ClangScanDeps/macro-expansions.cpp +++ b/clang/test/ClangScanDeps/macro-expansions.cpp @@ -5,7 +5,7 @@ // RUN: split-file %s %t // RUN: sed -e "s|DIR|%/t|g" %t/cdb.json.template > %t/cdb.json -// RUN: clang-scan-deps -compilation-database %t/cdb.json | FileCheck %s %if system-darwin %{ --check-prefixes=CHECK,CHECK-DARWIN %} +// RUN: clang-scan-deps -compilation-database %t/cdb.json | FileCheck %s %if system-darwin && target={{.*}}-{{darwin|macos}}{{.*}} %{ --check-prefixes=CHECK,CHECK-DARWIN %} // CHECK: test.o: // CHECK-DARWIN-NEXT: SDKSettings.json diff --git a/clang/test/ClangScanDeps/modules.cpp b/clang/test/ClangScanDeps/modules.cpp index eb486cf996997..3f259dd8ad17d 100644 --- a/clang/test/ClangScanDeps/modules.cpp +++ b/clang/test/ClangScanDeps/modules.cpp @@ -14,7 +14,7 @@ // RUN: sed -e "s|DIR|%/t.dir|g" %S/Inputs/modules_cdb_clangcl.json > %t_clangcl.cdb // // RUN: clang-scan-deps -compilation-database %t.cdb -j 1 -mode preprocess-dependency-directives | \ -// RUN: FileCheck --check-prefixes=CHECK1,CHECK2,CHECK2NO%if system-darwin %{,CHECK1-DARWIN,CHECK2-DARWIN %} %else %{,CHECK2-NON-DARWIN %} %s +// RUN: FileCheck --check-prefixes=CHECK1,CHECK2,CHECK2NO%if system-darwin && target={{.*}}-{{darwin|macos}}{{.*}} %{,CHECK1-DARWIN,CHECK2-DARWIN %} %else %{,CHECK2-NON-DARWIN %} %s // RUN: clang-scan-deps -compilation-database %t_clangcl.cdb -j 1 -mode preprocess-dependency-directives | \ // RUN: FileCheck --check-prefixes=CHECK1,CHECK2,CHECK2NO,CHECK2-NON-DARWIN %s // @@ -24,19 +24,19 @@ // `modules_cdb_input2.cpp`. // // RUN: clang-scan-deps -compilation-database %t.cdb -j 2 -mode preprocess-dependency-directives | \ -// RUN: FileCheck --check-prefixes=CHECK1%if system-darwin %{,CHECK1-DARWIN %} %s +// RUN: FileCheck --check-prefixes=CHECK1%if system-darwin && target={{.*}}-{{darwin|macos}}{{.*}} %{,CHECK1-DARWIN %} %s // RUN: clang-scan-deps -compilation-database %t_clangcl.cdb -j 2 -mode preprocess-dependency-directives | \ // RUN: FileCheck --check-prefix=CHECK1 %s // RUN: clang-scan-deps -compilation-database %t.cdb -j 2 -mode preprocess | \ -// RUN: FileCheck --check-prefixes=CHECK1%if system-darwin %{,CHECK1-DARWIN %} %s +// RUN: FileCheck --check-prefixes=CHECK1%if system-darwin && target={{.*}}-{{darwin|macos}}{{.*}} %{,CHECK1-DARWIN %} %s // RUN: clang-scan-deps -compilation-database %t_clangcl.cdb -j 2 -mode preprocess | \ // RUN: FileCheck --check-prefix=CHECK1 %s // RUN: clang-scan-deps -compilation-database %t.cdb -j 2 -mode preprocess-dependency-directives | \ -// RUN: FileCheck --check-prefixes=CHECK2%if system-darwin %{,CHECK2-DARWIN %} %else %{,CHECK2-NON-DARWIN %} %s +// RUN: FileCheck --check-prefixes=CHECK2%if system-darwin && target={{.*}}-{{darwin|macos}}{{.*}} %{,CHECK2-DARWIN %} %else %{,CHECK2-NON-DARWIN %} %s // RUN: clang-scan-deps -compilation-database %t_clangcl.cdb -j 2 -mode preprocess-dependency-directives | \ // RUN: FileCheck --check-prefixes=CHECK2,CHECK2-NON-DARWIN %s // RUN: clang-scan-deps -compilation-database %t.cdb -j 2 -mode preprocess | \ -// RUN: FileCheck --check-prefixes=CHECK2%if system-darwin %{,CHECK2-DARWIN %} %else %{,CHECK2-NON-DARWIN %} %s +// RUN: FileCheck --check-prefixes=CHECK2%if system-darwin && target={{.*}}-{{darwin|macos}}{{.*}} %{,CHECK2-DARWIN %} %else %{,CHECK2-NON-DARWIN %} %s // RUN: clang-scan-deps -compilation-database %t_clangcl.cdb -j 2 -mode preprocess | \ // RUN: FileCheck --check-prefixes=CHECK2,CHECK2-NON-DARWIN %s diff --git a/clang/test/ClangScanDeps/regular_cdb.cpp b/clang/test/ClangScanDeps/regular_cdb.cpp index 6449b46b19dfb..60501d7a851ca 100644 --- a/clang/test/ClangScanDeps/regular_cdb.cpp +++ b/clang/test/ClangScanDeps/regular_cdb.cpp @@ -13,12 +13,12 @@ // RUN: sed -e "s|DIR|%/t.dir|g" %S/Inputs/regular_cdb_clangcl.json > %t_clangcl.cdb // // RUN: clang-scan-deps -compilation-database %t.cdb -j 1 -mode preprocess-dependency-directives | \ -// RUN: FileCheck --check-prefixes=CHECK1,CHECK2,CHECK2NO,CHECK3%if system-darwin %{,CHECK-DARWIN1,CHECK-DARWIN2 %} %s +// RUN: FileCheck --check-prefixes=CHECK1,CHECK2,CHECK2NO,CHECK3%if system-darwin && target={{.*}}-{{darwin|macos}}{{.*}} %{,CHECK-DARWIN1,CHECK-DARWIN2 %} %s // RUN: clang-scan-deps -compilation-database %t_clangcl.cdb -j 1 -mode preprocess-dependency-directives | \ // RUN: FileCheck --check-prefixes=CHECK1,CHECK2,CHECK2NO,CHECK3 %s // RUN: clang-scan-deps -compilation-database %t.cdb -j 1 -mode preprocess | \ -// RUN: FileCheck --check-prefixes=CHECK1,CHECK2,CHECK2NO,CHECK3%if system-darwin %{,CHECK-DARWIN1,CHECK-DARWIN2 %} %s +// RUN: FileCheck --check-prefixes=CHECK1,CHECK2,CHECK2NO,CHECK3%if system-darwin && target={{.*}}-{{darwin|macos}}{{.*}} %{,CHECK-DARWIN1,CHECK-DARWIN2 %} %s // RUN: clang-scan-deps -compilation-database %t_clangcl.cdb -j 1 -mode preprocess | \ // RUN: FileCheck --check-prefixes=CHECK1,CHECK2,CHECK2NO,CHECK3 %s @@ -34,22 +34,22 @@ // `regular_cdb_input2.cpp`. // // RUN: clang-scan-deps -compilation-database %t.cdb -j 2 -mode preprocess-dependency-directives | \ -// RUN: FileCheck --check-prefixes=CHECK1%if system-darwin %{,CHECK-DARWIN1 %} %s +// RUN: FileCheck --check-prefixes=CHECK1%if system-darwin && target={{.*}}-{{darwin|macos}}{{.*}} %{,CHECK-DARWIN1 %} %s // RUN: clang-scan-deps -compilation-database %t_clangcl.cdb -j 2 -mode preprocess-dependency-directives | \ // RUN: FileCheck --check-prefix=CHECK1 %s // RUN: clang-scan-deps -compilation-database %t.cdb -j 2 -mode preprocess | \ -// RUN: FileCheck --check-prefixes=CHECK1%if system-darwin %{,CHECK-DARWIN1 %} %s +// RUN: FileCheck --check-prefixes=CHECK1%if system-darwin && target={{.*}}-{{darwin|macos}}{{.*}} %{,CHECK-DARWIN1 %} %s // RUN: clang-scan-deps -compilation-database %t_clangcl.cdb -j 2 -mode preprocess | \ // RUN: FileCheck --check-prefix=CHECK1 %s // RUN: clang-scan-deps -compilation-database %t.cdb -j 2 -mode preprocess-dependency-directives | \ -// RUN: FileCheck --check-prefixes=CHECK2%if system-darwin %{,CHECK-DARWIN2 %} %s +// RUN: FileCheck --check-prefixes=CHECK2%if system-darwin && target={{.*}}-{{darwin|macos}}{{.*}} %{,CHECK-DARWIN2 %} %s // RUN: clang-scan-deps -compilation-database %t_clangcl.cdb -j 2 -mode preprocess-dependency-directives | \ // RUN: FileCheck --check-prefix=CHECK2 %s // RUN: clang-scan-deps -compilation-database %t.cdb -j 2 -mode preprocess | \ -// RUN: FileCheck --check-prefixes=CHECK2%if system-darwin %{,CHECK-DARWIN2 %} %s +// RUN: FileCheck --check-prefixes=CHECK2%if system-darwin && target={{.*}}-{{darwin|macos}}{{.*}} %{,CHECK-DARWIN2 %} %s // RUN: clang-scan-deps -compilation-database %t_clangcl.cdb -j 2 -mode preprocess | \ // RUN: FileCheck --check-prefix=CHECK2 %s diff --git a/clang/test/ClangScanDeps/relative_directory.cpp b/clang/test/ClangScanDeps/relative_directory.cpp index 12191102a451d..82c8d6eaa1ead 100644 --- a/clang/test/ClangScanDeps/relative_directory.cpp +++ b/clang/test/ClangScanDeps/relative_directory.cpp @@ -9,12 +9,12 @@ // RUN: touch %t.dir/Inputs/header.h // RUN: sed -e "s|DIR|%/t.dir|g" %S/Inputs/relative_directory.json > %t.cdb // -// RUN: clang-scan-deps -compilation-database %t.cdb -j 1 | FileCheck --check-prefixes=CHECK1,CHECK2%if system-darwin %{,CHECK-DARWIN1,CHECK-DARWIN2 %} %s +// RUN: clang-scan-deps -compilation-database %t.cdb -j 1 | FileCheck --check-prefixes=CHECK1,CHECK2%if system-darwin && target={{.*}}-{{darwin|macos}}{{.*}} %{,CHECK-DARWIN1,CHECK-DARWIN2 %} %s // The output order is non-deterministic when using more than one thread, // so check the output using two runs. -// RUN: clang-scan-deps -compilation-database %t.cdb -j 2 | FileCheck --check-prefixes=CHECK1%if system-darwin %{,CHECK-DARWIN1 %} %s -// RUN: clang-scan-deps -compilation-database %t.cdb -j 2 | FileCheck --check-prefixes=CHECK2%if system-darwin %{,CHECK-DARWIN2 %} %s +// RUN: clang-scan-deps -compilation-database %t.cdb -j 2 | FileCheck --check-prefixes=CHECK1%if system-darwin && target={{.*}}-{{darwin|macos}}{{.*}} %{,CHECK-DARWIN1 %} %s +// RUN: clang-scan-deps -compilation-database %t.cdb -j 2 | FileCheck --check-prefixes=CHECK2%if system-darwin && target={{.*}}-{{darwin|macos}}{{.*}} %{,CHECK-DARWIN2 %} %s #include <header.h> diff --git a/clang/test/ClangScanDeps/subframework_header_dir_symlink.m b/clang/test/ClangScanDeps/subframework_header_dir_symlink.m index a5912f980a95d..c8dc8bf9d84cb 100644 --- a/clang/test/ClangScanDeps/subframework_header_dir_symlink.m +++ b/clang/test/ClangScanDeps/subframework_header_dir_symlink.m @@ -8,7 +8,7 @@ // RUN: cp -R %S/Inputs/frameworks %t.dir/Inputs/frameworks // RUN: ln -s %t.dir/Inputs/frameworks %t.dir/Inputs/frameworks_symlink // RUN: sed -e "s|DIR|%/t.dir|g" %S/Inputs/subframework_header_dir_symlink_cdb.json > %t.cdb -// RUN: clang-scan-deps -compilation-database %t.cdb -j 1 | FileCheck %s %if system-darwin %{ --check-prefixes=CHECK,CHECK-DARWIN %} +// RUN: clang-scan-deps -compilation-database %t.cdb -j 1 | FileCheck %s %if system-darwin && target={{.*}}-{{darwin|macos}}{{.*}} %{ --check-prefixes=CHECK,CHECK-DARWIN %} #ifndef EMPTY #include "Framework/Framework.h" diff --git a/clang/test/ClangScanDeps/target-filename.cpp b/clang/test/ClangScanDeps/target-filename.cpp index ddc12ba504c7f..5f6ad0048c39e 100644 --- a/clang/test/ClangScanDeps/target-filename.cpp +++ b/clang/test/ClangScanDeps/target-filename.cpp @@ -5,7 +5,7 @@ // RUN: mkdir %t.dir/Inputs // RUN: cp %S/Inputs/header.h %t.dir/Inputs/header.h // RUN: sed -e "s|DIR|%/t.dir|g" %S/Inputs/target-filename-cdb.json > %t.cdb -// RUN: clang-scan-deps -compilation-database %t.cdb -j 1 | FileCheck %s --check-prefixes=CHECK,%if system-darwin %{CHECK-DARWIN %} %else %{CHECK-NON-DARWIN %} +// RUN: clang-scan-deps -compilation-database %t.cdb -j 1 | FileCheck %s --check-prefixes=CHECK,%if system-darwin && target={{.*}}-{{darwin|macos}}{{.*}} %{CHECK-DARWIN %} %else %{CHECK-NON-DARWIN %} // CHECK: target-filename_input.o: // CHECK-DARWIN-NEXT: SDKSettings.json diff --git a/clang/test/ClangScanDeps/vfsoverlay.cpp b/clang/test/ClangScanDeps/vfsoverlay.cpp index 03440101fcc83..c0d7bd0113ee2 100644 --- a/clang/test/ClangScanDeps/vfsoverlay.cpp +++ b/clang/test/ClangScanDeps/vfsoverlay.cpp @@ -8,8 +8,8 @@ // RUN: cp %S/Inputs/header.h %t.dir/Inputs/header.h // RUN: sed -e "s|DIR|%/t.dir|g" %S/Inputs/vfsoverlay_cdb.json > %t.cdb // -// RUN: clang-scan-deps -compilation-database %t.cdb -mode preprocess-dependency-directives -j 1 | FileCheck %s %if system-darwin %{ --check-prefixes=CHECK,CHECK-DARWIN %} -// RUN: clang-scan-deps -compilation-database %t.cdb -mode preprocess -j 1 | FileCheck %s %if system-darwin %{ --check-prefixes=CHECK,CHECK-DARWIN %} +// RUN: clang-scan-deps -compilation-database %t.cdb -mode preprocess-dependency-directives -j 1 | FileCheck %s %if system-darwin && target={{.*}}-{{darwin|macos}}{{.*}} %{ --check-prefixes=CHECK,CHECK-DARWIN %} +// RUN: clang-scan-deps -compilation-database %t.cdb -mode preprocess -j 1 | FileCheck %s %if system-darwin && target={{.*}}-{{darwin|macos}}{{.*}} %{ --check-prefixes=CHECK,CHECK-DARWIN %} #include "not_real.h" diff --git a/clang/test/Frontend/dependency-gen-phony.c b/clang/test/Frontend/dependency-gen-phony.c index bb456a254d917..12923cb1839dd 100644 --- a/clang/test/Frontend/dependency-gen-phony.c +++ b/clang/test/Frontend/dependency-gen-phony.c @@ -1,7 +1,7 @@ // RUN: cd %S // RUN: %clang -MM -MP -I Inputs -Xclang -fdepfile-entry=1.extra -Xclang -fdepfile-entry=2.extra -Xclang -fdepfile-entry=2.extra dependency-gen-phony.c | \ -// RUN: FileCheck %s %if system-darwin %{ --check-prefix=CHECK-DARWIN %} --match-full-lines --strict-whitespace --implicit-check-not=.c: -// RUN: %clang -MM -MP -I Inputs -xc - < dependency-gen-phony.c | FileCheck %s --check-prefix=%if system-darwin %{STDIO-DARWIN %} %else %{STDIO %} --implicit-check-not=.c: +// RUN: FileCheck %s %if system-darwin && target={{.*}}-{{darwin|macos}}{{.*}} %{ --check-prefix=CHECK-DARWIN %} --match-full-lines --strict-whitespace --implicit-check-not=.c: +// RUN: %clang -MM -MP -I Inputs -xc - < dependency-gen-phony.c | FileCheck %s --check-prefix=%if system-darwin && target={{.*}}-{{darwin|macos}}{{.*}} %{STDIO-DARWIN %} %else %{STDIO %} --implicit-check-not=.c: /// Verify that phony targets are only created for the extra dependency files, /// and not the input file. _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
