Skip to content

fix static Apple builds failing to link and registering no backends - #4

Closed
cartertemm wants to merge 1 commit into
accessware:mainfrom
cartertemm:fix-static-apple
Closed

cartertemm wants to merge 1 commit into
accessware:mainfrom
cartertemm:fix-static-apple

Conversation

@cartertemm

Copy link
Copy Markdown
Contributor

Static builds on macOS and iOS fail to link, and when I hacked them into working, no backends are registered. This change fixes both problems.

  • build.rs only links c++ for static Apple builds. prism also needs system frameworks, so a minimal macOS binary fails with undefined IOKit and CoreFoundation symbols from the power notifier.
  • The pinned prism commit doesn't keep backend objects in static builds made with GCC or Clang, which is why backend_count() returns 0 and create_best() fails. Looks like you fixed this upstream.

I bumped the prism submodule to 6d87910, which includes the upstream fix
for static backend registration (ethindp/prism#135). I also link the frameworks prism uses, based on PrismPlatformApple.cmake:

  • macOS: Foundation, AVFoundation, AppKit, IOKit, and CoreFoundation.
  • iOS: Foundation, AVFoundation, and UIKit.

This also necessitated a README note for Xcode projects that link a Rust staticlib. Cargo doesn't do the final link in that case, so those projects must add the
frameworks themselves.

Testing

I built a binary with
prismer = { default-features = false, features = ["static"] } and no extra link flags.

  • macOS arm64: builds, and 2 backends register.
  • iOS simulator (arm64): builds, and 2 backends register.
  • Default shared build: the speak example still works.
  • Clippy passes for the default and static builds.

Not covered

  • Linux static builds still don't link, because build.rs doesn't link the
    pkg-config libraries for Orca, speech-dispatcher, and power management. If you like, I can open a separate PR for that.
  • tvOS, watchOS, and visionOS aren't handled at all. I haven't built apps for these yet so am uncertain as to what we'd need to do there.

@cartertemm

Copy link
Copy Markdown
Contributor Author

Just noticed #3, which handles the linux case as well.

I think this PR can be closed accordingly, however, the note in the readme should be added there too.

@trypsynth

Copy link
Copy Markdown
Member

Thanks for this, and for testing it on macOS and the iOS simulator! Main already covers the same ground: 3ff0dbe links the Apple frameworks for static builds (on tvOS, visionOS and watchOS too, plus libobjc), and the prism submodule on main is past ethindp/prism#135, so backends register. Your README note about Xcode projects linking a Rust staticlib wasn't there, though, so I've added it to main in 430afe9, with you as co-author. Closing this, since the rest is already in.

@trypsynth trypsynth closed this Nov 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants