[clang] eca29d4 - [Clang] Avoid using unwind library in the MSVC environment
Petr Hosek via cfe-commits
cfe-commits at lists.llvm.org
Tue Aug 23 17:09:11 PDT 2022
Author: Petr Hosek
Date: 2022-08-24T00:09:01Z
New Revision: eca29d4a37b8d1c93fe99be6289a60bb11cf789d
URL: https://github.com/llvm/llvm-project/commit/eca29d4a37b8d1c93fe99be6289a60bb11cf789d
DIFF: https://github.com/llvm/llvm-project/commit/eca29d4a37b8d1c93fe99be6289a60bb11cf789d.diff
LOG: [Clang] Avoid using unwind library in the MSVC environment
We're seeing the following warnings with --rtlib=compiler-rt:
lld-link: warning: ignoring unknown argument '--as-needed'
lld-link: warning: ignoring unknown argument '-lunwind'
lld-link: warning: ignoring unknown argument '--no-as-needed'
MSVC doesn't use the unwind library, so just omit it.
Differential Revision: https://reviews.llvm.org/D132440
Added:
Modified:
clang/lib/Driver/ToolChains/CommonArgs.cpp
clang/test/Driver/compiler-rt-unwind.c
Removed:
################################################################################
diff --git a/clang/lib/Driver/ToolChains/CommonArgs.cpp b/clang/lib/Driver/ToolChains/CommonArgs.cpp
index d5b437ceed63c..f270a5763806b 100644
--- a/clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ b/clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -1529,7 +1529,7 @@ static void AddUnwindLibrary(const ToolChain &TC, const Driver &D,
// Targets that don't use unwind libraries.
if ((TC.getTriple().isAndroid() && UNW == ToolChain::UNW_Libgcc) ||
TC.getTriple().isOSIAMCU() || TC.getTriple().isOSBinFormatWasm() ||
- UNW == ToolChain::UNW_None)
+ TC.getTriple().isWindowsMSVCEnvironment() || UNW == ToolChain::UNW_None)
return;
LibGccType LGT = getLibGccType(TC, D, Args);
diff --git a/clang/test/Driver/compiler-rt-unwind.c b/clang/test/Driver/compiler-rt-unwind.c
index c5f63fba065e0..88e2705029032 100644
--- a/clang/test/Driver/compiler-rt-unwind.c
+++ b/clang/test/Driver/compiler-rt-unwind.c
@@ -88,6 +88,12 @@
// RTLIB-GCC-UNWINDLIB-COMPILER_RT: "{{[.|\\\n]*}}--rtlib=libgcc requires --unwindlib=libgcc"
//
// RUN: %clang -### %s 2>&1 \
+// RUN: --target=x86_64-pc-windows-msvc -rtlib=compiler-rt --unwindlib=libunwind \
+// RUN: | FileCheck --check-prefix=MSVC-RTLIB-COMPILER-RT-UNWINDLIB-COMPILER-RT %s
+// MSVC-RTLIB-COMPILER-RT-UNWINDLIB-COMPILER-RT: "{{.*}}clang_rt.builtins-x86_64.lib"
+// MSVC-RTLIB-COMPILER-RT-UNWINDLIB-COMPILER-RT-NOT: "{{.*}}unwind.lib"
+//
+// RUN: %clang -### %s 2>&1 \
// RUN: --target=x86_64-w64-mingw32 -rtlib=compiler-rt --unwindlib=libunwind \
// RUN: -shared-libgcc \
// RUN: --gcc-toolchain="" \
More information about the cfe-commits
mailing list