fix: link macOS CoreServices for the bundled notify/FSEvents backend#1875
Conversation
The Go bindings, and any C/CMake consumer of libmoq, failed to link on macOS with undefined _FSEventStream* / _FSEvents* symbols. moq-native's default features enable quinn, which implies the watch feature and pulls in notify. Both moq-ffi and libmoq link moq-native with default features, so libmoq_ffi.a and libmoq.a bundle notify's FSEvents backend. Those symbols live in the macOS CoreServices framework, which the Go cgo flags and the libmoq CMake config did not link. Only build.rs's pkg-config already listed it, so the three link configs were inconsistent. Linux uses inotify and is unaffected, which is why the Linux-only CI never caught it. - go/moq/cgo.go: add -framework CoreServices to both darwin LDFLAGS lines. - rs/libmoq/CMakeLists.txt and cmake/moq-config.cmake.in: add CoreServices, matching build.rs. - go/moq/link_test.go: a link smoke test. go build ./... compiles the cgo library but never links a binary, so the missing framework slipped through; go test ./... now links a real test binary and catches it. Verified on darwin/arm64: a consumer binary fails to link without the framework (the exact FSEvents errors) and links and runs with it; just go check is green. Swift was checked too and is unaffected (its Apple-toolchain link autolinks the framework). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (4)
WalkthroughThe macOS linker configuration for the 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches✨ Simplify code
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 golangci-lint (2.12.2)level=error msg="[linters_context] typechecking error: pattern ./...: directory prefix . does not contain main module or its selected dependencies" Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Summary
The Go bindings (
github.com/moq-dev/moq-go) and any C/CMake consumer oflibmoqfailed to link on macOS with undefined_FSEventStream*/_FSEvents*symbols:Root cause:
moq-native's default features enablequinn, which implies thewatchfeature and pulls innotify. Bothmoq-ffiandlibmoqlinkmoq-nativewith default features, solibmoq_ffi.aandlibmoq.abundlenotify's FSEvents backend. Those symbols live in the macOS CoreServices framework, which the Go cgo flags and the libmoq CMake config did not link. Onlybuild.rs's pkg-config already listed it (rs/libmoq/build.rs:33), so the three link configs were inconsistent. Linux uses inotify and needs no extra framework, which is why the Linux-only CI never caught it.Changes
go/moq/cgo.go: add-framework CoreServicesto bothdarwin,amd64anddarwin,arm64LDFLAGS.rs/libmoq/CMakeLists.txt+rs/libmoq/cmake/moq-config.cmake.in: add CoreServices, bringing the CMake /find_package(moq)path in line withbuild.rs. Confirmedlibmoq.acarries the same undefined FSEvents symbols.go/moq/link_test.go: a link smoke test.go build ./...compiles the cgo library but never links a binary, so a missing framework slips through compilation;go test ./...(already run bygo/scripts/check.sh) now links a real test binary and surfaces it.Test plan
nmconfirmslibmoq_ffi.aandlibmoq.aboth carry the 9 undefined_FSEvent*symbols.just go checkgreen; the newlink_test.gois staged andgo test ./...passes. A/B confirmed the test fails the build without CoreServices and passes with it.just swift check): unaffected, links and tests pass without declaring the framework (Apple-toolchain autolink). Kotlin/Python load the dynamic lib (rustc links it self-contained), so they are unaffected.Targets
main: a build/link fix, with no public API or wire-protocol change.🤖 Generated with Claude Code