Index: clang/lib/Driver/ToolChains/CommonArgs.cpp =================================================================== --- clang/lib/Driver/ToolChains/CommonArgs.cpp +++ clang/lib/Driver/ToolChains/CommonArgs.cpp @@ -1382,7 +1382,9 @@ // 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; } Index: clang/test/Driver/compiler-rt-unwind.c =================================================================== --- clang/test/Driver/compiler-rt-unwind.c +++ 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"