Skip to content

Commit ff56584

Browse files
authored
[LLD][COFF] Use getMachineArchType in LinkerDriver::getArch. (#87499)
Adds support for ARM64EC, which should use the same search paths as ARM64. It's similar to #87370 and #87495. The test is based on the existing x86 test. Generally ARM64EC libraries are shipped together with native ARM64 libraries (using ECSYMBOLS section mechanism). getMachineArchType uses Triple::thumb, while the existing implementation uses Triple::arm. It's ultimately passed to MSVCPaths.cpp functions, so modify them to accept both forms.
1 parent a8c5975 commit ff56584

File tree

3 files changed

+29
-12
lines changed

3 files changed

+29
-12
lines changed

lld/COFF/Driver.cpp

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -157,18 +157,7 @@ StringRef LinkerDriver::mangle(StringRef sym) {
157157
}
158158

159159
llvm::Triple::ArchType LinkerDriver::getArch() {
160-
switch (ctx.config.machine) {
161-
case I386:
162-
return llvm::Triple::ArchType::x86;
163-
case AMD64:
164-
return llvm::Triple::ArchType::x86_64;
165-
case ARMNT:
166-
return llvm::Triple::ArchType::arm;
167-
case ARM64:
168-
return llvm::Triple::ArchType::aarch64;
169-
default:
170-
return llvm::Triple::ArchType::UnknownArch;
171-
}
160+
return getMachineArchType(ctx.config.machine);
172161
}
173162

174163
bool LinkerDriver::findUnderscoreMangle(StringRef sym) {
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# REQUIRES: aarch64
2+
3+
# RUN: llvm-mc -triple aarch64-windows-msvc %s -filetype=obj -o %t.aarch64.obj
4+
# RUN: lld-link -dll -noentry -winsysroot:%t.dir/sysroot -vctoolsversion:1.1.1.1 -winsdkversion:10.0.1 -libpath:custom-dir \
5+
# RUN: %t.aarch64.obj -print-search-paths | FileCheck -DSYSROOT=%t.dir %s
6+
7+
# RUN: llvm-mc -triple arm64ec-windows-msvc %s -filetype=obj -o %t.arm64ec.obj
8+
# RUN: lld-link -dll -noentry -winsysroot:%t.dir/sysroot -vctoolsversion:1.1.1.1 -winsdkversion:10.0.1 -libpath:custom-dir \
9+
# RUN: %t.arm64ec.obj -print-search-paths -machine:arm64ec | FileCheck -DSYSROOT=%t.dir %s
10+
11+
# CHECK: Library search paths:
12+
# CHECK-NEXT: (cwd)
13+
# CHECK-NEXT: custom-dir
14+
# CHECK-NEXT: [[CPATH:.*]]lib{{[/\\]}}clang{{[/\\]}}{{[0-9]+}}{{[/\\]}}lib{{[/\\]}}windows
15+
# CHECK-NEXT: [[CPATH]]lib{{[/\\]}}clang{{[/\\]}}{{[0-9]+}}{{[/\\]}}lib
16+
# CHECK-NEXT: [[CPATH]]lib
17+
# CHECK-NEXT: [[SYSROOT]]{{[/\\]}}sysroot{{[/\\]}}DIA SDK{{[/\\]}}lib{{[/\\]}}arm64
18+
# CHECK-NEXT: [[SYSROOT]]{{[/\\]}}sysroot{{[/\\]}}VC{{[/\\]}}Tools{{[/\\]}}MSVC{{[/\\]}}1.1.1.1{{[/\\]}}lib{{[/\\]}}arm64
19+
# CHECK-NEXT: [[SYSROOT]]{{[/\\]}}sysroot{{[/\\]}}VC{{[/\\]}}Tools{{[/\\]}}MSVC{{[/\\]}}1.1.1.1{{[/\\]}}atlmfc{{[/\\]}}lib{{[/\\]}}arm64
20+
# CHECK-NEXT: [[SYSROOT]]{{[/\\]}}sysroot{{[/\\]}}Windows Kits{{[/\\]}}10{{[/\\]}}Lib{{[/\\]}}10.0.1{{[/\\]}}ucrt{{[/\\]}}arm64
21+
# CHECK-NEXT: [[SYSROOT]]{{[/\\]}}sysroot{{[/\\]}}Windows Kits{{[/\\]}}10{{[/\\]}}Lib{{[/\\]}}10.0.1{{[/\\]}}um{{[/\\]}}arm64
22+
23+
.data
24+
.word 1

llvm/lib/WindowsDriver/MSVCPaths.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,7 @@ const char *archToWindowsSDKArch(Triple::ArchType Arch) {
268268
case Triple::ArchType::x86_64:
269269
return "x64";
270270
case Triple::ArchType::arm:
271+
case Triple::ArchType::thumb:
271272
return "arm";
272273
case Triple::ArchType::aarch64:
273274
return "arm64";
@@ -285,6 +286,7 @@ const char *archToLegacyVCArch(Triple::ArchType Arch) {
285286
case Triple::ArchType::x86_64:
286287
return "amd64";
287288
case Triple::ArchType::arm:
289+
case Triple::ArchType::thumb:
288290
return "arm";
289291
case Triple::ArchType::aarch64:
290292
return "arm64";
@@ -300,6 +302,7 @@ const char *archToDevDivInternalArch(Triple::ArchType Arch) {
300302
case Triple::ArchType::x86_64:
301303
return "amd64";
302304
case Triple::ArchType::arm:
305+
case Triple::ArchType::thumb:
303306
return "arm";
304307
case Triple::ArchType::aarch64:
305308
return "arm64";
@@ -321,6 +324,7 @@ bool appendArchToWindowsSDKLibPath(int SDKMajor, SmallString<128> LibPath,
321324
sys::path::append(LibPath, "x64");
322325
break;
323326
case Triple::arm:
327+
case Triple::thumb:
324328
// It is not necessary to link against Windows SDK 7.x when targeting ARM.
325329
return false;
326330
default:

0 commit comments

Comments
 (0)