From: Martin Storsjo Date: Fri, 12 Oct 2018 20:15:51 +0000 (+0000) Subject: [MinGW] Allow using LTO when lld is used as linker X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=1c99505cfafe7f6057981f365a75ae869c13b13d;p=clang [MinGW] Allow using LTO when lld is used as linker Differential Revision: https://reviews.llvm.org/D53195 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@344412 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Driver/ToolChains/MinGW.cpp b/lib/Driver/ToolChains/MinGW.cpp index f9e641e63f..4a68205f95 100644 --- a/lib/Driver/ToolChains/MinGW.cpp +++ b/lib/Driver/ToolChains/MinGW.cpp @@ -10,6 +10,7 @@ #include "MinGW.h" #include "InputInfo.h" #include "CommonArgs.h" +#include "clang/Config/config.h" #include "clang/Driver/Compilation.h" #include "clang/Driver/Driver.h" #include "clang/Driver/DriverDiagnostic.h" @@ -376,6 +377,10 @@ toolchains::MinGW::MinGW(const Driver &D, const llvm::Triple &Triple, getFilePaths().push_back(Base + "lib"); // openSUSE getFilePaths().push_back(Base + Arch + "/sys-root/mingw/lib"); + + NativeLLVMSupport = + Args.getLastArgValue(options::OPT_fuse_ld_EQ, CLANG_DEFAULT_LINKER) + .equals_lower("lld"); } bool toolchains::MinGW::IsIntegratedAssemblerDefault() const { return true; } @@ -403,6 +408,10 @@ Tool *toolchains::MinGW::buildLinker() const { return new tools::MinGW::Linker(*this); } +bool toolchains::MinGW::HasNativeLLVMSupport() const { + return NativeLLVMSupport; +} + bool toolchains::MinGW::IsUnwindTablesDefault(const ArgList &Args) const { return getArch() == llvm::Triple::x86_64; } diff --git a/lib/Driver/ToolChains/MinGW.h b/lib/Driver/ToolChains/MinGW.h index 450044d451..04d23006ee 100644 --- a/lib/Driver/ToolChains/MinGW.h +++ b/lib/Driver/ToolChains/MinGW.h @@ -59,6 +59,8 @@ public: MinGW(const Driver &D, const llvm::Triple &Triple, const llvm::opt::ArgList &Args); + bool HasNativeLLVMSupport() const override; + bool IsIntegratedAssemblerDefault() const override; bool IsUnwindTablesDefault(const llvm::opt::ArgList &Args) const override; bool isPICDefault() const override; @@ -99,6 +101,8 @@ private: void findGccLibDir(); llvm::ErrorOr findGcc(); llvm::ErrorOr findClangRelativeSysroot(); + + bool NativeLLVMSupport; }; } // end namespace toolchains diff --git a/test/Driver/mingw-lto.c b/test/Driver/mingw-lto.c new file mode 100644 index 0000000000..8bb4aedefd --- /dev/null +++ b/test/Driver/mingw-lto.c @@ -0,0 +1,4 @@ +// The default linker doesn't support LLVM bitcode +// RUN: not %clang -target i686-pc-windows-gnu %s -flto -fuse-ld=bfd +// When using lld, this is allowed though. +// RUN: %clang -target i686-pc-windows-gnu -### %s -flto -fuse-ld=lld