]> git.lizzy.rs Git - rust.git/commitdiff
Implement -Z relax-elf-relocations=yes|no
authorAnthony Ramine <nox@nox.paris>
Mon, 26 Oct 2020 19:55:07 +0000 (20:55 +0100)
committerAnthony Ramine <nox@nox.paris>
Sat, 31 Oct 2020 16:16:56 +0000 (17:16 +0100)
This lets rustc users tweak whether the linker should relax ELF relocations,
namely whether it should emit R_X86_64_GOTPCRELX relocations instead of
R_X86_64_GOTPCREL, as the former is allowed by the ABI to be further
optimised. The default value is whatever the target defines.

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

index 3902df8a7cac3d5d71e03d8233512432febda9c9..f13c2d312dfcca3a6ddec6425866ddbb81c9fcd5 100644 (file)
@@ -156,7 +156,11 @@ pub fn target_machine_factory(
     let emit_stack_size_section = sess.opts.debugging_opts.emit_stack_sizes;
 
     let asm_comments = sess.asm_comments();
-    let relax_elf_relocations = sess.target.options.relax_elf_relocations;
+    let relax_elf_relocations = sess
+        .opts
+        .debugging_opts
+        .relax_elf_relocations
+        .unwrap_or(sess.target.options.relax_elf_relocations);
 
     let use_init_array = !sess
         .opts
index 235e049c3f566b63f4f4a4257e83b9567c29b927..046e451cd835a083f0eabfe292024beff6df7e83 100644 (file)
@@ -573,6 +573,7 @@ macro_rules! tracked {
     tracked!(print_fuel, Some("abc".to_string()));
     tracked!(profile, true);
     tracked!(profile_emit, Some(PathBuf::from("abc")));
+    tracked!(relax_elf_relocations, Some(true));
     tracked!(relro_level, Some(RelroLevel::Full));
     tracked!(report_delayed_bugs, true);
     tracked!(run_dsymutil, false);
index 750f2e19ee2578ea428bfec67a7f3be0f341eaca..c3ec17bc4efa313ac0ed84a0ff37a118a95fc4fb 100644 (file)
@@ -1030,6 +1030,8 @@ fn parse_target_feature(slot: &mut String, v: Option<&str>) -> bool {
         "enable queries of the dependency graph for regression testing (default: no)"),
     query_stats: bool = (false, parse_bool, [UNTRACKED],
         "print some statistics about the query system (default: no)"),
+    relax_elf_relocations: Option<bool> = (None, parse_opt_bool, [TRACKED],
+        "whether ELF relocations can be relaxed"),
     relro_level: Option<RelroLevel> = (None, parse_relro_level, [TRACKED],
         "choose which RELRO level to use"),
     report_delayed_bugs: bool = (false, parse_bool, [TRACKED],