Auto merge of #78414 - nox:function-sections, r=nagisa,bjorn3
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. I'm having fun experimenting with musl libc and trying to implement the start symbol in Rust, that means avoiding code that requires relocations, and AFAIK putting everything in its own section makes the toolchain generate `GOTPCREL` relocations for symbols that could use plain old PC-relative addressing (at least on `x86_64`) if they were all in the same section.
This commit is contained in:
commit
3dddf6ac1e
3 changed files with 8 additions and 4 deletions
|
@ -128,7 +128,8 @@ pub fn target_machine_factory(
|
||||||
let (opt_level, _) = to_llvm_opt_settings(optlvl);
|
let (opt_level, _) = to_llvm_opt_settings(optlvl);
|
||||||
let use_softfp = sess.opts.cg.soft_float;
|
let use_softfp = sess.opts.cg.soft_float;
|
||||||
|
|
||||||
let ffunction_sections = sess.target.options.function_sections;
|
let ffunction_sections =
|
||||||
|
sess.opts.debugging_opts.function_sections.unwrap_or(sess.target.options.function_sections);
|
||||||
let fdata_sections = ffunction_sections;
|
let fdata_sections = ffunction_sections;
|
||||||
|
|
||||||
let code_model = to_llvm_code_model(sess.code_model());
|
let code_model = to_llvm_code_model(sess.code_model());
|
||||||
|
|
|
@ -550,6 +550,7 @@ fn test_debugging_options_tracking_hash() {
|
||||||
tracked!(force_overflow_checks, Some(true));
|
tracked!(force_overflow_checks, Some(true));
|
||||||
tracked!(force_unstable_if_unmarked, true);
|
tracked!(force_unstable_if_unmarked, true);
|
||||||
tracked!(fuel, Some(("abc".to_string(), 99)));
|
tracked!(fuel, Some(("abc".to_string(), 99)));
|
||||||
|
tracked!(function_sections, Some(false));
|
||||||
tracked!(human_readable_cgu_names, true);
|
tracked!(human_readable_cgu_names, true);
|
||||||
tracked!(inline_in_all_cgus, Some(true));
|
tracked!(inline_in_all_cgus, Some(true));
|
||||||
tracked!(insert_sideeffect, true);
|
tracked!(insert_sideeffect, true);
|
||||||
|
|
|
@ -717,7 +717,7 @@ options! {CodegenOptions, CodegenSetter, basic_codegen_options,
|
||||||
// This list is in alphabetical order.
|
// This list is in alphabetical order.
|
||||||
//
|
//
|
||||||
// If you add a new option, please update:
|
// If you add a new option, please update:
|
||||||
// - src/librustc_interface/tests.rs
|
// - compiler/rustc_interface/src/tests.rs
|
||||||
// - src/doc/rustc/src/codegen-options/index.md
|
// - src/doc/rustc/src/codegen-options/index.md
|
||||||
|
|
||||||
ar: String = (String::new(), parse_string, [UNTRACKED],
|
ar: String = (String::new(), parse_string, [UNTRACKED],
|
||||||
|
@ -814,7 +814,7 @@ options! {CodegenOptions, CodegenSetter, basic_codegen_options,
|
||||||
// This list is in alphabetical order.
|
// This list is in alphabetical order.
|
||||||
//
|
//
|
||||||
// If you add a new option, please update:
|
// If you add a new option, please update:
|
||||||
// - src/librustc_interface/tests.rs
|
// - compiler/rustc_interface/src/tests.rs
|
||||||
// - src/doc/rustc/src/codegen-options/index.md
|
// - src/doc/rustc/src/codegen-options/index.md
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -825,7 +825,7 @@ options! {DebuggingOptions, DebuggingSetter, basic_debugging_options,
|
||||||
// This list is in alphabetical order.
|
// This list is in alphabetical order.
|
||||||
//
|
//
|
||||||
// If you add a new option, please update:
|
// If you add a new option, please update:
|
||||||
// - src/librustc_interface/tests.rs
|
// - compiler/rustc_interface/src/tests.rs
|
||||||
|
|
||||||
allow_features: Option<Vec<String>> = (None, parse_opt_comma_list, [TRACKED],
|
allow_features: Option<Vec<String>> = (None, parse_opt_comma_list, [TRACKED],
|
||||||
"only allow the listed language features to be enabled in code (space separated)"),
|
"only allow the listed language features to be enabled in code (space separated)"),
|
||||||
|
@ -904,6 +904,8 @@ options! {DebuggingOptions, DebuggingSetter, basic_debugging_options,
|
||||||
"force all crates to be `rustc_private` unstable (default: no)"),
|
"force all crates to be `rustc_private` unstable (default: no)"),
|
||||||
fuel: Option<(String, u64)> = (None, parse_optimization_fuel, [TRACKED],
|
fuel: Option<(String, u64)> = (None, parse_optimization_fuel, [TRACKED],
|
||||||
"set the optimization fuel quota for a crate"),
|
"set the optimization fuel quota for a crate"),
|
||||||
|
function_sections: Option<bool> = (None, parse_opt_bool, [TRACKED],
|
||||||
|
"whether each function should go in its own section"),
|
||||||
graphviz_dark_mode: bool = (false, parse_bool, [UNTRACKED],
|
graphviz_dark_mode: bool = (false, parse_bool, [UNTRACKED],
|
||||||
"use dark-themed colors in graphviz output (default: no)"),
|
"use dark-themed colors in graphviz output (default: no)"),
|
||||||
graphviz_font: String = ("Courier, monospace".to_string(), parse_string, [UNTRACKED],
|
graphviz_font: String = ("Courier, monospace".to_string(), parse_string, [UNTRACKED],
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue