@@ -862,7 +862,7 @@ pub(crate) fn codegen(
862
862
. generic_activity_with_arg ( "LLVM_module_codegen_embed_bitcode" , & * module. name ) ;
863
863
let thin_bc =
864
864
module. thin_lto_buffer . as_deref ( ) . expect ( "cannot find embedded bitcode" ) ;
865
- embed_bitcode ( cgcx, llcx, llmod, & config . bc_cmdline , & thin_bc) ;
865
+ embed_bitcode ( cgcx, llcx, llmod, & thin_bc) ;
866
866
}
867
867
}
868
868
@@ -1058,7 +1058,6 @@ fn embed_bitcode(
1058
1058
cgcx : & CodegenContext < LlvmCodegenBackend > ,
1059
1059
llcx : & llvm:: Context ,
1060
1060
llmod : & llvm:: Module ,
1061
- cmdline : & str ,
1062
1061
bitcode : & [ u8 ] ,
1063
1062
) {
1064
1063
// We're adding custom sections to the output object file, but we definitely
@@ -1074,7 +1073,9 @@ fn embed_bitcode(
1074
1073
// * Mach-O - this is for macOS. Inspecting the source code for the native
1075
1074
// linker here shows that the `.llvmbc` and `.llvmcmd` sections are
1076
1075
// automatically skipped by the linker. In that case there's nothing extra
1077
- // that we need to do here.
1076
+ // that we need to do here. We do need to make sure that the
1077
+ // `__LLVM,__cmdline` section exists even though it is empty as otherwise
1078
+ // ld64 rejects the object file.
1078
1079
//
1079
1080
// * Wasm - the native LLD linker is hard-coded to skip `.llvmbc` and
1080
1081
// `.llvmcmd` sections, so there's nothing extra we need to do.
@@ -1111,7 +1112,7 @@ fn embed_bitcode(
1111
1112
llvm:: set_linkage ( llglobal, llvm:: Linkage :: PrivateLinkage ) ;
1112
1113
llvm:: LLVMSetGlobalConstant ( llglobal, llvm:: True ) ;
1113
1114
1114
- let llconst = common:: bytes_in_context ( llcx, cmdline . as_bytes ( ) ) ;
1115
+ let llconst = common:: bytes_in_context ( llcx, & [ ] ) ;
1115
1116
let llglobal = llvm:: add_global ( llmod, common:: val_ty ( llconst) , c"rustc.embedded.cmdline" ) ;
1116
1117
llvm:: set_initializer ( llglobal, llconst) ;
1117
1118
let section = if cgcx. target_is_like_darwin {
@@ -1128,7 +1129,7 @@ fn embed_bitcode(
1128
1129
let section_flags = if cgcx. is_pe_coff { "n" } else { "e" } ;
1129
1130
let asm = create_section_with_flags_asm ( ".llvmbc" , section_flags, bitcode) ;
1130
1131
llvm:: append_module_inline_asm ( llmod, & asm) ;
1131
- let asm = create_section_with_flags_asm ( ".llvmcmd" , section_flags, cmdline . as_bytes ( ) ) ;
1132
+ let asm = create_section_with_flags_asm ( ".llvmcmd" , section_flags, & [ ] ) ;
1132
1133
llvm:: append_module_inline_asm ( llmod, & asm) ;
1133
1134
}
1134
1135
}
0 commit comments