Add native Apple Silicon (arm64) build support - #1493
Conversation
- Guard x86-64 [[gnu::target_clones]] behind a VIDEO2X_TARGET_CLONES macro (include/libvideo2x/multiversion.h) so the attribute is emitted only on x86-64 with GCC/Clang. Fixes build failures on arm64 (Apple Silicon, Raspberry Pi, Jetson) and Apple Clang. Covers all 7 annotated sites. - CMake: use ld64-compatible link flags on Apple (-dead_strip instead of -s/--gc-sections); restrict -march=native to x86-64; link Homebrew libomp for ncnn's OpenMP on Apple Clang; honor <Pkg>_ROOT (CMP0074). - vulkan_utils: request VK_KHR_portability_enumeration on macOS (MoltenVK), guarded by __APPLE__ so Linux/Windows are unaffected. - Add 'just macos' build recipe, macos-14 CI jobs (build + release), and docs/building/macos.md. Closes k4yt3x#1362 for Apple Silicon; supersedes k4yt3x#1475.
|
Thanks for sharing the work. I'm not fond of how the While I might not merge this PR, you can leave this around since it's a known working approach for macOS. I might still reference it when I eventually find time to work on this. |
|
Confirming this PR's approach works end-to-end on Apple Silicon — I've been running a build based on it for real upscaling work. Details that may help land it: Verified configuration
The MoltenVK ICD workaround in this PR's docs is definitely needed — current Homebrew One additional fix worth folding in: HEVC output is unplayable in QuickTime/Photos without an // Apple players (QuickTime, Photos) only recognize HEVC in MP4/MOV when the
// sample entry is tagged 'hvc1'; the mux default 'hev1' renders unplayable.
if (enc_ctx_->codec_id == AV_CODEC_ID_HEVC && ofmt_ctx_->oformat->name != nullptr &&
(std::strcmp(ofmt_ctx_->oformat->name, "mp4") == 0 ||
std::strcmp(ofmt_ctx_->oformat->name, "mov") == 0)) {
out_vstream->codecpar->codec_tag = MKTAG('h', 'v', 'c', '1');
}(after the frame-rate copy, before the stream-map section — verified via ffprobe: Also FWIW for anyone bundling a relocatable app from this: |
yo, I like the repo and spent some tokens to make it work on my machine, here are changes that worked for me
Closes #1362 for Apple Silicon; supersedes #1475.