Author: Martin Storsjö Date: 2021-03-06T08:50:46+02:00 New Revision: ebe6d3be0f73c15e64b1ebafd2a4b9fa836be78c
URL: https://github.com/llvm/llvm-project/commit/ebe6d3be0f73c15e64b1ebafd2a4b9fa836be78c DIFF: https://github.com/llvm/llvm-project/commit/ebe6d3be0f73c15e64b1ebafd2a4b9fa836be78c.diff LOG: [clang] Don't default to a specifically shared libunwind on mingw with a g++ driver For MinGW targets, we distinguish between an explicitly shared unwinder library (requested via -shared-libgcc), an explicitly static one (requested via -static-libgcc or -static) and the default case (which just passes -lunwind to the linker, which will pick either shared or static depending on what's available, with the normal linker logic). This makes the implicit default case (as added in D79995) actually work as it was intended, when using the g++ driver (which is the main usecase for libunwind as far as I know). Differential Revision: https://reviews.llvm.org/D98023 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 46a0fc67ced0..5afb213a178b 100644 --- a/clang/lib/Driver/ToolChains/CommonArgs.cpp +++ b/clang/lib/Driver/ToolChains/CommonArgs.cpp @@ -1382,7 +1382,9 @@ static LibGccType getLibGccType(const ToolChain &TC, const Driver &D, // The Android NDK only provides libunwind.a, not libunwind.so. if (TC.getTriple().isAndroid()) return LibGccType::StaticLibGcc; - if (D.CCCIsCXX()) + // For MinGW, don't imply a shared libgcc here, we only want to return + // SharedLibGcc if that was explicitly requested. + if (D.CCCIsCXX() && !TC.getTriple().isOSCygMing()) return LibGccType::SharedLibGcc; return LibGccType::UnspecifiedLibGcc; } diff --git a/clang/test/Driver/compiler-rt-unwind.c b/clang/test/Driver/compiler-rt-unwind.c index e21916d41f93..86c2c9b982c3 100644 --- a/clang/test/Driver/compiler-rt-unwind.c +++ b/clang/test/Driver/compiler-rt-unwind.c @@ -69,5 +69,9 @@ // RUN: --target=x86_64-w64-mingw32 -rtlib=compiler-rt --unwindlib=libunwind \ // RUN: --gcc-toolchain="" \ // RUN: | FileCheck --check-prefix=MINGW-RTLIB-COMPILER-RT-UNWINDLIB-COMPILER-RT %s +// RUN: %clangxx -no-canonical-prefixes %s -### -o %t.o 2>&1 \ +// RUN: --target=x86_64-w64-mingw32 -rtlib=compiler-rt --unwindlib=libunwind \ +// RUN: --gcc-toolchain="" \ +// RUN: | FileCheck --check-prefix=MINGW-RTLIB-COMPILER-RT-UNWINDLIB-COMPILER-RT %s // MINGW-RTLIB-COMPILER-RT-UNWINDLIB-COMPILER-RT: "{{.*}}libclang_rt.builtins-x86_64.a" // MINGW-RTLIB-COMPILER-RT-UNWINDLIB-COMPILER-RT: "{{.*}}lunwind" _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits