Make plain cargo build work on macOS arm64 (#92)#100
Merged
Conversation
A bare `cargo build` on macOS failed to link the turbovec-python extension module — 'symbol(s) not found for architecture arm64' — because nothing emitted the Python-extension linker args that resolve interpreter symbols (Py_True, etc.) at load time. maturin injects these, but a plain cargo build did not. Add a build.rs for turbovec-python calling pyo3_build_config::add_extension_module_link_args() (with the matching pyo3-build-config build-dependency), so cargo build/test work directly. Also clear the 3 pre-existing build warnings the reporter noted: drop two unused n_groups bindings in the NEON kernels, and cfg-gate the scalar score_query_into_heap fallback out of aarch64 builds where it is never reached. Reported by @yihong0618. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.
Closes #92.
Problem
A bare
cargo build(orcargo test) on macOS Apple Silicon fails to link theturbovec-pythonextension module:The
cdylibreferences Python interpreter symbols (Py_True, etc.) that are only present at load time. maturin injects the right linker args (-undefined dynamic_lookupon macOS) so the link succeeds, but a plaincargo builddoesn't — so anyone cloning and runningcargo buildhits a wall. Reproduced locally.Fix
Add a
build.rsforturbovec-pythonthat callspyo3_build_config::add_extension_module_link_args()(with the matchingpyo3-build-configbuild-dependency). This emits the platform-correct extension-module linker args for a bare cargo build, matching what maturin already does. End-userpip installis unaffected (wheels are built by maturin either way).Also clears the 3 pre-existing build warnings the reporter asked about:
n_groupsbindings in the NEON scoring kernelsscore_query_into_heapfallback iscfg-gated out of aarch64 builds, where the NEON kernel is always used and it was dead code (still compiled for x86_64, where it's the pre-AVX2 fallback)Verification (macOS arm64)
cargo build✅ ·cargo build --release✅ — both now link, zero warningscargo test -p turbovec✅ — all suites passApproach matches the patch suggested by @yihong0618 in the issue; implemented and verified independently.
🤖 Generated with Claude Code