diff --git a/compiler/rustc_codegen_ssa/src/back/archive.rs b/compiler/rustc_codegen_ssa/src/back/archive.rs index f673675bdbb70..ae649cd77c420 100644 --- a/compiler/rustc_codegen_ssa/src/back/archive.rs +++ b/compiler/rustc_codegen_ssa/src/back/archive.rs @@ -292,7 +292,7 @@ impl<'a> ArArchiveBuilder<'a> { &entries, archive_kind, false, - self.sess.target.arch == "arm64ec", + /* is_ec = */ self.sess.target.arch == "arm64ec", )?; let any_entries = !entries.is_empty(); diff --git a/compiler/rustc_llvm/llvm-wrapper/SymbolWrapper.cpp b/compiler/rustc_llvm/llvm-wrapper/SymbolWrapper.cpp index acd767f287b20..e8b9995fd59db 100644 --- a/compiler/rustc_llvm/llvm-wrapper/SymbolWrapper.cpp +++ b/compiler/rustc_llvm/llvm-wrapper/SymbolWrapper.cpp @@ -38,6 +38,7 @@ static bool isArchiveSymbol(const object::BasicSymbolRef &S) { typedef void *(*LLVMRustGetSymbolsCallback)(void *, const char *); typedef void *(*LLVMRustGetSymbolsErrorCallback)(const char *); +// This function is copied from ArchiveWriter.cpp. static Expected> getSymbolicFile(MemoryBufferRef Buf, LLVMContext &Context) { const file_magic Type = identify_magic(Buf.getBuffer()); @@ -112,6 +113,8 @@ extern "C" bool LLVMRustIs64BitSymbolicFile(char *BufPtr, size_t BufLen) { SmallString<0> SymNameBuf; auto SymName = raw_svector_ostream(SymNameBuf); + // Code starting from this line is copied from s64BitSymbolicFile in + // ArchiveWriter.cpp. // In the scenario when LLVMContext is populated SymbolicFile will contain a // reference to it, thus SymbolicFile should be destroyed first. LLVMContext Context; @@ -145,6 +148,9 @@ extern "C" bool LLVMRustIsECObject(char *BufPtr, size_t BufLen) { return false; } + + // Code starting from this line is copied from isECObject in + // ArchiveWriter.cpp with an extra #if to work with LLVM 17. if (Obj->isCOFF()) return cast(&*Obj)->getMachine() != COFF::IMAGE_FILE_MACHINE_ARM64;