build(darwin): add macOS arm64 support with VideoToolbox#10
Merged
flexiondotorg merged 3 commits intomainfrom Jan 14, 2026
Merged
build(darwin): add macOS arm64 support with VideoToolbox#10flexiondotorg merged 3 commits intomainfrom
flexiondotorg merged 3 commits intomainfrom
Conversation
Resolve three blocking issues for building FFmpeg and 20 dependencies on macOS arm64 within Nix development environment: - Force clang compiler via FFmpeg configure flags and build environment - Disable x264 assembly on Apple Silicon (GNU macro incompatibility with LLVM) - Build rav1e without git_version feature to avoid libgit2/libiconv dependency - Configure C++ header search order with -nostdinc++ and explicit libc++ path - Filter NIX_CFLAGS_COMPILE to prevent incorrect -isystem injection - Use Apple's /usr/bin/libtool instead of GNU libtool for library combining - Add VideoToolbox hardware encoder support (H.264, HEVC, ProRes) - Export LIBCXX_INCLUDE from flake.nix for C++ dependency builds Root cause: Nix dev shell provides both GCC and Clang, but CGO_CFLAGS points to Clang's builtin headers containing preprocessor features (__has_feature, __building_module) that GCC doesn't recognise. Verified: All 17 platform-applicable libraries build successfully, combine into lib/darwin_arm64/libffmpeg.a (63MB), tests pass, VideoToolbox encoders confirmed present. Signed-off-by: Martin Wimpress <martin@wimpress.org>
x264's aarch64 .S files contain macros (T(), const, endconst) requiring C preprocessor expansion. The bare 'as' command skips preprocessing, causing build failures. Setting AS=clang ensures preprocessing runs before assembly, matching Apple's Xcode toolchain behaviour. Removes the --disable-asm workaround that caused 10-20% performance loss. Signed-off-by: Martin Wimpress <martin@wimpress.org>
There was a problem hiding this comment.
1 issue found across 6 files
Prompt for AI agents (all issues)
Check if these issues are valid — if so, understand the root cause of each and fix them.
<file name="internal/builder/library.go">
<violation number="1" location="internal/builder/library.go:300">
P2: LIBRARY_PATH handling is inconsistent with other environment variables. This unconditionally appends without checking for an existing value, potentially creating duplicate environment variables and losing existing paths that cargo/rustc might depend on.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
Follow same pattern as LDFLAGS/CFLAGS handling - check for existing value and prepend rather than overwrite, preventing loss of paths that cargo/rustc might depend on.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Enable FFmpeg and 20 dependencies to build on macOS arm64 within the Nix development environment, with full x264 assembly optimisation and VideoToolbox hardware encoder support.
Changes
AS=clangfor x264 on arm64 to ensure C preprocessor expands assembly macrosgit_versionfeature to avoid libgit2/libiconv dependency-nostdinc++and explicit libc++ pathNIX_CFLAGS_COMPILEto prevent incorrect-isysteminjection/usr/bin/libtoolinstead of GNU libtool for library combiningLIBCXX_INCLUDEfrom flake.nix for C++ dependency buildsRoot Cause
Nix dev shell provides both GCC and Clang, but
CGO_CFLAGSpoints to Clang's builtin headers containing preprocessor features (__has_feature,__building_module) that GCC doesn't recognise. Additionally, x264's aarch64 assembly uses macros requiring C preprocessor expansion, which the bareascommand skips.Testing
lib/darwin_arm64/libffmpeg.a(63MB)Known Limitations
just generaterequires Linux (go-clang bindings incompatible with macOS libclang blocks)