Test failuire: Driver/baremetal.cpp

I've configured clang to use gold, which seems to cause
test/Driver/baremetal.cpp to fail. The test works like this:

// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
// RUN: -target armv6m-none-eabi \
// RUN: -T semihosted.lds \
// RUN: -L some/directory/user/asked/for \
// RUN: --sysroot=%S/Inputs/baremetal_arm \
// RUN: | FileCheck --check-prefix=CHECK-V6M-C %s
// CHECK-V6M-C: "[[PREFIX_DIR:.*]]{{[/\\]+}}{{[^/^\\]+}}{{[/\\]+}}clang{{.*}}" "-cc1" "-triple" "thumbv6m-none--eabi"
// CHECK-V6M-C-SAME: "-resource-dir" "[[RESOURCE_DIR:[^"]+]]"
// CHECK-V6M-C-SAME: "-isysroot" "[[SYSROOT:[^"]*]]"
// CHECK-V6M-C-SAME: "-internal-isystem" "[[SYSROOT]]{{[/\\]+}}include{{[/\\]+}}c++{{[/\\]+}}v1"
// CHECk-V6M-C-SAME: "-internal-isystem" "[[SYSROOT]]{{[/\\]+}}include"
// CHECK-V6M-C-SAME: "-x" "c++" "{{.*}}baremetal.cpp"
// CHECK-V6M-C-NEXT: "{{[^"]*}}ld.lld{{(\.exe)?}}" "{{.*}}.o" "-Bstatic"

The NEXT line is problematic as it assumes ld.lld. I did not build lld,
though I could simply to get the test working. But building lld is not
enough as I configured with CLANG_DEFAULT_LINKER=gold. It seems like
the RUN line needs -fuse-ld=lld.

Is there a REQUIRES clause for lld being present and default? I could
not find somthing appropriate in lit's config.available_features.

It's certainly possible I'm doing something wrong, as I assume many
people use gold with clang. Maybe those people don't run the tests?

I am happy to update the test if someone can point me to a good REQUIRES
clause.

Thanks!

                                 -David

Hi,

I wonder if this test really needs to depend on lld. Maybe you can replace ld.lld with ld so that the test passes for any linker?

Yes, that's fine by me. We don't have a cross-linker gold, so I want to
make sure this isn't testing that a cross-linker is found.

                            -David

Rui Ueyama <ruiu@google.com> writes:

I didn’t write this test, so I don’t know what is intended. I’d create a patch to relax the regexp and send it to the person who wrote this test.

My understanding is that the BareMetal driver will default to ld.lld
if clang has been configured with the default linker of "ld" which as
far as I know means ToolChain default. It looks like this will fail
when anyone builds clang with a different default linker to "ld" or
"ld.lld". I guess some cmake/lit magic could be done to disable the
test if the change default linker option has been used via REQUIRES,
but I don't know if that is worth it.

Peter