Skip to content

Commit

Permalink
[Clang] Avoid using unwind library in the MSVC environment
Browse files Browse the repository at this point in the history
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
  • Loading branch information
petrhosek committed Aug 24, 2022
1 parent df4e637 commit eca29d4
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion clang/lib/Driver/ToolChains/CommonArgs.cpp
Expand Up @@ -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);
Expand Down
6 changes: 6 additions & 0 deletions clang/test/Driver/compiler-rt-unwind.c
Expand Up @@ -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="" \
Expand Down

0 comments on commit eca29d4

Please sign in to comment.