From 97da3ae18097eb591306060bdf0a902941512a66 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A8=8B=E5=BA=8F=E5=91=98=E9=98=BF=E6=B1=9F=28Relakkes?= =?UTF-8?q?=29?= Date: Tue, 5 May 2026 23:04:12 +0800 Subject: [PATCH] Build macOS notification bridge for the target arch The macOS notification bridge is compiled by build.rs outside Cargo's Rust target handling. On Apple Silicon, clang defaulted macos_notifications.o to arm64 even when Cargo was building x86_64, so the x64 release job ignored the object and missed the exported notification symbols. Constraint: The ObjC bridge is linked manually through cargo:rustc-link-arg Constraint: Release workflow builds both aarch64-apple-darwin and x86_64-apple-darwin from macOS runners Rejected: Rely on clang default architecture | Apple Silicon defaults arm64 and breaks x86_64 linking Confidence: high Scope-risk: narrow Directive: Keep native ObjC bridge compilation aligned with Cargo TARGET when adding platform bridge files Tested: cargo fmt --check Tested: git diff --check Tested: cargo check --target aarch64-apple-darwin Tested: cargo build --target x86_64-apple-darwin --release Tested: file target/x86_64-apple-darwin/release/.../macos_notifications.o reports Mach-O 64-bit object x86_64 Not-tested: Full GitHub release workflow after retag before pushing --- desktop/src-tauri/build.rs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/desktop/src-tauri/build.rs b/desktop/src-tauri/build.rs index f6240955..a5a10297 100644 --- a/desktop/src-tauri/build.rs +++ b/desktop/src-tauri/build.rs @@ -4,15 +4,24 @@ fn main() { use std::{env, path::PathBuf, process::Command}; let out_dir = PathBuf::from(env::var("OUT_DIR").expect("OUT_DIR is set by Cargo")); + let target = env::var("TARGET").expect("TARGET is set by Cargo"); + let arch = match target.as_str() { + "aarch64-apple-darwin" => "arm64", + "x86_64-apple-darwin" => "x86_64", + _ => panic!("unsupported macOS notification bridge target: {target}"), + }; let object_path = out_dir.join("macos_notifications.o"); let source_path = PathBuf::from("src/macos_notifications.m"); println!("cargo:rerun-if-changed={}", source_path.display()); + println!("cargo:rerun-if-env-changed=TARGET"); let status = Command::new("clang") .args([ "-fobjc-arc", "-c", + "-arch", + arch, source_path .to_str() .expect("notification bridge path is UTF-8"),