From 85d5fcc722a357e563aac0822d49185aa0cb8693 Mon Sep 17 00:00:00 2001 From: mamamiyear Date: Tue, 7 Jul 2026 14:16:24 +0800 Subject: [PATCH] build: silence duplicate -lobjc linker warning on Xcode 15+ Add -Wl,-no_warn_duplicate_libraries to the darwin cgo LDFLAGS and allow it through the cgo flag allowlist via CGO_LDFLAGS_ALLOW in the build scripts, so the ld-prime duplicate -lobjc note no longer clutters build output. --- activation_policy_darwin.go | 6 ++++++ scripts/dev-build.sh | 3 +++ scripts/release.sh | 4 +++- 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/activation_policy_darwin.go b/activation_policy_darwin.go index 75a9b1b..11726be 100644 --- a/activation_policy_darwin.go +++ b/activation_policy_darwin.go @@ -5,6 +5,12 @@ package main /* #cgo CFLAGS: -x objective-c -fobjc-arc #cgo LDFLAGS: -framework AppKit +// Silence the "ignoring duplicate libraries: '-lobjc'" note emitted by the +// Xcode 15+ linker (ld-prime): cgo links -lobjc for our Objective-C code and +// the Go darwin runtime pulls it in as well, which the new linker flags as a +// duplicate. Suppressing it here keeps the build output clean; the flag is a +// no-op on the legacy ld64 path. +#cgo LDFLAGS: -Wl,-no_warn_duplicate_libraries #include #import diff --git a/scripts/dev-build.sh b/scripts/dev-build.sh index f67e226..c4f590e 100755 --- a/scripts/dev-build.sh +++ b/scripts/dev-build.sh @@ -43,6 +43,9 @@ sleep 0.4 # --identity flag in v2. ARCH="${ARCH:-arm64}" echo "[dev-build.sh] building darwin/${ARCH}..." +# Allow the -Wl,-no_warn_duplicate_libraries flag declared in the darwin cgo +# files past Go's cgo LDFLAGS allowlist (see activation_policy_darwin.go). +export CGO_LDFLAGS_ALLOW='-Wl,-no_warn_duplicate_libraries' wails build -platform "darwin/${ARCH}" -clean # 5. Re-sign with the stable dev cert. We invoke sign.sh through env var diff --git a/scripts/release.sh b/scripts/release.sh index 3408c8d..04e94e5 100755 --- a/scripts/release.sh +++ b/scripts/release.sh @@ -35,7 +35,9 @@ echo "================================================================" # ---- 1. Build ---- echo "" echo "[release.sh] (1/4) wails build" -( cd "${ROOT_DIR}" && wails build -platform "${WAILS_PLATFORM}" -clean ) +# Allow the -Wl,-no_warn_duplicate_libraries flag declared in the darwin cgo +# files past Go's cgo LDFLAGS allowlist (see activation_policy_darwin.go). +( cd "${ROOT_DIR}" && CGO_LDFLAGS_ALLOW='-Wl,-no_warn_duplicate_libraries' wails build -platform "${WAILS_PLATFORM}" -clean ) # ---- 2. Sign .app ---- echo ""