@@ -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,40 +1058,38 @@ 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
10651064 // do not want these custom sections to make their way into the final linked
1066- // executable. The purpose of these custom sections is for tooling
1067- // surrounding object files to work with the LLVM IR, if necessary. For
1068- // example rustc's own LTO will look for LLVM IR inside of the object file
1069- // in these sections by default.
1065+ // executable. The purpose of this custom section is for tooling surrounding
1066+ // object files to work with the LLVM IR, if necessary. For example rustc's
1067+ // own LTO will look for LLVM IR inside of the object file in this section
1068+ // by default.
10701069 //
10711070 // To handle this is a bit different depending on the object file format
10721071 // used by the backend, broken down into a few different categories:
10731072 //
10741073 // * Mach-O - this is for macOS. Inspecting the source code for the native
1075- // linker here shows that the `.llvmbc` and `.llvmcmd` sections are
1076- // automatically skipped by the linker. In that case there's nothing extra
1077- // that we need to do here.
1074+ // linker here shows that the `.llvmbc` section is automatically skipped
1075+ // by the linker. In that case there's nothing extra that we need to do
1076+ // here.
10781077 //
1079- // * Wasm - the native LLD linker is hard-coded to skip `.llvmbc` and
1080- // `.llvmcmd` sections, so there's nothing extra we need to do.
1078+ // * Wasm - the native LLD linker is hard-coded to skip `.llvmbc` section,
1079+ // so there's nothing extra we need to do.
10811080 //
1082- // * COFF - if we don't do anything the linker will by default copy all
1083- // these sections to the output artifact, not what we want! To subvert
1084- // this we want to flag the sections we inserted here as
1085- // `IMAGE_SCN_LNK_REMOVE`.
1081+ // * COFF - if we don't do anything the linker will by default copy this
1082+ // section to the output artifact, not what we want! To subvert this we
1083+ // want to flag the section we inserted here as `IMAGE_SCN_LNK_REMOVE`.
10861084 //
1087- // * ELF - this is very similar to COFF above. One difference is that these
1088- // sections are removed from the output linked artifact when
1089- // `--gc-sections` is passed, which we pass by default. If that flag isn't
1090- // passed though then these sections will show up in the final output.
1091- // Additionally the flag that we need to set here is `SHF_EXCLUDE`.
1085+ // * ELF - this is very similar to COFF above. One difference is that this
1086+ // section is removed from the output linked artifact when `--gc-sections`
1087+ // is passed, which we pass by default. If that flag isn't passed through
1088+ // then this section will show up in the final output. Additionally the
1089+ // flag that we need to set here is `SHF_EXCLUDE`.
10921090 //
1093- // * XCOFF - AIX linker ignores content in .ipa and .info if no auxiliary
1094- // symbol associated with these sections .
1091+ // * XCOFF - AIX linker ignores content in .ipa if no auxiliary symbol
1092+ // associated with this section .
10951093 //
10961094 // Unfortunately, LLVM provides no way to set custom section flags. For ELF
10971095 // and COFF we emit the sections using module level inline assembly for that
@@ -1110,26 +1108,11 @@ fn embed_bitcode(
11101108 llvm:: set_section ( llglobal, bitcode_section_name ( cgcx) ) ;
11111109 llvm:: set_linkage ( llglobal, llvm:: Linkage :: PrivateLinkage ) ;
11121110 llvm:: LLVMSetGlobalConstant ( llglobal, llvm:: True ) ;
1113-
1114- let llconst = common:: bytes_in_context ( llcx, cmdline. as_bytes ( ) ) ;
1115- let llglobal = llvm:: add_global ( llmod, common:: val_ty ( llconst) , c"rustc.embedded.cmdline" ) ;
1116- llvm:: set_initializer ( llglobal, llconst) ;
1117- let section = if cgcx. target_is_like_darwin {
1118- c"__LLVM,__cmdline"
1119- } else if cgcx. target_is_like_aix {
1120- c".info"
1121- } else {
1122- c".llvmcmd"
1123- } ;
1124- llvm:: set_section ( llglobal, section) ;
1125- llvm:: set_linkage ( llglobal, llvm:: Linkage :: PrivateLinkage ) ;
11261111 } else {
11271112 // We need custom section flags, so emit module-level inline assembly.
11281113 let section_flags = if cgcx. is_pe_coff { "n" } else { "e" } ;
11291114 let asm = create_section_with_flags_asm ( ".llvmbc" , section_flags, bitcode) ;
11301115 llvm:: append_module_inline_asm ( llmod, & asm) ;
1131- let asm = create_section_with_flags_asm ( ".llvmcmd" , section_flags, cmdline. as_bytes ( ) ) ;
1132- llvm:: append_module_inline_asm ( llmod, & asm) ;
11331116 }
11341117}
11351118
0 commit comments