Skip to content

Commit 80a4948

Browse files
authored
[clang][Driver] Allow -fuse-lld=lld-link when lto is enabled on *windows-msvc targets (#113966)
Follow-up on #109607, we have a use case on Windows-on-ARM64 where `cmake -G "Unix Makefiles"` generates `-fuse-ld=lld-link`, which is accidentally disallowed by PR#109607.
1 parent 77b7d9d commit 80a4948

File tree

3 files changed

+11
-1
lines changed

3 files changed

+11
-1
lines changed

clang/lib/Driver/Driver.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -4035,7 +4035,7 @@ void Driver::handleArguments(Compilation &C, DerivedArgList &Args,
40354035
if (C.getDefaultToolChain().getTriple().isWindowsMSVCEnvironment() &&
40364036
LTOMode != LTOK_None &&
40374037
!Args.getLastArgValue(options::OPT_fuse_ld_EQ)
4038-
.equals_insensitive("lld"))
4038+
.starts_with_insensitive("lld"))
40394039
Diag(clang::diag::err_drv_lto_without_lld);
40404040

40414041
// If -dumpdir is not specified, give a default prefix derived from the link

clang/test/Driver/clang_f_opts.c

+1
Original file line numberDiff line numberDiff line change
@@ -606,6 +606,7 @@
606606
// RUN: %clang -### -S -fjmc -g --target=x86_64-unknown-linux %s 2>&1 | FileCheck -check-prefix=CHECK_JMC %s
607607
// RUN: %clang -### -S -fjmc -g -fno-jmc --target=x86_64-unknown-linux %s 2>&1 | FileCheck -check-prefix=CHECK_NOJMC %s
608608
// RUN: %clang -### -fjmc -g -flto -fuse-ld=lld --target=x86_64-pc-windows-msvc %s 2>&1 | FileCheck -check-prefix=CHECK_NOJMC_LTO %s
609+
// 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
609610
// RUN: %clang -### -fjmc -g -flto --target=x86_64-unknown-linux %s 2>&1 | FileCheck -check-prefix=CHECK_JMC_LTO %s
610611
// RUN: %clang -### -fjmc -g -flto -fno-jmc --target=x86_64-unknown-linux %s 2>&1 | FileCheck -check-prefix=CHECK_NOJMC_LTO %s
611612
// CHECK_JMC_WARN: -fjmc requires debug info. Use -g or debug options that enable debugger's stepping function; option ignored

clang/test/Driver/windows-lto.c

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// RUN: %clang --target=aarch64-pc-windows-msvc -O3 -flto -fuse-ld=lld -### %s 2>&1 | FileCheck %s
2+
// RUN: %clang --target=aarch64-pc-windows-msvc -O3 -flto=thin -fuse-ld=lld -### %s 2>&1 | FileCheck %s
3+
4+
// RUN: %clang --target=aarch64-pc-windows-msvc -O3 -flto -fuse-ld=lld-link -### %s 2>&1 | FileCheck %s
5+
// RUN: %clang --target=aarch64-pc-windows-msvc -O3 -flto=thin -fuse-ld=lld-link -### %s 2>&1 | FileCheck %s
6+
7+
// CHECK: "{{.*}}lld-link{{(.exe)?}}" "-out:a.exe" "-defaultlib:libcmt" "-defaultlib:oldnames"
8+
9+
int main() { return 0; }

0 commit comments

Comments
 (0)