zig build test -Doptimize=ReleaseFast fails on macOS for an app built with addAppArtifacts, and so does the model-contract tool:
error: undefined symbol: _native_sdk_update_verify_archive
note: referenced by appkit_host.o: -[NativeSdkAppKitHost installDownloadedUpdate:version:archiveBytes:sha256:]_block_invoke
error: undefined symbol: _native_sdk_update_verify_feed
note: referenced by appkit_host.o: -[NativeSdkAppKitHost checkForUpdatesUserInitiated:]_block_invoke
Debug links. Seen with CLI 0.10.1, Zig 0.16.0, on an Apple Silicon Mac; the code below is as of 6b05318 on main.
build/app.zig:2614 compiles src/platform/macos/appkit_host.m into the app module, so every binary built from it carries the host, the test binary included. The two functions are export fns in src/updater/c_api.zig (:14, :82), and the only thing that references them is the comptime block at src/platform/macos/root.zig:13. That file is only analysed when something reaches native_sdk.platform.macos, which the app runner's run path does and a test binary does not. A Debug link drops the unused host object; an optimized link keeps it, and the two symbols are missing.
A fix on the toolkit side could reference the two exports from wherever appkit_host.m is added, or from the module root on macOS, so they exist in every binary that carries the host. In the meantime an app can reference them itself, which is what I do in Plaza (zig-nostr/plaza#390):
comptime {
if (builtin.os.tag == .macos) {
_ = native_sdk.updater.c_api.native_sdk_update_verify_feed;
_ = native_sdk.updater.c_api.native_sdk_update_verify_archive;
}
}
zig build test -Doptimize=ReleaseFastfails on macOS for an app built withaddAppArtifacts, and so does the model-contract tool:Debug links. Seen with CLI 0.10.1, Zig 0.16.0, on an Apple Silicon Mac; the code below is as of
6b05318on main.build/app.zig:2614compilessrc/platform/macos/appkit_host.minto the app module, so every binary built from it carries the host, the test binary included. The two functions areexport fns insrc/updater/c_api.zig(:14,:82), and the only thing that references them is thecomptimeblock atsrc/platform/macos/root.zig:13. That file is only analysed when something reachesnative_sdk.platform.macos, which the app runner's run path does and a test binary does not. A Debug link drops the unused host object; an optimized link keeps it, and the two symbols are missing.A fix on the toolkit side could reference the two exports from wherever
appkit_host.mis added, or from the module root on macOS, so they exist in every binary that carries the host. In the meantime an app can reference them itself, which is what I do in Plaza (zig-nostr/plaza#390):