This revision was automatically updated to reflect the committed changes. Closed by commit rL344412: [MinGW] Allow using LTO when lld is used as linker (authored by mstorsjo, committed by ). Herald added a subscriber: llvm-commits.
Changed prior to commit: https://reviews.llvm.org/D53195?vs=169387&id=169483#toc Repository: rL LLVM https://reviews.llvm.org/D53195 Files: cfe/trunk/lib/Driver/ToolChains/MinGW.cpp cfe/trunk/lib/Driver/ToolChains/MinGW.h cfe/trunk/test/Driver/mingw-lto.c Index: cfe/trunk/test/Driver/mingw-lto.c =================================================================== --- cfe/trunk/test/Driver/mingw-lto.c +++ cfe/trunk/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 Index: cfe/trunk/lib/Driver/ToolChains/MinGW.cpp =================================================================== --- cfe/trunk/lib/Driver/ToolChains/MinGW.cpp +++ cfe/trunk/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 @@ 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 @@ 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; } Index: cfe/trunk/lib/Driver/ToolChains/MinGW.h =================================================================== --- cfe/trunk/lib/Driver/ToolChains/MinGW.h +++ cfe/trunk/lib/Driver/ToolChains/MinGW.h @@ -59,6 +59,8 @@ 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 @@ void findGccLibDir(); llvm::ErrorOr<std::string> findGcc(); llvm::ErrorOr<std::string> findClangRelativeSysroot(); + + bool NativeLLVMSupport; }; } // end namespace toolchains
Index: cfe/trunk/test/Driver/mingw-lto.c =================================================================== --- cfe/trunk/test/Driver/mingw-lto.c +++ cfe/trunk/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 Index: cfe/trunk/lib/Driver/ToolChains/MinGW.cpp =================================================================== --- cfe/trunk/lib/Driver/ToolChains/MinGW.cpp +++ cfe/trunk/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 @@ 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 @@ 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; } Index: cfe/trunk/lib/Driver/ToolChains/MinGW.h =================================================================== --- cfe/trunk/lib/Driver/ToolChains/MinGW.h +++ cfe/trunk/lib/Driver/ToolChains/MinGW.h @@ -59,6 +59,8 @@ 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 @@ void findGccLibDir(); llvm::ErrorOr<std::string> findGcc(); llvm::ErrorOr<std::string> findClangRelativeSysroot(); + + bool NativeLLVMSupport; }; } // end namespace toolchains
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits