summary refs log tree commit diff
path: root/compiler/rustc_codegen_llvm/src/declare.rs
diff options
context:
space:
mode:
authorDavid Lattimore <dvdlttmr@gmail.com>2024-10-11 07:58:36 +1100
committerDavid Lattimore <dvdlttmr@gmail.com>2024-10-11 08:43:27 +1100
commit42c0494499b3ee271bafa68bbfe5eb5176442c4d (patch)
tree36af6f1f1b24b9be2de03c497ebe6a5fecaa7bb2 /compiler/rustc_codegen_llvm/src/declare.rs
parentbfe5e8cef698ccc4fca655b4cdbabf78fed43816 (diff)
downloadrust-42c0494499b3ee271bafa68bbfe5eb5176442c4d.tar.gz
rust-42c0494499b3ee271bafa68bbfe5eb5176442c4d.zip
Use Default visibility for rustc-generated C symbol declarations
Non-default visibilities should only be used for definitions, not
declarations, otherwise linking can fail.

Co-authored-by: Collin Baker <collinbaker@chromium.org>
Diffstat (limited to 'compiler/rustc_codegen_llvm/src/declare.rs')
-rw-r--r--compiler/rustc_codegen_llvm/src/declare.rs7
1 files changed, 3 insertions, 4 deletions
diff --git a/compiler/rustc_codegen_llvm/src/declare.rs b/compiler/rustc_codegen_llvm/src/declare.rs
index 7be44dd51b5..33258cb46fa 100644
--- a/compiler/rustc_codegen_llvm/src/declare.rs
+++ b/compiler/rustc_codegen_llvm/src/declare.rs
@@ -84,10 +84,9 @@ impl<'ll, 'tcx> CodegenCx<'ll, 'tcx> {
         unnamed: llvm::UnnamedAddr,
         fn_type: &'ll Type,
     ) -> &'ll Value {
-        // Declare C ABI functions with the visibility used by C by default.
-        let visibility = Visibility::from_generic(self.tcx.sess.default_visibility());
-
-        declare_raw_fn(self, name, llvm::CCallConv, unnamed, visibility, fn_type)
+        // Visibility should always be default for declarations, otherwise the linker may report an
+        // error.
+        declare_raw_fn(self, name, llvm::CCallConv, unnamed, Visibility::Default, fn_type)
     }
 
     /// Declare an entry Function