From b0671c88a34e4dc96ae4a26d7873c45d6d7221e9 Mon Sep 17 00:00:00 2001 From: Martell Malone Date: Wed, 13 Sep 2017 00:46:54 +0000 Subject: [PATCH] [Driver] MinGW: Remove custom linker detection In rL289668 the ability to specify the default linker at compile time was added but because the MinGW driver used custom detection we could not take advantage of this new CMAKE flag CLANG_DEFAULT_LINKER. This is a re-apply of rL313082 which was reverted in rL313088 due to failing buildbot tests. Differential Revision: https://reviews.llvm.org/D37727 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@313102 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Driver/ToolChains/MinGW.cpp | 12 ++---------- test/Driver/mingw-useld.c | 18 +++++++++--------- 2 files changed, 11 insertions(+), 19 deletions(-) diff --git a/lib/Driver/ToolChains/MinGW.cpp b/lib/Driver/ToolChains/MinGW.cpp index 46e2289219..6247efb305 100644 --- a/lib/Driver/ToolChains/MinGW.cpp +++ b/lib/Driver/ToolChains/MinGW.cpp @@ -104,14 +104,6 @@ void tools::MinGW::Linker::ConstructJob(Compilation &C, const JobAction &JA, // 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)); @@ -241,7 +233,7 @@ void tools::MinGW::Linker::ConstructJob(Compilation &C, const JobAction &JA, if (Args.hasArg(options::OPT_static)) CmdArgs.push_back("--end-group"); - else if (!LinkerName.equals_lower("lld")) + else AddLibGCC(Args, CmdArgs); } @@ -252,7 +244,7 @@ void tools::MinGW::Linker::ConstructJob(Compilation &C, const JobAction &JA, CmdArgs.push_back(Args.MakeArgString(TC.GetFilePath("crtend.o"))); } } - const char *Exec = Args.MakeArgString(TC.GetProgramPath(LinkerName.data())); + const char *Exec = Args.MakeArgString(TC.GetLinkerPath()); C.addCommand(llvm::make_unique(JA, *this, Exec, CmdArgs, Inputs)); } diff --git a/test/Driver/mingw-useld.c b/test/Driver/mingw-useld.c index a0ab5a9338..e364635eff 100644 --- a/test/Driver/mingw-useld.c +++ b/test/Driver/mingw-useld.c @@ -1,19 +1,19 @@ -// 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)?}}" +// RUN: %clang -### -target i686-pc-windows-gnu -fuse-ld=platform --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: "-flavor" "gnu" +// CHECK_LD_32-NOT: "{{[^"]*}}ld.lld{{(.exe)?}}" -// 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 +// RUN: %clang -### -target i686-pc-windows-gnu -fuse-ld=lld --sysroot=%S/Inputs/mingw_clang_tree/mingw32 %s 2>&1 | FileCheck -check-prefix=CHECK_LLD_32 %s // CHECK_LLD_32-NOT: invalid linker name in argument -// CHECK_LLD_32: lld{{(.exe)?}}" "-flavor" "gnu" +// CHECK_LLD_32: "{{[^"]*}}ld.lld{{(.exe)?}}" // 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 +// RUN: %clang -### -target x86_64-pc-windows-gnu -fuse-ld=lld --sysroot=%S/Inputs/mingw_clang_tree/mingw32 %s 2>&1 | FileCheck -check-prefix=CHECK_LLD_64 %s // CHECK_LLD_64-NOT: invalid linker name in argument -// CHECK_LLD_64: lld{{(.exe)?}}" "-flavor" "gnu" +// CHECK_LLD_64: "{{[^"]*}}ld.lld{{(.exe)?}}" // 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 +// RUN: %clang -### -target arm-pc-windows-gnu -fuse-ld=lld --sysroot=%S/Inputs/mingw_clang_tree/mingw32 %s 2>&1 | FileCheck -check-prefix=CHECK_LLD_ARM %s // CHECK_LLD_ARM-NOT: invalid linker name in argument -// CHECK_LLD_ARM: lld{{(.exe)?}}" "-flavor" "gnu" +// CHECK_LLD_ARM: "{{[^"]*}}ld.lld{{(.exe)?}}" // CHECK_LLD_ARM: "thumb2pe" -- 2.40.0