Skip to content

Commit 0569422

Browse files
committed
Implement -Z function-sections=yes|no
This lets rustc users tweak whether all functions should be put in their own TEXT section, using whatever default value the target defines if the flag is missing.
1 parent 53fa22a commit 0569422

File tree

3 files changed

+5
-1
lines changed

3 files changed

+5
-1
lines changed

compiler/rustc_codegen_llvm/src/back/write.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,8 @@ pub fn target_machine_factory(
128128
let (opt_level, _) = to_llvm_opt_settings(optlvl);
129129
let use_softfp = sess.opts.cg.soft_float;
130130

131-
let ffunction_sections = sess.target.options.function_sections;
131+
let ffunction_sections =
132+
sess.opts.debugging_opts.function_sections.unwrap_or(sess.target.options.function_sections);
132133
let fdata_sections = ffunction_sections;
133134

134135
let code_model = to_llvm_code_model(sess.code_model());

compiler/rustc_interface/src/tests.rs

+1
Original file line numberDiff line numberDiff line change
@@ -550,6 +550,7 @@ fn test_debugging_options_tracking_hash() {
550550
tracked!(force_overflow_checks, Some(true));
551551
tracked!(force_unstable_if_unmarked, true);
552552
tracked!(fuel, Some(("abc".to_string(), 99)));
553+
tracked!(function_sections, Some(false));
553554
tracked!(human_readable_cgu_names, true);
554555
tracked!(inline_in_all_cgus, Some(true));
555556
tracked!(insert_sideeffect, true);

compiler/rustc_session/src/options.rs

+2
Original file line numberDiff line numberDiff line change
@@ -904,6 +904,8 @@ options! {DebuggingOptions, DebuggingSetter, basic_debugging_options,
904904
"force all crates to be `rustc_private` unstable (default: no)"),
905905
fuel: Option<(String, u64)> = (None, parse_optimization_fuel, [TRACKED],
906906
"set the optimization fuel quota for a crate"),
907+
function_sections: Option<bool> = (None, parse_opt_bool, [TRACKED],
908+
"whether each function should go in its own section"),
907909
graphviz_dark_mode: bool = (false, parse_bool, [UNTRACKED],
908910
"use dark-themed colors in graphviz output (default: no)"),
909911
graphviz_font: String = ("Courier, monospace".to_string(), parse_string, [UNTRACKED],

0 commit comments

Comments
 (0)