@@ -30,7 +30,7 @@ use rustc_span::source_map::{FilePathMapping, SourceMap}; |
|
|
30 |
30 |
use rustc_span::{FileNameDisplayPreference, RealFileName, Span, Symbol}; |
31 |
31 |
use rustc_target::asm::InlineAsmArch; |
32 |
32 |
use rustc_target::spec::{ |
33 |
|
-CodeModel, DebuginfoKind, PanicStrategy, RelocModel, RelroLevel, SanitizerSet, |
|
33 |
+CodeModel, DebuginfoKind, LinkerFeatures, PanicStrategy, RelocModel, RelroLevel, SanitizerSet, |
34 |
34 |
SmallDataThresholdSupport, SplitDebuginfo, StackProtector, SymbolVisibility, Target, |
35 |
35 |
TargetTriple, TlsModel, |
36 |
36 |
}; |
@@ -622,11 +622,20 @@ impl Session { |
|
|
622 |
622 |
|
623 |
623 |
/// Returns the default symbol visibility. |
624 |
624 |
pub fn default_visibility(&self) -> SymbolVisibility { |
|
625 |
+// For now, we default to using protected only if the LLD linker features is enabled. This |
|
626 |
+// is to avoid link errors that are likely if using protected visibility with GNU ld < 2.40. |
|
627 |
+let fallback = |
|
628 |
+if self.opts.unstable_opts.linker_features.enabled.contains(LinkerFeatures::LLD) { |
|
629 |
+SymbolVisibility::Protected |
|
630 |
+} else { |
|
631 |
+SymbolVisibility::Interposable |
|
632 |
+}; |
|
633 |
+ |
625 |
634 |
self.opts |
626 |
635 |
.unstable_opts |
627 |
636 |
.default_visibility |
628 |
637 |
.or(self.target.options.default_visibility) |
629 |
|
-.unwrap_or(SymbolVisibility::Interposable) |
|
638 |
+.unwrap_or(fallback) |
630 |
639 |
} |
631 |
640 |
} |
632 |
641 |
|