diff options
author | Matthias Krüger <matthias.krueger@famsik.de> | 2023-03-10 21:15:45 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-03-10 21:15:45 +0100 |
commit | 342ca46517714ccde6efba95ff552d11b9a92f1c (patch) | |
tree | dd3b11270980457ac988e1ec3349398857dfc163 /compiler/rustc_codegen_cranelift | |
parent | 93316d7f28b06ac2cc86526dec143952ad2a4b25 (diff) | |
parent | cb41803899ae6531ea2e8fd236f67663e7815ae3 (diff) | |
download | rust-342ca46517714ccde6efba95ff552d11b9a92f1c.tar.gz |
Rollup merge of #108017 - chbaker0:fix-105967, r=chbaker0
Add `--no-undefined-version` link flag and fix associated breakage
LLVM upstream sets `--no-undefined-version` by default in lld: https://reviews.llvm.org/D135402.
Due to a bug in how version scripts are generated, this breaks the `dylib` output type for most crates. See https://github.com/rust-lang/rust/issues/105967#issuecomment-1428671533 for details.
This PR adds the flag to gcc flavor linkers in anticipation of this LLVM change rolling in, and patches `rustc` to not attempt to export `__rust_*` allocator symbols when they weren't generated.
Fixes #105967
Diffstat (limited to 'compiler/rustc_codegen_cranelift')
-rw-r--r-- | compiler/rustc_codegen_cranelift/src/allocator.rs | 28 |
1 files changed, 10 insertions, 18 deletions
diff --git a/compiler/rustc_codegen_cranelift/src/allocator.rs b/compiler/rustc_codegen_cranelift/src/allocator.rs index 1c73957ca57..2c246ceb37d 100644 --- a/compiler/rustc_codegen_cranelift/src/allocator.rs +++ b/compiler/rustc_codegen_cranelift/src/allocator.rs @@ -4,6 +4,7 @@ use crate::prelude::*; use rustc_ast::expand::allocator::{AllocatorKind, AllocatorTy, ALLOCATOR_METHODS}; +use rustc_codegen_ssa::base::allocator_kind_for_codegen; use rustc_session::config::OomStrategy; use rustc_span::symbol::sym; @@ -13,24 +14,15 @@ pub(crate) fn codegen( module: &mut impl Module, unwind_context: &mut UnwindContext, ) -> bool { - let any_dynamic_crate = tcx.dependency_formats(()).iter().any(|(_, list)| { - use rustc_middle::middle::dependency_format::Linkage; - list.iter().any(|&linkage| linkage == Linkage::Dynamic) - }); - if any_dynamic_crate { - false - } else if let Some(kind) = tcx.allocator_kind(()) { - codegen_inner( - module, - unwind_context, - kind, - tcx.alloc_error_handler_kind(()).unwrap(), - tcx.sess.opts.unstable_opts.oom, - ); - true - } else { - false - } + let Some(kind) = allocator_kind_for_codegen(tcx) else { return false }; + codegen_inner( + module, + unwind_context, + kind, + tcx.alloc_error_handler_kind(()).unwrap(), + tcx.sess.opts.unstable_opts.oom, + ); + true } fn codegen_inner( |