r313104 - Revert "[Driver] MinGW: Remove custom linker detection"

Martell Malone via cfe-commits cfe-commits at lists.llvm.org
Tue Sep 12 18:54:32 PDT 2017


Hey Reid, Rui,

I had to revert this twice. I'm not sure where the configurations for the
build bots are but there are 2 issues as I mentioned in the commit message

Looking through the clang test directory I only se -fuse-ld=lld tested in 4
locations

test/Driver/windows-cross.c does some really old tests like
`-fuse-ld=lld-link2` which was back when Rui had just started the new COFF
linker. (maybe we should remove / update these ? )
test/Driver/cl-link.c which checks that for cl -fuse-ld=lld is converted
to lld-link and not ld.lld
test/Driver/cl-options.c just checks an error showing LTO that requires
-fuse-ld=lld
and in
test/Driver/mingw-useld.c where we run into our errors.

So to begin there does not seem to be any checking for lld in the test
suite because it is not properly tested anywhere (from a clang perspective).

For the first error `error: invalid linker name in argument '-fuse-ld=lld'`
I'm not sure exactly how to add requirements to the lit tooling, I did a
few greps build only came up with target checks.
but do you know where I would look to implement something like this?
`// REQUIRES: lld`

As for the second issue.

lld-link.exe: warning: ignoring unknown argument: -fuse-ld=lld

I can't confirm but it seems like a configuration with the buildbot itself.
Possibly related to setting LLD_SYMLINKS_TO_CREATE within the bot itself or
some bat file on the system itself for symlinking?

I don't think it is clang itself that is doing this because the only place
where lld is remapped to lld-link is in lib/Driver/ToolChains/MSVC.cpp
and that is only for msvc targets with a testcase in test/Driver/cl-link.c

Best,
Martell

On Wed, Sep 13, 2017 at 1:57 AM, Martell Malone via cfe-commits <
cfe-commits at lists.llvm.org> wrote:

> Author: martell
> Date: Tue Sep 12 17:57:50 2017
> New Revision: 313104
>
> URL: http://llvm.org/viewvc/llvm-project?rev=313104&view=rev
> Log:
> Revert "[Driver] MinGW: Remove custom linker detection"
>
> This reverts rL313102 because it still fails some build bot tests.
>
> On many linux bots it fails with the following error.
> error: invalid linker name in argument '-fuse-ld=lld'
> and on some windows bots also because there is no ld.lld.exe
> lld-link.exe: warning: ignoring unknown argument: -fuse-ld=lld
>
> 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/Too
> lChains/MinGW.cpp?rev=313104&r1=313103&r2=313104&view=diff
> ============================================================
> ==================
> --- cfe/trunk/lib/Driver/ToolChains/MinGW.cpp (original)
> +++ cfe/trunk/lib/Driver/ToolChains/MinGW.cpp Tue Sep 12 17:57:50 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.GetProgr
> amPath(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/mi
> ngw-useld.c?rev=313104&r1=313103&r2=313104&view=diff
> ============================================================
> ==================
> --- cfe/trunk/test/Driver/mingw-useld.c (original)
> +++ cfe/trunk/test/Driver/mingw-useld.c Tue Sep 12 17:57:50 2017
> @@ -1,19 +1,19 @@
> -// 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)?}}"
> +// 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 -fuse-ld=lld
> --sysroot=%S/Inputs/mingw_clang_tree/mingw32 %s 2>&1 | FileCheck
> -check-prefix=CHECK_LLD_32 %s
> +// 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 -fuse-ld=lld
> --sysroot=%S/Inputs/mingw_clang_tree/mingw32 %s 2>&1 | FileCheck
> -check-prefix=CHECK_LLD_64 %s
> +// 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 -fuse-ld=lld
> --sysroot=%S/Inputs/mingw_clang_tree/mingw32 %s 2>&1 | FileCheck
> -check-prefix=CHECK_LLD_ARM %s
> +// 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"
>
>
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20170913/49cf6ae8/attachment-0001.html>


More information about the cfe-commits mailing list