about summary refs log tree commit diff
path: root/compiler/rustc_codegen_llvm/src/builder.rs
diff options
context:
space:
mode:
authorDan Gohman <dev@sunfishcode.online>2022-09-28 10:42:30 -0700
committerDan Gohman <dev@sunfishcode.online>2022-09-28 10:42:30 -0700
commit3c3bf76ce0cc9e569e04a242dfdc447131e21db9 (patch)
treed5e3c7bf8dd3b8dd9173d0060ee9dfad0ef99d1c /compiler/rustc_codegen_llvm/src/builder.rs
parent09ae7846a272a500ff7145255f0de5556c0b8949 (diff)
downloadrust-3c3bf76ce0cc9e569e04a242dfdc447131e21db9.tar.gz
rust-3c3bf76ce0cc9e569e04a242dfdc447131e21db9.zip
Declare `main` as visibility hidden on targets that default to hidden.
On targets with `default_hidden_visibility` set, which is currrently
just WebAssembly, declare the generated `main` function with visibility
hidden. This makes it consistent with clang's WebAssembly target, where
`main` is just a user function that gets the same visibility as any
other user function, which is hidden on WebAssembly unless explicitly
overridden.

This will help simplify use cases which in the future may want to
automatically wasm-export all visibility-"default" symbols. `main` isn't
intended to be wasm-exported, and marking it hidden prevents it from
being wasm-exported in that scenario.
Diffstat (limited to 'compiler/rustc_codegen_llvm/src/builder.rs')
-rw-r--r--compiler/rustc_codegen_llvm/src/builder.rs7
1 files changed, 6 insertions, 1 deletions
diff --git a/compiler/rustc_codegen_llvm/src/builder.rs b/compiler/rustc_codegen_llvm/src/builder.rs
index 59b1c7fb5db..a6cd1059dc7 100644
--- a/compiler/rustc_codegen_llvm/src/builder.rs
+++ b/compiler/rustc_codegen_llvm/src/builder.rs
@@ -1458,7 +1458,12 @@ impl<'a, 'll, 'tcx> Builder<'a, 'll, 'tcx> {
         } else {
             format!("llvm.{}.sat.i{}.f{}", instr, int_width, float_width)
         };
-        let f = self.declare_cfn(&name, llvm::UnnamedAddr::No, self.type_func(&[src_ty], dest_ty));
+        let f = self.declare_cfn(
+            &name,
+            llvm::UnnamedAddr::No,
+            llvm::Visibility::Default,
+            self.type_func(&[src_ty], dest_ty),
+        );
         self.call(self.type_func(&[src_ty], dest_ty), f, &[val], None)
     }