diff options
| author | Jubilee Young <workingjubilee@gmail.com> | 2024-10-18 00:31:28 -0700 |
|---|---|---|
| committer | Jubilee Young <workingjubilee@gmail.com> | 2024-10-19 10:46:10 -0700 |
| commit | 45d61b0d2654373405e2a8d44289e883847873e4 (patch) | |
| tree | 567393f54cadf971bc6aeab0170cb6d4f9b3dacc /compiler/rustc_codegen_llvm/src/mono_item.rs | |
| parent | 888efe74a3b1f54fcb34e5c8c4f17dd2a381989f (diff) | |
| download | rust-45d61b0d2654373405e2a8d44289e883847873e4.tar.gz rust-45d61b0d2654373405e2a8d44289e883847873e4.zip | |
cg_llvm: Reuse LLVM-C Comdat support
Migrate `llvm::set_comdat` and `llvm::SetUniqueComdat` to LLVM-C FFI. Note, now we can call `llvm::set_comdat` only when the target actually supports adding comdat. As this has no convenient LLVM-C API, we implement this as `TargetOptions::supports_comdat`. Co-authored-by: Stuart Cook <Zalathar@users.noreply.github.com>
Diffstat (limited to 'compiler/rustc_codegen_llvm/src/mono_item.rs')
| -rw-r--r-- | compiler/rustc_codegen_llvm/src/mono_item.rs | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/compiler/rustc_codegen_llvm/src/mono_item.rs b/compiler/rustc_codegen_llvm/src/mono_item.rs index 02e1995620b..bf6ef219873 100644 --- a/compiler/rustc_codegen_llvm/src/mono_item.rs +++ b/compiler/rustc_codegen_llvm/src/mono_item.rs @@ -64,7 +64,9 @@ impl<'tcx> PreDefineCodegenMethods<'tcx> for CodegenCx<'_, 'tcx> { unsafe { llvm::LLVMRustSetLinkage(lldecl, base::linkage_to_llvm(linkage)) }; let attrs = self.tcx.codegen_fn_attrs(instance.def_id()); base::set_link_section(lldecl, attrs); - if linkage == Linkage::LinkOnceODR || linkage == Linkage::WeakODR { + if (linkage == Linkage::LinkOnceODR || linkage == Linkage::WeakODR) + && self.tcx.sess.target.supports_comdat() + { llvm::SetUniqueComdat(self.llmod, lldecl); } |
