]> git.lizzy.rs Git - rust.git/commitdiff
Implement -Z function-sections=yes|no
authorAnthony Ramine <nox@nox.paris>
Mon, 26 Oct 2020 19:55:07 +0000 (20:55 +0100)
committerAnthony Ramine <nox@nox.paris>
Mon, 26 Oct 2020 22:26:43 +0000 (23:26 +0100)
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.

compiler/rustc_codegen_llvm/src/back/write.rs
compiler/rustc_interface/src/tests.rs
compiler/rustc_session/src/options.rs

index ea1a7cfa5d3b5325c88cced137a02431d9344ce8..3902df8a7cac3d5d71e03d8233512432febda9c9 100644 (file)
@@ -128,7 +128,8 @@ pub fn target_machine_factory(
     let (opt_level, _) = to_llvm_opt_settings(optlvl);
     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 code_model = to_llvm_code_model(sess.code_model());
index 6553d0ecfdb5f973a91a9663a0e73244ee5c346d..235e049c3f566b63f4f4a4257e83b9567c29b927 100644 (file)
@@ -550,6 +550,7 @@ macro_rules! tracked {
     tracked!(force_overflow_checks, Some(true));
     tracked!(force_unstable_if_unmarked, true);
     tracked!(fuel, Some(("abc".to_string(), 99)));
+    tracked!(function_sections, Some(false));
     tracked!(human_readable_cgu_names, true);
     tracked!(inline_in_all_cgus, Some(true));
     tracked!(insert_sideeffect, true);
index dd22889ddec82d98c01adcc0f563258e98a233fe..750f2e19ee2578ea428bfec67a7f3be0f341eaca 100644 (file)
@@ -904,6 +904,8 @@ fn parse_target_feature(slot: &mut String, v: Option<&str>) -> bool {
         "force all crates to be `rustc_private` unstable (default: no)"),
     fuel: Option<(String, u64)> = (None, parse_optimization_fuel, [TRACKED],
         "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],
         "use dark-themed colors in graphviz output (default: no)"),
     graphviz_font: String = ("Courier, monospace".to_string(), parse_string, [UNTRACKED],