Skip to content

Commit

Permalink
Fix review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
bjorn3 committed Jul 7, 2024
1 parent 72223e2 commit cd3f2f6
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion compiler/rustc_codegen_ssa/src/back/archive.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
5 changes: 5 additions & 0 deletions compiler/rustc_llvm/llvm-wrapper/SymbolWrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<std::unique_ptr<SymbolicFile>>
getSymbolicFile(MemoryBufferRef Buf, LLVMContext &Context) {
const file_magic Type = identify_magic(Buf.getBuffer());
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -145,6 +148,8 @@ 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<llvm::object::COFFObjectFile>(&*Obj)->getMachine() !=
COFF::IMAGE_FILE_MACHINE_ARM64;
Expand Down

0 comments on commit cd3f2f6

Please sign in to comment.