[lld] ff56584 - [LLD][COFF] Use getMachineArchType in LinkerDriver::getArch. (#87499)
via llvm-commits
llvm-commits at lists.llvm.org
Thu Apr 4 05:25:58 PDT 2024
Author: Jacek Caban
Date: 2024-04-04T14:25:54+02:00
New Revision: ff56584ee9c8a6d5430c0ba461540ccb6696ebc6
URL: https://github.com/llvm/llvm-project/commit/ff56584ee9c8a6d5430c0ba461540ccb6696ebc6
DIFF: https://github.com/llvm/llvm-project/commit/ff56584ee9c8a6d5430c0ba461540ccb6696ebc6.diff
LOG: [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.
Added:
lld/test/COFF/print-search-paths-arm64.s
Modified:
lld/COFF/Driver.cpp
llvm/lib/WindowsDriver/MSVCPaths.cpp
Removed:
################################################################################
diff --git a/lld/COFF/Driver.cpp b/lld/COFF/Driver.cpp
index 2b1d4abb6ed0d6..ea37f8deecf03c 100644
--- a/lld/COFF/Driver.cpp
+++ b/lld/COFF/Driver.cpp
@@ -157,18 +157,7 @@ StringRef LinkerDriver::mangle(StringRef sym) {
}
llvm::Triple::ArchType LinkerDriver::getArch() {
- switch (ctx.config.machine) {
- case I386:
- return llvm::Triple::ArchType::x86;
- case AMD64:
- return llvm::Triple::ArchType::x86_64;
- case ARMNT:
- return llvm::Triple::ArchType::arm;
- case ARM64:
- return llvm::Triple::ArchType::aarch64;
- default:
- return llvm::Triple::ArchType::UnknownArch;
- }
+ return getMachineArchType(ctx.config.machine);
}
bool LinkerDriver::findUnderscoreMangle(StringRef sym) {
diff --git a/lld/test/COFF/print-search-paths-arm64.s b/lld/test/COFF/print-search-paths-arm64.s
new file mode 100644
index 00000000000000..fb5c8897a165dc
--- /dev/null
+++ b/lld/test/COFF/print-search-paths-arm64.s
@@ -0,0 +1,24 @@
+# REQUIRES: aarch64
+
+# RUN: llvm-mc -triple aarch64-windows-msvc %s -filetype=obj -o %t.aarch64.obj
+# RUN: lld-link -dll -noentry -winsysroot:%t.dir/sysroot -vctoolsversion:1.1.1.1 -winsdkversion:10.0.1 -libpath:custom-dir \
+# RUN: %t.aarch64.obj -print-search-paths | FileCheck -DSYSROOT=%t.dir %s
+
+# RUN: llvm-mc -triple arm64ec-windows-msvc %s -filetype=obj -o %t.arm64ec.obj
+# RUN: lld-link -dll -noentry -winsysroot:%t.dir/sysroot -vctoolsversion:1.1.1.1 -winsdkversion:10.0.1 -libpath:custom-dir \
+# RUN: %t.arm64ec.obj -print-search-paths -machine:arm64ec | FileCheck -DSYSROOT=%t.dir %s
+
+# CHECK: Library search paths:
+# CHECK-NEXT: (cwd)
+# CHECK-NEXT: custom-dir
+# CHECK-NEXT: [[CPATH:.*]]lib{{[/\\]}}clang{{[/\\]}}{{[0-9]+}}{{[/\\]}}lib{{[/\\]}}windows
+# CHECK-NEXT: [[CPATH]]lib{{[/\\]}}clang{{[/\\]}}{{[0-9]+}}{{[/\\]}}lib
+# CHECK-NEXT: [[CPATH]]lib
+# CHECK-NEXT: [[SYSROOT]]{{[/\\]}}sysroot{{[/\\]}}DIA SDK{{[/\\]}}lib{{[/\\]}}arm64
+# CHECK-NEXT: [[SYSROOT]]{{[/\\]}}sysroot{{[/\\]}}VC{{[/\\]}}Tools{{[/\\]}}MSVC{{[/\\]}}1.1.1.1{{[/\\]}}lib{{[/\\]}}arm64
+# CHECK-NEXT: [[SYSROOT]]{{[/\\]}}sysroot{{[/\\]}}VC{{[/\\]}}Tools{{[/\\]}}MSVC{{[/\\]}}1.1.1.1{{[/\\]}}atlmfc{{[/\\]}}lib{{[/\\]}}arm64
+# CHECK-NEXT: [[SYSROOT]]{{[/\\]}}sysroot{{[/\\]}}Windows Kits{{[/\\]}}10{{[/\\]}}Lib{{[/\\]}}10.0.1{{[/\\]}}ucrt{{[/\\]}}arm64
+# CHECK-NEXT: [[SYSROOT]]{{[/\\]}}sysroot{{[/\\]}}Windows Kits{{[/\\]}}10{{[/\\]}}Lib{{[/\\]}}10.0.1{{[/\\]}}um{{[/\\]}}arm64
+
+ .data
+ .word 1
diff --git a/llvm/lib/WindowsDriver/MSVCPaths.cpp b/llvm/lib/WindowsDriver/MSVCPaths.cpp
index 634cfcb15f1d95..a7bffbb20eba1a 100644
--- a/llvm/lib/WindowsDriver/MSVCPaths.cpp
+++ b/llvm/lib/WindowsDriver/MSVCPaths.cpp
@@ -268,6 +268,7 @@ const char *archToWindowsSDKArch(Triple::ArchType Arch) {
case Triple::ArchType::x86_64:
return "x64";
case Triple::ArchType::arm:
+ case Triple::ArchType::thumb:
return "arm";
case Triple::ArchType::aarch64:
return "arm64";
@@ -285,6 +286,7 @@ const char *archToLegacyVCArch(Triple::ArchType Arch) {
case Triple::ArchType::x86_64:
return "amd64";
case Triple::ArchType::arm:
+ case Triple::ArchType::thumb:
return "arm";
case Triple::ArchType::aarch64:
return "arm64";
@@ -300,6 +302,7 @@ const char *archToDevDivInternalArch(Triple::ArchType Arch) {
case Triple::ArchType::x86_64:
return "amd64";
case Triple::ArchType::arm:
+ case Triple::ArchType::thumb:
return "arm";
case Triple::ArchType::aarch64:
return "arm64";
@@ -321,6 +324,7 @@ bool appendArchToWindowsSDKLibPath(int SDKMajor, SmallString<128> LibPath,
sys::path::append(LibPath, "x64");
break;
case Triple::arm:
+ case Triple::thumb:
// It is not necessary to link against Windows SDK 7.x when targeting ARM.
return false;
default:
More information about the llvm-commits
mailing list