@@ -862,7 +862,7 @@ pub(crate) fn codegen(
862862 . generic_activity_with_arg ( "LLVM_module_codegen_embed_bitcode" , & * module. name ) ;
863863 let thin_bc =
864864 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) ;
866866 }
867867 }
868868
@@ -1058,7 +1058,6 @@ fn embed_bitcode(
10581058 cgcx : & CodegenContext < LlvmCodegenBackend > ,
10591059 llcx : & llvm:: Context ,
10601060 llmod : & llvm:: Module ,
1061- cmdline : & str ,
10621061 bitcode : & [ u8 ] ,
10631062) {
10641063 // We're adding custom sections to the output object file, but we definitely
@@ -1074,7 +1073,9 @@ fn embed_bitcode(
10741073 // * Mach-O - this is for macOS. Inspecting the source code for the native
10751074 // linker here shows that the `.llvmbc` and `.llvmcmd` sections are
10761075 // 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.
10781079 //
10791080 // * Wasm - the native LLD linker is hard-coded to skip `.llvmbc` and
10801081 // `.llvmcmd` sections, so there's nothing extra we need to do.
@@ -1111,7 +1112,7 @@ fn embed_bitcode(
11111112 llvm:: set_linkage ( llglobal, llvm:: Linkage :: PrivateLinkage ) ;
11121113 llvm:: LLVMSetGlobalConstant ( llglobal, llvm:: True ) ;
11131114
1114- let llconst = common:: bytes_in_context ( llcx, cmdline . as_bytes ( ) ) ;
1115+ let llconst = common:: bytes_in_context ( llcx, & [ ] ) ;
11151116 let llglobal = llvm:: add_global ( llmod, common:: val_ty ( llconst) , c"rustc.embedded.cmdline" ) ;
11161117 llvm:: set_initializer ( llglobal, llconst) ;
11171118 let section = if cgcx. target_is_like_darwin {
@@ -1128,7 +1129,7 @@ fn embed_bitcode(
11281129 let section_flags = if cgcx. is_pe_coff { "n" } else { "e" } ;
11291130 let asm = create_section_with_flags_asm ( ".llvmbc" , section_flags, bitcode) ;
11301131 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, & [ ] ) ;
11321133 llvm:: append_module_inline_asm ( llmod, & asm) ;
11331134 }
11341135}
0 commit comments