-
Notifications
You must be signed in to change notification settings - Fork 152
Open
Conversation
go-osstat only implements its darwin CPU counters behind cgo (its cpu_darwin_nocgo.go is a stub), so `CGO_ENABLED=0 GOOS=darwin go build` fails in utils/hwstats: # github.com/livekit/protocol/utils/hwstats utils/hwstats/cpu_all.go:24:12: undefined: cpu.Stats utils/hwstats/cpu_all.go:28:20: undefined: cpu.Get utils/hwstats/cpu_all.go:39:19: undefined: cpu.Get This blocks cross-compiling darwin binaries from a linux host, which needs CGO_ENABLED=0. Restrict the go-osstat monitor and the darwin platform monitor to cgo builds, and widen the existing null monitor to cover darwin without cgo. That mirrors what the null monitor already does on other unsupported platforms: CPU stats degrade to a no-op and capacity management is disabled, nothing else changes. Builds with cgo enabled are unaffected.
🦋 Changeset detectedLatest commit: be4e582 The changes in this PR will be included in the next version bump. This PR includes changesets to release 2 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
xiaoshao9704
commented
Sep 8, 2026
Author
FYI: the livekit-server side of this (livekit/livekit#4841, dropping the unused getCPUStats in telemetry) has been merged, so this PR is now the only remaining piece for CGO_ENABLED=0 GOOS=darwin builds to succeed end to end. Happy to rebase or adjust if anything is needed.
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.
Problem
go-osstatonly implements its darwin CPU counters behind cgo (itscpu_darwin_nocgo.gois a stub), soCGO_ENABLED=0 GOOS=darwin go build ./...fails inutils/hwstats:This blocks cross-compiling darwin binaries from a linux host, where
CGO_ENABLED=0is required. (Context: an open-source project embedding livekit-server and cross-compiling six OS/arch targets from one linux runner; previously discussed in #659 / #272.)Change
Three build-tag edits, no new code:
cpu_all.go!(darwin && !cgo)cpu_darwin.godarwindarwin && cgocpu_null.go!(linux || darwin)!linux && !(darwin && cgo)Restrict the go-osstat monitor and the darwin platform monitor to cgo builds, and widen the existing null monitor to cover darwin without cgo. That mirrors what the null monitor already does on other unsupported platforms: CPU stats degrade to a no-op and capacity management is disabled, nothing else changes. Builds with cgo enabled are unaffected. A changeset is included.
Verification
CGO_ENABLED=0 go build ./...fordarwin/arm64,darwin/amd64,linux,windows,freebsd— passCGO_ENABLED=1 GOOS=darwin GOARCH=arm64 go build ./...— pass (unchanged path)go vet ./utils/hwstats/...in both cgo modes — cleango test ./utils/hwstats/...— pass🤖 Generated with Claude Code