Skip to content

metrics: disable CPU stats (gosigar) on Darwing when nocgo is passed #20829

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 3 commits into from
Closed

metrics: disable CPU stats (gosigar) on Darwing when nocgo is passed #20829

wants to merge 3 commits into from

Conversation

BogdanHabic
Copy link

As the title suggests disables gosigar on darwin when CGO is disabled.

This is because the build fails with the following error when CGO is disabled:

../../../../pkg/mod/github.com/elastic/gosigar@v0.10.5/concrete_sigar.go:20:11: cpuUsage.Get undefined (type Cpu has no field or method Get)
../../../../pkg/mod/github.com/elastic/gosigar@v0.10.5/concrete_sigar.go:30:13: cpuUsage.Get undefined (type Cpu has no field or method Get)
../../../../pkg/mod/github.com/elastic/gosigar@v0.10.5/concrete_sigar.go:49:10: l.Get undefined (type LoadAverage has no field or method Get)
../../../../pkg/mod/github.com/elastic/gosigar@v0.10.5/concrete_sigar.go:55:10: m.Get undefined (type Mem has no field or method Get)
../../../../pkg/mod/github.com/elastic/gosigar@v0.10.5/concrete_sigar.go:61:10: s.Get undefined (type Swap has no field or method Get)
../../../../pkg/mod/github.com/elastic/gosigar@v0.10.5/concrete_sigar.go:67:10: p.Get undefined (type HugeTLBPages has no field or method Get)
../../../../pkg/mod/github.com/elastic/gosigar@v0.10.5/concrete_sigar.go:79:11: fd.Get undefined (type FDUsage has no field or method Get)
../../../../pkg/mod/github.com/elastic/gosigar@v0.10.5/sigar_darwin_amd64.go:11:12: undefined: sysctlbyname

@@ -14,7 +14,7 @@
// You should have received a copy of the GNU Lesser General Public License
// along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.

// +build !ios
// +build darwin,cgo dragonfly freebsd linux nacl netbsd openbsd solaris windows arm64
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks very weird. Architectures mixed with platforms. It would also be a maintenance nightmare to keep it always updated. Please use exclusion patterns

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@adamschmideg
Copy link
Contributor

@BogdanHabic are you still interested in this PR and in making the changes requested?

@BogdanHabic
Copy link
Author

@adamschmideg oh my god, sorry, yes, I somehow missed this notification due to the security ones GitHub has spammed me with. I'll make the changes today!

@BogdanHabic
Copy link
Author

Hey @adamschmideg, I've pushed the requested change. The test that is failing is not broken by this change if I'm not mistaken.

@@ -14,7 +14,7 @@
// You should have received a copy of the GNU Lesser General Public License
// along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.

// +build !ios
// +build !ios,!darwin
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you should be able to cover all cases here and not need that extra file:

// +build !ios
// +build !darwin cgo

Could you try this version out?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it should be

Suggested change
// +build !ios,!darwin
// +build !ios,!darwin darwin,cgo

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the truth table I'm using

ios darwin Other OS cgo cpu enabled
0 1 0 0 0
0 1 0 1 1
1 0 0 0 0
1 0 0 1 0
0 0 1 0 1
0 0 1 1 1

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So the Other OS will essentially be caught by !ios,!darwin, correct? If this is the case, the change you suggested makes sense.

@renaynay
Copy link
Contributor

renaynay commented Jun 4, 2020

Closing this PR as this fix was not sufficient to prevent geth build failure when building on darwin with CGO disabled. #21041 implements a fix for this issue.

@renaynay renaynay closed this Jun 4, 2020
@BogdanHabic BogdanHabic deleted the disable-gosigar-darwin-nocgo branch June 4, 2020 09:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants