Skip to content

Commit 8d20d71

Browse files
authored
Rollup merge of #133297 - DianQK:embed-bitcode-ios, r=nikic
Remove legacy bitcode for iOS Follow #117364.
2 parents 6bf9a23 + 7cc5fee commit 8d20d71

File tree

4 files changed

+8
-35
lines changed

4 files changed

+8
-35
lines changed

compiler/rustc_codegen_llvm/src/back/write.rs

+1-18
Original file line numberDiff line numberDiff line change
@@ -955,24 +955,7 @@ pub(crate) fn bitcode_section_name(cgcx: &CodegenContext<LlvmCodegenBackend>) ->
955955
}
956956
}
957957

958-
/// Embed the bitcode of an LLVM module in the LLVM module itself.
959-
///
960-
/// This is done primarily for iOS where it appears to be standard to compile C
961-
/// code at least with `-fembed-bitcode` which creates two sections in the
962-
/// executable:
963-
///
964-
/// * __LLVM,__bitcode
965-
/// * __LLVM,__cmdline
966-
///
967-
/// It appears *both* of these sections are necessary to get the linker to
968-
/// recognize what's going on. A suitable cmdline value is taken from the
969-
/// target spec.
970-
///
971-
/// Furthermore debug/O1 builds don't actually embed bitcode but rather just
972-
/// embed an empty section.
973-
///
974-
/// Basically all of this is us attempting to follow in the footsteps of clang
975-
/// on iOS. See #35968 for lots more info.
958+
/// Embed the bitcode of an LLVM module for LTO in the LLVM module itself.
976959
unsafe fn embed_bitcode(
977960
cgcx: &CodegenContext<LlvmCodegenBackend>,
978961
llcx: &llvm::Context,

compiler/rustc_codegen_ssa/src/back/write.rs

+2-4
Original file line numberDiff line numberDiff line change
@@ -432,11 +432,9 @@ struct CompiledModules {
432432

433433
fn need_bitcode_in_object(tcx: TyCtxt<'_>) -> bool {
434434
let sess = tcx.sess;
435-
let requested_for_rlib = sess.opts.cg.embed_bitcode
435+
sess.opts.cg.embed_bitcode
436436
&& tcx.crate_types().contains(&CrateType::Rlib)
437-
&& sess.opts.output_types.contains_key(&OutputType::Exe);
438-
let forced_by_target = sess.target.forces_embed_bitcode;
439-
requested_for_rlib || forced_by_target
437+
&& sess.opts.output_types.contains_key(&OutputType::Exe)
440438
}
441439

442440
fn need_pre_lto_bitcode_for_incr_comp(sess: &Session) -> bool {

compiler/rustc_target/src/spec/mod.rs

-5
Original file line numberDiff line numberDiff line change
@@ -2327,8 +2327,6 @@ pub struct TargetOptions {
23272327
/// If we give emcc .o files that are actually .bc files it
23282328
/// will 'just work'.
23292329
pub obj_is_bitcode: bool,
2330-
/// Whether the target requires that emitted object code includes bitcode.
2331-
pub forces_embed_bitcode: bool,
23322330
/// Content of the LLVM cmdline section associated with embedded bitcode.
23332331
pub bitcode_llvm_cmdline: StaticCow<str>,
23342332

@@ -2671,7 +2669,6 @@ impl Default for TargetOptions {
26712669
allow_asm: true,
26722670
has_thread_local: false,
26732671
obj_is_bitcode: false,
2674-
forces_embed_bitcode: false,
26752672
bitcode_llvm_cmdline: "".into(),
26762673
min_atomic_width: None,
26772674
max_atomic_width: None,
@@ -3412,7 +3409,6 @@ impl Target {
34123409
key!(main_needs_argc_argv, bool);
34133410
key!(has_thread_local, bool);
34143411
key!(obj_is_bitcode, bool);
3415-
key!(forces_embed_bitcode, bool);
34163412
key!(bitcode_llvm_cmdline);
34173413
key!(max_atomic_width, Option<u64>);
34183414
key!(min_atomic_width, Option<u64>);
@@ -3687,7 +3683,6 @@ impl ToJson for Target {
36873683
target_option_val!(main_needs_argc_argv);
36883684
target_option_val!(has_thread_local);
36893685
target_option_val!(obj_is_bitcode);
3690-
target_option_val!(forces_embed_bitcode);
36913686
target_option_val!(bitcode_llvm_cmdline);
36923687
target_option_val!(min_atomic_width);
36933688
target_option_val!(max_atomic_width);

src/doc/rustc/src/codegen-options/index.md

+5-8
Original file line numberDiff line numberDiff line change
@@ -119,17 +119,14 @@ files. It takes one of the following values:
119119
* `n`, `no`, `off` or `false`: omit bitcode from rlibs.
120120

121121
LLVM bitcode is required when rustc is performing link-time optimization (LTO).
122-
It is also required on some targets like iOS ones where vendors look for LLVM
123-
bitcode. Embedded bitcode will appear in rustc-generated object files inside of
124-
a section whose name is defined by the target platform. Most of the time this is
125-
`.llvmbc`.
122+
Embedded bitcode will appear in rustc-generated object files inside of a section
123+
whose name is defined by the target platform. Most of the time this is `.llvmbc`.
126124

127125
The use of `-C embed-bitcode=no` can significantly improve compile times and
128126
reduce generated file sizes if your compilation does not actually need bitcode
129-
(e.g. if you're not compiling for iOS or you're not performing LTO). For these
130-
reasons, Cargo uses `-C embed-bitcode=no` whenever possible. Likewise, if you
131-
are building directly with `rustc` we recommend using `-C embed-bitcode=no`
132-
whenever you are not using LTO.
127+
(e.g. if you're not performing LTO). For these reasons, Cargo uses `-C embed-bitcode=no`
128+
whenever possible. Likewise, if you are building directly with `rustc` we recommend
129+
using `-C embed-bitcode=no` whenever you are not using LTO.
133130

134131
If combined with `-C lto`, `-C embed-bitcode=no` will cause `rustc` to abort
135132
at start-up, because the combination is invalid.

0 commit comments

Comments
 (0)