r313088 - Revert "[Driver] MinGW: Remove custom linker detection"
Martell Malone via cfe-commits
cfe-commits at lists.llvm.org
Tue Sep 12 15:58:12 PDT 2017
Author: martell
Date: Tue Sep 12 15:58:12 2017
New Revision: 313088
URL: http://llvm.org/viewvc/llvm-project?rev=313088&view=rev
Log:
Revert "[Driver] MinGW: Remove custom linker detection"
This reverts rL313082
Modified:
cfe/trunk/lib/Driver/ToolChains/MinGW.cpp
cfe/trunk/test/Driver/mingw-useld.c
Modified: cfe/trunk/lib/Driver/ToolChains/MinGW.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/MinGW.cpp?rev=313088&r1=313087&r2=313088&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/ToolChains/MinGW.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/MinGW.cpp Tue Sep 12 15:58:12 2017
@@ -104,6 +104,14 @@ void tools::MinGW::Linker::ConstructJob(
// handled somewhere else.
Args.ClaimAllArgs(options::OPT_w);
+ StringRef LinkerName = Args.getLastArgValue(options::OPT_fuse_ld_EQ, "ld");
+ if (LinkerName.equals_lower("lld")) {
+ CmdArgs.push_back("-flavor");
+ CmdArgs.push_back("gnu");
+ } else if (!LinkerName.equals_lower("ld")) {
+ D.Diag(diag::err_drv_unsupported_linker) << LinkerName;
+ }
+
if (!D.SysRoot.empty())
CmdArgs.push_back(Args.MakeArgString("--sysroot=" + D.SysRoot));
@@ -233,7 +241,7 @@ void tools::MinGW::Linker::ConstructJob(
if (Args.hasArg(options::OPT_static))
CmdArgs.push_back("--end-group");
- else
+ else if (!LinkerName.equals_lower("lld"))
AddLibGCC(Args, CmdArgs);
}
@@ -244,7 +252,7 @@ void tools::MinGW::Linker::ConstructJob(
CmdArgs.push_back(Args.MakeArgString(TC.GetFilePath("crtend.o")));
}
}
- const char *Exec = Args.MakeArgString(TC.GetLinkerPath());
+ const char *Exec = Args.MakeArgString(TC.GetProgramPath(LinkerName.data()));
C.addCommand(llvm::make_unique<Command>(JA, *this, Exec, CmdArgs, Inputs));
}
Modified: cfe/trunk/test/Driver/mingw-useld.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/mingw-useld.c?rev=313088&r1=313087&r2=313088&view=diff
==============================================================================
--- cfe/trunk/test/Driver/mingw-useld.c (original)
+++ cfe/trunk/test/Driver/mingw-useld.c Tue Sep 12 15:58:12 2017
@@ -1,19 +1,19 @@
-// RUN: %clang -### -target i686-pc-windows-gnu --sysroot=%S/Inputs/mingw_clang_tree/mingw32 %s -fuse-ld=platform 2>&1 | FileCheck -check-prefix=CHECK_LD_32 %s
-// CHECK_LD_32: "{{[^"]*}}ld{{(.exe)?}}"
+// RUN: %clang -### -target i686-pc-windows-gnu --sysroot=%S/Inputs/mingw_clang_tree/mingw32 %s 2>&1 | FileCheck -check-prefix=CHECK_LD_32 %s
+// CHECK_LD_32: ld{{(.exe)?}}"
// CHECK_LD_32: "i386pe"
-// CHECK_LD_32-NOT: "{{[^"]*}}ld.lld{{(.exe)?}}"
+// CHECK_LD_32-NOT: "-flavor" "gnu"
// RUN: %clang -### -target i686-pc-windows-gnu --sysroot=%S/Inputs/mingw_clang_tree/mingw32 %s -fuse-ld=lld 2>&1 | FileCheck -check-prefix=CHECK_LLD_32 %s
// CHECK_LLD_32-NOT: invalid linker name in argument
-// CHECK_LLD_32: "{{[^"]*}}ld.lld{{(.exe)?}}"
+// CHECK_LLD_32: lld{{(.exe)?}}" "-flavor" "gnu"
// CHECK_LLD_32: "i386pe"
// RUN: %clang -### -target x86_64-pc-windows-gnu --sysroot=%S/Inputs/mingw_clang_tree/mingw32 %s -fuse-ld=lld 2>&1 | FileCheck -check-prefix=CHECK_LLD_64 %s
// CHECK_LLD_64-NOT: invalid linker name in argument
-// CHECK_LLD_64: "{{[^"]*}}ld.lld{{(.exe)?}}"
+// CHECK_LLD_64: lld{{(.exe)?}}" "-flavor" "gnu"
// CHECK_LLD_64: "i386pep"
// RUN: %clang -### -target arm-pc-windows-gnu --sysroot=%S/Inputs/mingw_clang_tree/mingw32 %s -fuse-ld=lld 2>&1 | FileCheck -check-prefix=CHECK_LLD_ARM %s
// CHECK_LLD_ARM-NOT: invalid linker name in argument
-// CHECK_LLD_ARM: "{{[^"]*}}ld.lld{{(.exe)?}}"
+// CHECK_LLD_ARM: lld{{(.exe)?}}" "-flavor" "gnu"
// CHECK_LLD_ARM: "thumb2pe"
More information about the cfe-commits
mailing list