Skip to content

Commit 8f648d7

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 8f648d7

File tree

4 files changed

+6
-13
lines changed

4 files changed

+6
-13
lines changed

compiler/rustc_codegen_llvm/src/back/write.rs

Lines changed: 6 additions & 5 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,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
}

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)