Default relax_elf_relocations to true

This option tells LLVM to emit relaxable relocation types
R_X86_64_GOTPCRELX/R_X86_64_REX_GOTPCRELX/R_386_GOT32X in applicable cases. True
matches Clang's CMake default since 2020-08 [1] and latest LLVM default[2].

This also works around a GNU ld<2.41 issue[3] when using
general-dynamic/local-dynamic TLS models in `-Z plt=no` mode with latest LLVM.

[1]: c41a18cf61
[2]: 2aedfdd9b8
[3]: https://sourceware.org/bugzilla/show_bug.cgi?id=24784
This commit is contained in:
Fangrui Song 2023-01-05 13:55:24 -08:00
parent 8e8231f64e
commit f3d81917fc
3 changed files with 2 additions and 3 deletions

View File

@ -821,7 +821,7 @@ macro_rules! tracked {
tracked!(profile_emit, Some(PathBuf::from("abc"))); tracked!(profile_emit, Some(PathBuf::from("abc")));
tracked!(profile_sample_use, Some(PathBuf::from("abc"))); tracked!(profile_sample_use, Some(PathBuf::from("abc")));
tracked!(profiler_runtime, "abc".to_string()); tracked!(profiler_runtime, "abc".to_string());
tracked!(relax_elf_relocations, Some(true)); tracked!(relax_elf_relocations, Some(false));
tracked!(relro_level, Some(RelroLevel::Full)); tracked!(relro_level, Some(RelroLevel::Full));
tracked!(remap_cwd_prefix, Some(PathBuf::from("abc"))); tracked!(remap_cwd_prefix, Some(PathBuf::from("abc")));
tracked!(report_delayed_bugs, true); tracked!(report_delayed_bugs, true);

View File

@ -2216,7 +2216,7 @@ fn default() -> TargetOptions {
mcount: "mcount".into(), mcount: "mcount".into(),
llvm_mcount_intrinsic: None, llvm_mcount_intrinsic: None,
llvm_abiname: "".into(), llvm_abiname: "".into(),
relax_elf_relocations: false, relax_elf_relocations: true,
llvm_args: cvs![], llvm_args: cvs![],
use_ctors_section: false, use_ctors_section: false,
eh_frame_header: true, eh_frame_header: true,

View File

@ -69,7 +69,6 @@ pub fn target() -> Target {
position_independent_executables: true, position_independent_executables: true,
pre_link_args, pre_link_args,
override_export_symbols: Some(EXPORT_SYMBOLS.iter().cloned().map(Cow::from).collect()), override_export_symbols: Some(EXPORT_SYMBOLS.iter().cloned().map(Cow::from).collect()),
relax_elf_relocations: true,
..Default::default() ..Default::default()
}; };
Target { Target {