From 371ee3438395a02a3194bfc28f832bf0ba94f905 Mon Sep 17 00:00:00 2001 From: kandrelczyk Date: Sat, 12 Jul 2025 12:48:13 +0200 Subject: [PATCH] make static bundle type var mutable (#13812) * make static bundle type var mutable * remove unsafe from no_mangle and link_section --- crates/tauri-utils/src/platform.rs | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/crates/tauri-utils/src/platform.rs b/crates/tauri-utils/src/platform.rs index a75bf088c..d6e659147 100644 --- a/crates/tauri-utils/src/platform.rs +++ b/crates/tauri-utils/src/platform.rs @@ -351,22 +351,26 @@ fn resource_dir_from>( #[no_mangle] #[cfg_attr(not(target_vendor = "apple"), link_section = ".taubndl")] #[cfg_attr(target_vendor = "apple", link_section = "__DATA,taubndl")] -static __TAURI_BUNDLE_TYPE: &str = "UNK"; +// Marked as `mut` becuase it could get optimized away without it, +// see https://github.com/tauri-apps/tauri/pull/13812 +static mut __TAURI_BUNDLE_TYPE: &str = "UNK"; /// Get the type of the bundle current binary is packaged in. /// If the bundle type is unknown, it returns [`Option::None`]. pub fn bundle_type() -> Option { - match __TAURI_BUNDLE_TYPE { - "DEB" => Some(BundleType::Deb), - "RPM" => Some(BundleType::Rpm), - "APP" => Some(BundleType::AppImage), - "MSI" => Some(BundleType::Msi), - "NSS" => Some(BundleType::Nsis), - _ => { - if cfg!(target_os = "macos") { - Some(BundleType::App) - } else { - None + unsafe { + match __TAURI_BUNDLE_TYPE { + "DEB" => Some(BundleType::Deb), + "RPM" => Some(BundleType::Rpm), + "APP" => Some(BundleType::AppImage), + "MSI" => Some(BundleType::Msi), + "NSS" => Some(BundleType::Nsis), + _ => { + if cfg!(target_os = "macos") { + Some(BundleType::App) + } else { + None + } } } }