Skip to content

[llvm-lib] Use ARM64EC machine type for import libraries when -machine:arm64x is used. #85972

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions llvm/lib/Object/COFFImportFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -626,8 +626,11 @@ Error writeImportLibrary(StringRef ImportName, StringRef Path,
MachineTypes Machine, bool MinGW,
ArrayRef<COFFShortExport> NativeExports) {

MachineTypes NativeMachine =
isArm64EC(Machine) ? IMAGE_FILE_MACHINE_ARM64 : Machine;
MachineTypes NativeMachine = Machine;
if (isArm64EC(Machine)) {
NativeMachine = IMAGE_FILE_MACHINE_ARM64;
Machine = IMAGE_FILE_MACHINE_ARM64EC;
}

std::vector<NewArchiveMember> Members;
ObjectFactory OF(llvm::sys::path::filename(ImportName), NativeMachine);
Expand Down
13 changes: 10 additions & 3 deletions llvm/test/tools/llvm-lib/arm64ec-implib.test
Original file line number Diff line number Diff line change
Expand Up @@ -34,17 +34,17 @@ ARMAP-NEXT: test_NULL_THUNK_DATA in test.dll

RUN: llvm-readobj test.lib | FileCheck -check-prefix=READOBJ %s

READOBJ: File: test.lib(test.dll)
READOBJ: File: test{{.*}}.lib(test.dll)
READOBJ-NEXT: Format: COFF-ARM64{{$}}
READOBJ-NEXT: Arch: aarch64
READOBJ-NEXT: AddressSize: 64bit
READOBJ-EMPTY:
READOBJ-NEXT: File: test.lib(test.dll)
READOBJ-NEXT: File: test{{.*}}.lib(test.dll)
READOBJ-NEXT: Format: COFF-ARM64{{$}}
READOBJ-NEXT: Arch: aarch64
READOBJ-NEXT: AddressSize: 64bit
READOBJ-EMPTY:
READOBJ-NEXT: File: test.lib(test.dll)
READOBJ-NEXT: File: test{{.*}}.lib(test.dll)
READOBJ-NEXT: Format: COFF-ARM64{{$}}
READOBJ-NEXT: Arch: aarch64
READOBJ-NEXT: AddressSize: 64bit
Expand Down Expand Up @@ -96,6 +96,11 @@ READOBJ-NEXT: Name type: name
READOBJ-NEXT: Export name: dataexp
READOBJ-NEXT: Symbol: __imp_dataexp

Using -machine:arm64x gives the same output.
RUN: llvm-lib -machine:arm64x -def:test.def -out:testx.lib
RUN: llvm-nm --print-armap testx.lib | FileCheck -check-prefix=ARMAP %s
RUN: llvm-readobj testx.lib | FileCheck -check-prefix=READOBJ %s

Creating a new lib containing the existing lib:
RUN: llvm-lib -machine:arm64ec test.lib -out:test2.lib
RUN: llvm-nm --print-armap test2.lib | FileCheck -check-prefix=ARMAP %s
Expand Down Expand Up @@ -246,7 +251,9 @@ READOBJX-NEXT: Symbol: __imp_dataexp


RUN: llvm-lib -machine:arm64ec -def:test.def -defArm64Native:test2.def -out:test2.lib
RUN: llvm-lib -machine:arm64ec -def:test.def -defArm64Native:test2.def -out:test2x.lib
RUN: llvm-nm --print-armap test2.lib | FileCheck -check-prefix=ARMAPX2 %s
RUN: llvm-nm --print-armap test2x.lib | FileCheck -check-prefix=ARMAPX2 %s

ARMAPX2: Archive map
ARMAPX2-NEXT: __IMPORT_DESCRIPTOR_test2 in test2.dll
Expand Down