Skip to content

Commit 371ee34

Browse files
authored
make static bundle type var mutable (#13812)
* make static bundle type var mutable * remove unsafe from no_mangle and link_section
1 parent 22cd1e2 commit 371ee34

File tree

1 file changed

+16
-12
lines changed

1 file changed

+16
-12
lines changed

crates/tauri-utils/src/platform.rs

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -351,22 +351,26 @@ fn resource_dir_from<P: AsRef<std::path::Path>>(
351351
#[no_mangle]
352352
#[cfg_attr(not(target_vendor = "apple"), link_section = ".taubndl")]
353353
#[cfg_attr(target_vendor = "apple", link_section = "__DATA,taubndl")]
354-
static __TAURI_BUNDLE_TYPE: &str = "UNK";
354+
// Marked as `mut` becuase it could get optimized away without it,
355+
// see https://github.com/tauri-apps/tauri/pull/13812
356+
static mut __TAURI_BUNDLE_TYPE: &str = "UNK";
355357

356358
/// Get the type of the bundle current binary is packaged in.
357359
/// If the bundle type is unknown, it returns [`Option::None`].
358360
pub fn bundle_type() -> Option<BundleType> {
359-
match __TAURI_BUNDLE_TYPE {
360-
"DEB" => Some(BundleType::Deb),
361-
"RPM" => Some(BundleType::Rpm),
362-
"APP" => Some(BundleType::AppImage),
363-
"MSI" => Some(BundleType::Msi),
364-
"NSS" => Some(BundleType::Nsis),
365-
_ => {
366-
if cfg!(target_os = "macos") {
367-
Some(BundleType::App)
368-
} else {
369-
None
361+
unsafe {
362+
match __TAURI_BUNDLE_TYPE {
363+
"DEB" => Some(BundleType::Deb),
364+
"RPM" => Some(BundleType::Rpm),
365+
"APP" => Some(BundleType::AppImage),
366+
"MSI" => Some(BundleType::Msi),
367+
"NSS" => Some(BundleType::Nsis),
368+
_ => {
369+
if cfg!(target_os = "macos") {
370+
Some(BundleType::App)
371+
} else {
372+
None
373+
}
370374
}
371375
}
372376
}

0 commit comments

Comments
 (0)