Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 0e3d395

Browse files
Update to ar_archive_writer 0.5.0
1 parent 6ba0ce4 commit 0e3d395

File tree

6 files changed

+68
-45
lines changed

6 files changed

+68
-45
lines changed

‎Cargo.lock

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -158,11 +158,11 @@ checksum = "e16d2d3311acee920a9eb8d33b8cbc1787ce4a264e85f964c2404b969bdcd487"
158158

159159
[[package]]
160160
name = "ar_archive_writer"
161-
version = "0.4.2"
161+
version = "0.5.0"
162162
source = "registry+https://github.com/rust-lang/crates.io-index"
163-
checksum = "01667f6f40216b9a0b2945e05fed5f1ad0ab6470e69cb9378001e37b1c0668e4"
163+
checksum = "3219abbb81fdcb1a976d794ea40cd8567b67c4e8f93bdcd077a40a0905f133e8"
164164
dependencies = [
165-
"object 0.36.7",
165+
"object 0.37.2",
166166
]
167167

168168
[[package]]

‎compiler/rustc_codegen_llvm/src/back/archive.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ static LLVM_OBJECT_READER: ObjectReader = ObjectReader {
2626
get_symbols: get_llvm_object_symbols,
2727
is_64_bit_object_file: llvm_is_64_bit_object_file,
2828
is_ec_object_file: llvm_is_ec_object_file,
29+
is_any_arm64_coff: llvm_is_any_arm64_coff,
2930
get_xcoff_member_alignment: DEFAULT_OBJECT_READER.get_xcoff_member_alignment,
3031
};
3132

