https://github.com/zhaoshiz updated https://github.com/llvm/llvm-project/pull/113966
>From 5259a3b00fe1b841e8548443036a943b169970dc Mon Sep 17 00:00:00 2001 From: Zhaoshi Zheng <zhaos...@quicinc.com> Date: Mon, 28 Oct 2024 14:35:35 -0700 Subject: [PATCH 1/2] [clang][Driver] Allow -fuse-lld=lld-link when lto is enabled on *windows-msvc targets Follow-up on https://github.com/llvm/llvm-project/pull/109607, we have a use case on WoA where `cmake -G "Unix Makefiles"` generates -fuse-ld=lld-link, which is disallowed by PR#109607. --- clang/lib/Driver/Driver.cpp | 2 +- clang/test/Driver/clang_f_opts.c | 1 + clang/test/Driver/woa-lto.c | 15 +++++++++++++++ 3 files changed, 17 insertions(+), 1 deletion(-) create mode 100644 clang/test/Driver/woa-lto.c diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp index 9878a9dad78d40..c1c581e6c6df7c 100644 --- a/clang/lib/Driver/Driver.cpp +++ b/clang/lib/Driver/Driver.cpp @@ -4035,7 +4035,7 @@ void Driver::handleArguments(Compilation &C, DerivedArgList &Args, if (C.getDefaultToolChain().getTriple().isWindowsMSVCEnvironment() && LTOMode != LTOK_None && !Args.getLastArgValue(options::OPT_fuse_ld_EQ) - .equals_insensitive("lld")) + .starts_with_insensitive("lld")) Diag(clang::diag::err_drv_lto_without_lld); // If -dumpdir is not specified, give a default prefix derived from the link diff --git a/clang/test/Driver/clang_f_opts.c b/clang/test/Driver/clang_f_opts.c index fd15552715cb35..2cfbe256bc7456 100644 --- a/clang/test/Driver/clang_f_opts.c +++ b/clang/test/Driver/clang_f_opts.c @@ -606,6 +606,7 @@ // RUN: %clang -### -S -fjmc -g --target=x86_64-unknown-linux %s 2>&1 | FileCheck -check-prefix=CHECK_JMC %s // RUN: %clang -### -S -fjmc -g -fno-jmc --target=x86_64-unknown-linux %s 2>&1 | FileCheck -check-prefix=CHECK_NOJMC %s // RUN: %clang -### -fjmc -g -flto -fuse-ld=lld --target=x86_64-pc-windows-msvc %s 2>&1 | FileCheck -check-prefix=CHECK_NOJMC_LTO %s +// RUN: %clang -### -fjmc -g -flto -fuse-ld=lld-link --target=x86_64-pc-windows-msvc %s 2>&1 | FileCheck -check-prefix=CHECK_NOJMC_LTO %s // RUN: %clang -### -fjmc -g -flto --target=x86_64-unknown-linux %s 2>&1 | FileCheck -check-prefix=CHECK_JMC_LTO %s // RUN: %clang -### -fjmc -g -flto -fno-jmc --target=x86_64-unknown-linux %s 2>&1 | FileCheck -check-prefix=CHECK_NOJMC_LTO %s // CHECK_JMC_WARN: -fjmc requires debug info. Use -g or debug options that enable debugger's stepping function; option ignored diff --git a/clang/test/Driver/woa-lto.c b/clang/test/Driver/woa-lto.c new file mode 100644 index 00000000000000..25c42374c4d449 --- /dev/null +++ b/clang/test/Driver/woa-lto.c @@ -0,0 +1,15 @@ +// REQUIRES: aarch64-registered-target +// +// RUN: echo "int main() {} " > %t.c +// +// RUN: %clang --target=aarch64-pc-windows-msvc -O3 -flto -fuse-ld=lld -c %t.c -o %t.o +// RUN: %clang --target=aarch64-pc-windows-msvc -O3 -flto -fuse-ld=lld -### %t.o 2>&1 | FileCheck %s +// RUN: %clang --target=aarch64-pc-windows-msvc -O3 -flto=thin -fuse-ld=lld -c %t.c -o %t.o +// RUN: %clang --target=aarch64-pc-windows-msvc -O3 -flto=thin -fuse-ld=lld -### %t.o 2>&1 | FileCheck %s +// +// RUN: %clang --target=aarch64-pc-windows-msvc -O3 -flto -fuse-ld=lld-link -c %t.c -o %t.o +// RUN: %clang --target=aarch64-pc-windows-msvc -O3 -flto -fuse-ld=lld-link -### %t.o 2>&1 | FileCheck %s +// RUN: %clang --target=aarch64-pc-windows-msvc -O3 -flto=thin -fuse-ld=lld-link -c %t.c -o %t.o +// RUN: %clang --target=aarch64-pc-windows-msvc -O3 -flto=thin -fuse-ld=lld-link -### %t.o 2>&1 | FileCheck %s +// +// CHECK: "{{.*}}lld-link" "-out:a.exe" "-defaultlib:libcmt" "-defaultlib:oldnames" >From 70454559165840f7c4e261bf5ed24b1c317d5b86 Mon Sep 17 00:00:00 2001 From: Zhaoshi Zheng <zhaos...@quicinc.com> Date: Mon, 28 Oct 2024 20:38:43 -0700 Subject: [PATCH 2/2] Update test case to allow possible '.exe' extension --- clang/test/Driver/woa-lto.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clang/test/Driver/woa-lto.c b/clang/test/Driver/woa-lto.c index 25c42374c4d449..7f4ecefd6b4b37 100644 --- a/clang/test/Driver/woa-lto.c +++ b/clang/test/Driver/woa-lto.c @@ -12,4 +12,4 @@ // RUN: %clang --target=aarch64-pc-windows-msvc -O3 -flto=thin -fuse-ld=lld-link -c %t.c -o %t.o // RUN: %clang --target=aarch64-pc-windows-msvc -O3 -flto=thin -fuse-ld=lld-link -### %t.o 2>&1 | FileCheck %s // -// CHECK: "{{.*}}lld-link" "-out:a.exe" "-defaultlib:libcmt" "-defaultlib:oldnames" +// CHECK: "{{.*}}lld-link{{(.exe)?}}" "-out:a.exe" "-defaultlib:libcmt" "-defaultlib:oldnames" _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits