Skip to content

Commit 6fbea4f

Browse files
committed
Remove bitcode_llvm_cmdline
It used to be necessary on Apple platforms to ship with the App Store, but XCode 15 has stopped embedding LLVM bitcode and the App Store no longer accepts apps with bitcode embedded.
1 parent ee38bc0 commit 6fbea4f

File tree

4 files changed

+20
-45
lines changed

4 files changed

+20
-45
lines changed

compiler/rustc_codegen_llvm/src/back/write.rs

Lines changed: 20 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -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

compiler/rustc_codegen_ssa/src/back/write.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,6 @@ pub struct ModuleConfig {
9999
pub emit_obj: EmitObj,
100100
pub emit_thin_lto: bool,
101101
pub emit_thin_lto_summary: bool,
102-
pub bc_cmdline: String,
103102

104103
// Miscellaneous flags. These are mostly copied from command-line
105104
// options.
@@ -216,7 +215,6 @@ impl ModuleConfig {
216215
sess.opts.output_types.contains_key(&OutputType::ThinLinkBitcode),
217216
false
218217
),
219-
bc_cmdline: sess.target.bitcode_llvm_cmdline.to_string(),
220218

221219
verify_llvm_ir: sess.verify_llvm_ir(),
222220
lint_llvm_ir: sess.opts.unstable_opts.lint_llvm_ir,

compiler/rustc_target/src/spec/json.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,6 @@ impl Target {
167167
forward!(main_needs_argc_argv);
168168
forward!(has_thread_local);
169169
forward!(obj_is_bitcode);
170-
forward!(bitcode_llvm_cmdline);
171170
forward_opt!(max_atomic_width);
172171
forward_opt!(min_atomic_width);
173172
forward!(atomic_cas);
@@ -359,7 +358,6 @@ impl ToJson for Target {
359358
target_option_val!(main_needs_argc_argv);
360359
target_option_val!(has_thread_local);
361360
target_option_val!(obj_is_bitcode);
362-
target_option_val!(bitcode_llvm_cmdline);
363361
target_option_val!(min_atomic_width);
364362
target_option_val!(max_atomic_width);
365363
target_option_val!(atomic_cas);
@@ -552,7 +550,6 @@ struct TargetSpecJson {
552550
main_needs_argc_argv: Option<bool>,
553551
has_thread_local: Option<bool>,
554552
obj_is_bitcode: Option<bool>,
555-
bitcode_llvm_cmdline: Option<StaticCow<str>>,
556553
max_atomic_width: Option<u64>,
557554
min_atomic_width: Option<u64>,
558555
atomic_cas: Option<bool>,

compiler/rustc_target/src/spec/mod.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2620,8 +2620,6 @@ pub struct TargetOptions {
26202620
/// If we give emcc .o files that are actually .bc files it
26212621
/// will 'just work'.
26222622
pub obj_is_bitcode: bool,
2623-
/// Content of the LLVM cmdline section associated with embedded bitcode.
2624-
pub bitcode_llvm_cmdline: StaticCow<str>,
26252623

26262624
/// Don't use this field; instead use the `.min_atomic_width()` method.
26272625
pub min_atomic_width: Option<u64>,
@@ -2984,7 +2982,6 @@ impl Default for TargetOptions {
29842982
allow_asm: true,
29852983
has_thread_local: false,
29862984
obj_is_bitcode: false,
2987-
bitcode_llvm_cmdline: "".into(),
29882985
min_atomic_width: None,
29892986
max_atomic_width: None,
29902987
atomic_cas: true,

0 commit comments

Comments
 (0)