From 9ad0396a34bdfa11fe0e4f8636f82da165ffad01 Mon Sep 17 00:00:00 2001 From: Augie Fackler Date: Thu, 7 Sep 2023 11:56:25 -0400 Subject: lto: handle Apple platforms correctly by eliding __LLVM, from section name --- compiler/rustc_codegen_llvm/src/back/lto.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'compiler/rustc_codegen_llvm/src/back') diff --git a/compiler/rustc_codegen_llvm/src/back/lto.rs b/compiler/rustc_codegen_llvm/src/back/lto.rs index 3964039ac2d..5cf83b1accb 100644 --- a/compiler/rustc_codegen_llvm/src/back/lto.rs +++ b/compiler/rustc_codegen_llvm/src/back/lto.rs @@ -154,7 +154,10 @@ fn get_bitcode_slice_from_object_data<'a>( if obj.starts_with(b"\xDE\xC0\x17\x0B") || obj.starts_with(b"BC\xC0\xDE") { return Ok(obj); } - let section_name = bitcode_section_name(cgcx); + // We drop the "__LLVM," prefix here because on Apple platforms there's a notion of "segment name" + // which in the public API for sections gets treated as part of the section name, but internally + // in MachOObjectFile.cpp gets treated separately. + let section_name = bitcode_section_name(cgcx).trim_start_matches("__LLVM,"); let mut len = 0; let data = unsafe { llvm::LLVMRustGetSliceFromObjectDataByName( -- cgit 1.4.1-3-g733a5