ggerganov / whisper.spm

whisper.cpp package for the Swift Package Manager
MIT License
168 stars 27 forks source link

Fix metal build by adding a separate CPP target #17

Closed bjnortier closed 12 months ago

bjnortier commented 1 year ago

Not really sure about this but opening a PR for discussion.

Building the SPM package with metal generates a bunch of NSString etc. errors.

If you move whisper.cpp into a separate target it solves the problem, so it looks like an issue with combining CPP and C/ObjC files (but it works without metal?).

There could be another way to solve it in a single target... looking into it.

bjnortier commented 1 year ago

Some other observations:

  1. The package works fine when imported into a project in Xcode, but using swift build fails.
  2. Apple recommends using two targets for bundling Metal sources with C sources etc. (but it's a but different): https://developer.apple.com/documentation/technotes/tn3133-packaging-a-renderer
  3. It's adding the ggml-metal.metal file the causes the errors.
bjnortier commented 12 months ago

Closed because whisper.cpp didn't have -DGGML_USE_METAL and the test crashes when I add it