File libsignal-client-visibility-hidden.patch of Package signal-desktop

Do not export internal glue symbols from the final cdylib while making them still unmangled for the linker. See https://github.com/rust-lang/rust/issues/73958
This is likely not upstreamable due to depending on the details of the rustc linux port.

--- vendor/node_modules/@signalapp/libsignal-client/rust/bridge/shared/src/lib.rs.old
+++ vendor/node_modules/@signalapp/libsignal-client/rust/bridge/shared/src/lib.rs
@@ -1,3 +1,4 @@
+#![feature(rustc_attrs)]
 //
 // Copyright 2020-2021 Signal Messenger, LLC.
 // SPDX-License-Identifier: AGPL-3.0-only
--- vendor/node_modules/@signalapp/libsignal-client/rust/bridge/shared/src/node/mod.rs.old
+++ vendor/node_modules/@signalapp/libsignal-client/rust/bridge/shared/src/node/mod.rs
@@ -20,6 +20,7 @@ macro_rules! node_register {
     ( $name:ident ) => {
         paste! {
             #[no_mangle] // necessary because we are linking as a cdylib
+            #[rustc_std_internal_symbol]
             #[allow(non_upper_case_globals)]
             #[linkme::distributed_slice(crate::node::LIBSIGNAL_FNS)]
             static [<signal_register_node_ $name>]: (&str, crate::node::JsFn) =
--- vendor/node_modules/@signalapp/libsignal-client/vendor/pqcrypto-internals/src/lib.rs.old
+++ vendor/node_modules/@signalapp/libsignal-client/vendor/pqcrypto-internals/src/lib.rs
@@ -1,3 +1,4 @@
+#![feature(rustc_attrs)]
 #![no_std]
 
 use core::slice;
@@ -7,8 +8,15 @@ use core::slice;
 /// # Safety
 /// Assumes inputs are valid and may panic over FFI boundary if rng failed.
 #[no_mangle]
+#[rustc_std_internal_symbol]
 pub unsafe extern "C" fn PQCRYPTO_RUST_randombytes(buf: *mut u8, len: libc::size_t) -> libc::c_int {
     let buf = slice::from_raw_parts_mut(buf, len);
     getrandom::getrandom(buf).expect("RNG Failed");
     0
 }
+
+//I can't believe we have to do this but you cannot mark #[used] on functions and otherwise the compiler would remove it before the linking stage causing a missing symbol
+#[used]
+#[no_mangle]
+#[rustc_std_internal_symbol]
+static SUSE_HACK_BECAUSE_RUSTC_LTO_IS_STUPID: unsafe extern "C" fn(*mut u8, usize) -> i32 = PQCRYPTO_RUST_randombytes;
openSUSE Build Service is sponsored by