@@ -95,3 +96,7 @@ fn llvm_is_64_bit_object_file(buf: &[u8]) -> bool {
9596
fn llvm_is_ec_object_file(buf: &[u8]) -> bool {
9697
unsafe { llvm::LLVMRustIsECObject(buf.as_ptr(), buf.len()) }
9798
}
99+
100+
fn llvm_is_any_arm64_coff(buf: &[u8]) -> bool {
101+
unsafe { llvm::LLVMRustIsAnyArm64Coff(buf.as_ptr(), buf.len()) }
102+
}

‎compiler/rustc_codegen_llvm/src/llvm/ffi.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2632,6 +2632,8 @@ unsafe extern "C" {
26322632

26332633
pub(crate) fn LLVMRustIsECObject(buf_ptr: *const u8, buf_len: usize) -> bool;
26342634

2635+
pub(crate) fn LLVMRustIsAnyArm64Coff(buf_ptr: *const u8, buf_len: usize) -> bool;
2636+
26352637
pub(crate) fn LLVMRustSetNoSanitizeAddress(Global: &Value);
26362638
pub(crate) fn LLVMRustSetNoSanitizeHWAddress(Global: &Value);
26372639
}

‎compiler/rustc_codegen_ssa/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ edition = "2024"
55

66
[dependencies]
77
# tidy-alphabetical-start
8-
ar_archive_writer = "0.4.2"
8+
ar_archive_writer = "0.5"
99
bitflags = "2.4.1"
1010
bstr = "1.11.3"
1111
# `cc` updates often break things, so we pin it here. Cargo enforces "max 1 semver-compat version

‎compiler/rustc_codegen_ssa/src/back/archive.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,8 @@ impl From<ImportLibraryItem> for COFFShortExport {
4646
name: item.name,
4747
ext_name: None,
4848
symbol_name: item.symbol_name,
49-
alias_target: None,
49+
import_name: None,
50+
export_as: None,
5051
ordinal: item.ordinal.unwrap_or(0),
5152
noname: item.ordinal.is_some(),
5253
data: item.is_data,
@@ -134,6 +135,7 @@ pub trait ArchiveBuilderBuilder {
134135
// when linking a rust staticlib using `/WHOLEARCHIVE`.
135136
// See #129020
136137
true,
138+
&[],
137139
) {
138140
sess.dcx()
139141
.emit_fatal(ErrorCreatingImportLibrary { lib_name, error: error.to_string() });
@@ -527,7 +529,7 @@ impl<'a> ArArchiveBuilder<'a> {
527529
&entries,
528530
archive_kind,
529531
false,
530-
/* is_ec = */ self.sess.target.arch == "arm64ec",
532+
/* is_ec = */ Some(self.sess.target.arch == "arm64ec"),
531533
)?;
532534
archive_tmpfile.flush()?;
533535
drop(archive_tmpfile);

‎compiler/rustc_llvm/llvm-wrapper/SymbolWrapper.cpp

Lines changed: 53 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -103,14 +103,14 @@ LLVMRustGetSymbols(char *BufPtr, size_t BufLen, void *State,
103103
#define TRUE_PTR (void *)1
104104
#define FALSE_PTR (void *)0
105105

106-
extern "C" bool LLVMRustIs64BitSymbolicFile(char *BufPtr, size_t BufLen) {
106+
bool
107+
withBufferAsSymbolicFile(char *BufPtr, size_t BufLen,
108+
std::function<bool(object::SymbolicFile&)> Callback) {
107109
std::unique_ptr<MemoryBuffer> Buf = MemoryBuffer::getMemBuffer(
108110
StringRef(BufPtr, BufLen), StringRef("LLVMRustGetSymbolsObject"), false);
109111
SmallString<0> SymNameBuf;
110112
auto SymName = raw_svector_ostream(SymNameBuf);
111113

112-
// Code starting from this line is copied from s64BitSymbolicFile in
113-
// ArchiveWriter.cpp.
114114
// In the scenario when LLVMContext is populated SymbolicFile will contain a
115115
// reference to it, thus SymbolicFile should be destroyed first.
116116
LLVMContext Context;
@@ -120,48 +120,62 @@ extern "C" bool LLVMRustIs64BitSymbolicFile(char *BufPtr, size_t BufLen) {
120120
return false;
121121
}
122122
std::unique_ptr<object::SymbolicFile> Obj = std::move(*ObjOrErr);
123+
if (Obj == nullptr) {
124+
return false;
125+
}
126+
return Callback(*Obj);
127+
}
123128

124-
return Obj != nullptr ? Obj->is64Bit() : false;
129+
extern "C" bool LLVMRustIs64BitSymbolicFile(char *BufPtr, size_t BufLen) {
130+
return withBufferAsSymbolicFile(BufPtr, BufLen, [](object::SymbolicFile &Obj) {
131+
return Obj.is64Bit();
132+
});
125133
}
126134

127135
extern "C" bool LLVMRustIsECObject(char *BufPtr, size_t BufLen) {
128-
std::unique_ptr<MemoryBuffer> Buf = MemoryBuffer::getMemBuffer(
129-
StringRef(BufPtr, BufLen), StringRef("LLVMRustGetSymbolsObject"), false);
130-
SmallString<0> SymNameBuf;
131-
auto SymName = raw_svector_ostream(SymNameBuf);
132-
133-
// In the scenario when LLVMContext is populated SymbolicFile will contain a
134-
// reference to it, thus SymbolicFile should be destroyed first.
135-
LLVMContext Context;
136-
Expected<std::unique_ptr<object::SymbolicFile>> ObjOrErr =
137-
getSymbolicFile(Buf->getMemBufferRef(), Context);
138-
if (!ObjOrErr) {
139-
return false;
140-
}
141-
std::unique_ptr<object::SymbolicFile> Obj = std::move(*ObjOrErr);
136+
return withBufferAsSymbolicFile(BufPtr, BufLen, [](object::SymbolicFile &Obj) {
137+
// Code starting from this line is copied from isECObject in
138+
// ArchiveWriter.cpp with an extra #if to work with LLVM 17.
139+
if (Obj.isCOFF())
140+
return cast<llvm::object::COFFObjectFile>(&Obj)->getMachine() !=
141+
COFF::IMAGE_FILE_MACHINE_ARM64;
142+
143+
if (Obj.isCOFFImportFile())
144+
return cast<llvm::object::COFFImportFile>(&Obj)->getMachine() !=
145+
COFF::IMAGE_FILE_MACHINE_ARM64;
146+
147+
if (Obj.isIR()) {
148+
Expected<std::string> TripleStr =
149+
getBitcodeTargetTriple(Obj.getMemoryBufferRef());
150+
if (!TripleStr)
151+
return false;
152+
Triple T(*TripleStr);
153+
return T.isWindowsArm64EC() || T.getArch() == Triple::x86_64;
154+
}
142155

143-
if (Obj == nullptr) {
144156
return false;
145-
}
157+
});
158+
}
146159

147-
// Code starting from this line is copied from isECObject in
148-
// ArchiveWriter.cpp with an extra #if to work with LLVM 17.
149-
if (Obj->isCOFF())
150-
return cast<llvm::object::COFFObjectFile>(&*Obj)->getMachine() !=
151-
COFF::IMAGE_FILE_MACHINE_ARM64;
152-
153-
if (Obj->isCOFFImportFile())
154-
return cast<llvm::object::COFFImportFile>(&*Obj)->getMachine() !=
155-
COFF::IMAGE_FILE_MACHINE_ARM64;
156-
157-
if (Obj->isIR()) {
158-
Expected<std::string> TripleStr =
159-
getBitcodeTargetTriple(Obj->getMemoryBufferRef());
160-
if (!TripleStr)
161-
return false;
162-
Triple T(*TripleStr);
163-
return T.isWindowsArm64EC() || T.getArch() == Triple::x86_64;
164-
}
160+
extern"C"boolLLVMRustIsAnyArm64Coff(char *BufPtr, size_t BufLen) {
161+
returnwithBufferAsSymbolicFile(BufPtr, BufLen, [](object::SymbolicFile &Obj) {
162+
// Code starting from this line is copied from isAnyArm64COFF in
163+
// ArchiveWriter.cpp.
164+
if (Obj.isCOFF())
165+
returnCOFF::isAnyArm64(cast<COFFObjectFile>(&Obj)->getMachine());
166+
167+
if (Obj.isCOFFImportFile())
168+
returnCOFF::isAnyArm64(cast<COFFImportFile>(&Obj)->getMachine());
169+
170+
if (Obj.isIR()) {
171+
Expected<std::string> TripleStr =
172+
getBitcodeTargetTriple(Obj.getMemoryBufferRef());
173+
if (!TripleStr)
174+
return false;
175+
Triple T(*TripleStr);
176+
return T.isOSWindows() && T.getArch() == Triple::aarch64;
177+
}
165178

166-
return false;
179+
return false;
180+
});
167181
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /