@@ -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,40 +1058,38 @@ 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
1065
1064
// 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.
1070
1069
//
1071
1070
// To handle this is a bit different depending on the object file format
1072
1071
// used by the backend, broken down into a few different categories:
1073
1072
//
1074
1073
// * 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.
1078
1077
//
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.
1081
1080
//
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`.
1086
1084
//
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`.
1092
1090
//
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 .
1095
1093
//
1096
1094
// Unfortunately, LLVM provides no way to set custom section flags. For ELF
1097
1095
// and COFF we emit the sections using module level inline assembly for that
@@ -1110,26 +1108,11 @@ fn embed_bitcode(
1110
1108
llvm:: set_section ( llglobal, bitcode_section_name ( cgcx) ) ;
1111
1109
llvm:: set_linkage ( llglobal, llvm:: Linkage :: PrivateLinkage ) ;
1112
1110
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 ) ;
1126
1111
} else {
1127
1112
// We need custom section flags, so emit module-level inline assembly.
1128
1113
let section_flags = if cgcx. is_pe_coff { "n" } else { "e" } ;
1129
1114
let asm = create_section_with_flags_asm ( ".llvmbc" , section_flags, bitcode) ;
1130
1115
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) ;
1133
1116
}
1134
1117
}
1135
1118
0 commit comments