[clang] [clang][test] Fix flaky linker checks in msvc-link.c (PR #228657)
via cfe-commits
cfe-commits at lists.llvm.org
Sat Oct 3 09:47:56 PDT 2026
================
@@ -61,9 +61,8 @@
// RUN: %clang --target=i686-pc-windows-msvc -g -fuse-ld= -### %s 2>&1 | FileCheck --check-prefix=DEBUG-LINK %s
// RUN: %clang --target=i686-pc-windows-msvc -g -fuse-ld=link -### %s 2>&1 | FileCheck --check-prefix=DEBUG-LINK %s
-// DEBUG-LINK: link.exe"
+// DEBUG-LINK: "{{([^"]*[/\\])?}}link.exe"
----------------
zeroomega wrote:
Why it won't work? Build task https://ci.chromium.org/ui/p/fuchsia/builders/toolchain.ci.shadow/clang-linux-x64/b8668993331892795153/overview was test run on this PR using `clang/cmake/caches/Fuchsia-stage2.cmake` cache file (see https://logs.chromium.org/logs/fuchsia/buildbucket/cr-buildbucket/8668993331892795153/+/u/clang/configure/l_execution_details). And this cache file set the flag you mentioned to lld: https://github.com/llvm/llvm-project/blob/018a46162a84070109760677031bcd636ed6026e/clang/cmake/caches/Fuchsia-stage2.cmake#L43
So we already tested the scenario you suspected and it passed.
Also the two RUN: at L62 and 63 overrides the linker with -fuse-ld.
In visualstudio::Linker::ConstructJob:
https://github.com/llvm/llvm-project/blob/018a46162a84070109760677031bcd636ed6026e/clang/lib/Driver/ToolChains/MSVC.cpp#L341-L361
Because `-fuse-ld=` is present on the command line, `A` is non-null, so `TC.getDriver().getPreferredLinker()` (CLANG_DEFAULT_LINKER) is not used. `A->getValue()` returns "", which enters `if (Linker.empty())` and selects "link" (link.exe).
In this case, the test should pass even after the modification.
https://github.com/llvm/llvm-project/pull/228657
More information about the cfe-commits
mailing list