[clang] [Clang][Driver] Revise Cygwin ToolChain to call linker directly (PR #147960)
via cfe-commits
cfe-commits at lists.llvm.org
Sat Jul 11 06:36:05 PDT 2026
================
@@ -684,6 +684,8 @@ static StringRef getArchNameForCompilerRTLib(const ToolChain &TC,
StringRef ToolChain::getOSLibName() const {
if (Triple.isOSDarwin())
return "darwin";
+ if (Triple.isWindowsCygwinEnvironment())
+ return "cygwin";
----------------
tyan0 wrote:
I observed following behaviour.
In `ToolChain::getCompilerRT()`, the path `/usr/lib/clang/22/lib/x86_64-pc-windows-cygnus/libclang_rt.builtins.a` is checked first. Then, `/usr/lib/clang/22/lib/windows/libclang_rt.builtins-x86_64.a` is checked.
This algorithm is not affected by `LLVM_ENABLE_PER_TARGET_RUNTIME_DIR` setting in clang.
If `LLVM_ENABLE_PER_TARGET_RUNTIME_DIR` is `ON` in compiler-rt, the first search will succeed. However, if `LLVM_ENABLE_PER_TARGET_RUNTIME_DIR` is `OFF` in compiler-rt, the correct path should not be `/usr/lib/clang/22/lib/windows/libclang_rt.builtins-x86_64.a`, but `/usr/lib/clang/22/lib/cygwin/libclang_rt.builtins-x86_64.a`, therefore, both search will fail. The patch above solves this issue.
As a conclusion, I’ve confirmed that the patch is indeed necessary after all. So, I'll create another PR for that.
https://github.com/llvm/llvm-project/pull/147960
More information about the cfe-commits
mailing list