Skip to content

Commit 9de0d14

Browse files
committed
Unconditionally use the LLVM symbol reader
This may fix a linker error on MSVC
1 parent 2217014 commit 9de0d14

File tree

1 file changed

+0
-22
lines changed

1 file changed

+0
-22
lines changed

compiler/rustc_codegen_llvm/src/back/archive.rs

-22
Original file line numberDiff line numberDiff line change
@@ -200,25 +200,11 @@ static LLVM_OBJECT_READER: ObjectReader = ObjectReader {
200200
get_xcoff_member_alignment: DEFAULT_OBJECT_READER.get_xcoff_member_alignment,
201201
};
202202

203-
fn should_use_llvm_reader(buf: &[u8]) -> bool {
204-
let is_bitcode = unsafe { llvm::LLVMRustIsBitcode(buf.as_ptr(), buf.len()) };
205-
206-
// COFF bigobj file, msvc LTO file or import library. See
207-
// https://github.com/llvm/llvm-project/blob/453f27bc9/llvm/lib/BinaryFormat/Magic.cpp#L38-L51
208-
let is_unsupported_windows_obj_file = buf.get(0..4) == Some(b"\0\0\xFF\xFF");
209-
210-
is_bitcode || is_unsupported_windows_obj_file
211-
}
212-
213203
#[deny(unsafe_op_in_unsafe_fn)]
214204
fn get_llvm_object_symbols(
215205
buf: &[u8],
216206
f: &mut dyn FnMut(&[u8]) -> io::Result<()>,
217207
) -> io::Result<bool> {
218-
if !should_use_llvm_reader(buf) {
219-
return (DEFAULT_OBJECT_READER.get_symbols)(buf, f);
220-
}
221-
222208
let mut state = Box::new(f);
223209

224210
let err = unsafe {
@@ -255,18 +241,10 @@ fn get_llvm_object_symbols(
255241
}
256242

257243
fn llvm_is_64_bit_object_file(buf: &[u8]) -> bool {
258-
if !should_use_llvm_reader(buf) {
259-
return (DEFAULT_OBJECT_READER.is_64_bit_object_file)(buf);
260-
}
261-
262244
unsafe { llvm::LLVMRustIs64BitSymbolicFile(buf.as_ptr(), buf.len()) }
263245
}
264246

265247
fn llvm_is_ec_object_file(buf: &[u8]) -> bool {
266-
if !should_use_llvm_reader(buf) {
267-
return (DEFAULT_OBJECT_READER.is_ec_object_file)(buf);
268-
}
269-
270248
unsafe { llvm::LLVMRustIsECObject(buf.as_ptr(), buf.len()) }
271249
}
272250

0 commit comments

Comments
 (0)