[llvm-lib] Add support for -defArm64Native argument. (#81426)
This can be used to create import libraries that contain both ARM64EC
and native exports. The implementation follows observed MSVC lib.exe
behaviour. It's ignored on targets other than ARM64EC.
GitOrigin-RevId: a38152e2156a467520dae29fa3760802c308d54c
diff --git a/COFF/Driver.cpp b/COFF/Driver.cpp
index 22ee2f1..091aa0d 100644
--- a/COFF/Driver.cpp
+++ b/COFF/Driver.cpp
@@ -939,7 +939,7 @@
void LinkerDriver::createImportLibrary(bool asLib) {
llvm::TimeTraceScope timeScope("Create import library");
- std::vector<COFFShortExport> exports;
+ std::vector<COFFShortExport> exports, nativeExports;
for (Export &e1 : ctx.config.exports) {
COFFShortExport e2;
e2.Name = std::string(e1.name);
@@ -958,8 +958,8 @@
std::string path = getImplibPath();
if (!ctx.config.incremental) {
- checkError(writeImportLibrary(libName, path, exports, ctx.config.machine,
- ctx.config.mingw));
+ checkError(writeImportLibrary(libName, path, exports, nativeExports,
+ ctx.config.machine, ctx.config.mingw));
return;
}
@@ -968,8 +968,8 @@
ErrorOr<std::unique_ptr<MemoryBuffer>> oldBuf = MemoryBuffer::getFile(
path, /*IsText=*/false, /*RequiresNullTerminator=*/false);
if (!oldBuf) {
- checkError(writeImportLibrary(libName, path, exports, ctx.config.machine,
- ctx.config.mingw));
+ checkError(writeImportLibrary(libName, path, exports, nativeExports,
+ ctx.config.machine, ctx.config.mingw));
return;
}
@@ -979,7 +979,7 @@
fatal("cannot create temporary file for import library " + path + ": " +
ec.message());
- if (Error e = writeImportLibrary(libName, tmpName, exports,
+ if (Error e = writeImportLibrary(libName, tmpName, exports, nativeExports,
ctx.config.machine, ctx.config.mingw)) {
checkError(std::move(e));
return;