From 3b62836d9e2287859cd79afcbdb90aa796426c81 Mon Sep 17 00:00:00 2001 From: Andrew Kroh Date: Sat, 4 Jun 2022 08:20:32 -0400 Subject: [PATCH] Fix build tags on AIX provider (#116) * Add build tags to aix provider * Add cross-compile checks to CI * Update golang.org/x/sys This brings in an updated version that supports windows/arm64. * Document GOOS / GOARCH / CGO * Bump Go versions Fixes #106 --- .ci/Jenkinsfile | 6 +- .ci/scripts/test.sh | 25 +++++++ CHANGELOG.md | 1 + README.md | 68 +++++++++++++------ go.mod | 2 +- go.sum | 4 +- ...{boottime_aix.go => boottime_aix_ppc64.go} | 3 + ...ime_test.go => boottime_aix_ppc64_test.go} | 4 +- providers/aix/doc.go | 2 +- .../aix/{host_aix.go => host_aix_ppc64.go} | 3 + .../{kernel_aix.go => kernel_aix_ppc64.go} | 3 + ...achineid_aix.go => machineid_aix_ppc64.go} | 3 + providers/aix/{os_aix.go => os_aix_ppc64.go} | 3 + .../{process_aix.go => process_aix_ppc64.go} | 3 + providers/aix/ztypes_aix_ppc64.go | 3 + 15 files changed, 102 insertions(+), 31 deletions(-) rename providers/aix/{boottime_aix.go => boottime_aix_ppc64.go} (97%) rename providers/aix/{boottime_test.go => boottime_aix_ppc64_test.go} (95%) rename providers/aix/{host_aix.go => host_aix_ppc64.go} (98%) rename providers/aix/{kernel_aix.go => kernel_aix_ppc64.go} (96%) rename providers/aix/{machineid_aix.go => machineid_aix_ppc64.go} (95%) rename providers/aix/{os_aix.go => os_aix_ppc64.go} (96%) rename providers/aix/{process_aix.go => process_aix_ppc64.go} (99%) diff --git a/.ci/Jenkinsfile b/.ci/Jenkinsfile index 0c090332..0e8f5eed 100644 --- a/.ci/Jenkinsfile +++ b/.ci/Jenkinsfile @@ -37,7 +37,7 @@ pipeline { axes { axis { name 'GO_VERSION' - values '1.17.10', '1.18.2' + values '1.17.11', '1.18.3' } axis { name 'PLATFORM' @@ -48,7 +48,7 @@ pipeline { exclude { axis { name 'GO_VERSION' - values '1.17.10' + values '1.17.11' } axis { name 'PLATFORM' @@ -58,7 +58,7 @@ pipeline { exclude { axis { name 'GO_VERSION' - values '1.18.2' + values '1.18.3' } axis { name 'PLATFORM' diff --git a/.ci/scripts/test.sh b/.ci/scripts/test.sh index 9c7bf562..2924a60e 100755 --- a/.ci/scripts/test.sh +++ b/.ci/scripts/test.sh @@ -8,6 +8,31 @@ go-licenser -d go run .ci/scripts/check_format.go go run .ci/scripts/check_lint.go +# Cross-compile checks (only execute on Linux to avoid running this multiple times). +if [[ $(go env GOOS) == "linux" ]]; then +# Test that there are no compilation issues when not using CGO. This does +# not imply that all of these targets are supported without CGO. It's only +# a sanity check for build tag issues. +CGO_ENABLED=0 GOOS=aix GOARCH=ppc64 go build ./... +CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 go build ./... +CGO_ENABLED=0 GOOS=darwin GOARCH=arm64 go build ./... +CGO_ENABLED=0 GOOS=linux GOARCH=386 go build ./... +CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build ./... +CGO_ENABLED=0 GOOS=linux GOARCH=arm go build ./... +CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build ./... +CGO_ENABLED=0 GOOS=linux GOARCH=mips go build ./... +CGO_ENABLED=0 GOOS=linux GOARCH=mips64 go build ./... +CGO_ENABLED=0 GOOS=linux GOARCH=mips64le go build ./... +CGO_ENABLED=0 GOOS=linux GOARCH=mipsle go build ./... +CGO_ENABLED=0 GOOS=linux GOARCH=ppc64 go build ./... +CGO_ENABLED=0 GOOS=linux GOARCH=ppc64le go build ./... +CGO_ENABLED=0 GOOS=linux GOARCH=riscv64 go build ./... +CGO_ENABLED=0 GOOS=linux GOARCH=s390x go build ./... +CGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build ./... +CGO_ENABLED=0 GOOS=windows GOARCH=arm go build ./... +CGO_ENABLED=0 GOOS=windows GOARCH=arm64 go build ./... +fi + # Run the tests set +e export OUT_FILE="build/test-report.out" diff --git a/CHANGELOG.md b/CHANGELOG.md index e7c7bb1c..9b37a7c3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -24,6 +24,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Fixed - Fix handling of environment variables without values on macOS. [#94](https://github.com/elastic/go-sysinfo/pull/94) +- Fix build tags on AIX provider such that CGO is required. [#106](https://github.com/elastic/go-sysinfo/issues/106) ## [1.7.1] - 2021-10-11 diff --git a/README.md b/README.md index 5ca5b61a..f7e7c0b1 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,6 @@ [![Build Status](https://beats-ci.elastic.co/job/Library/job/go-sysinfo-mbp/job/main/badge/icon)](https://beats-ci.elastic.co/job/Library/job/go-sysinfo-mbp/job/main/) [![Go Documentation](http://img.shields.io/badge/go-documentation-blue.svg?style=flat-square)][godocs] -[travis]: http://travis-ci.org/elastic/go-sysinfo [godocs]: http://godoc.org/github.com/elastic/go-sysinfo go-sysinfo is a library for collecting system information. This includes @@ -31,24 +30,49 @@ if handleCounter, ok := process.(types.OpenHandleCounter); ok { These tables show what methods are implemented as well as the extra interfaces that are implemented. -| `Host` Features | Darwin | Linux | Windows | AIX/ppc64 | -|------------------|--------|-------|---------|-----------| -| `Info()` | x | x | x | x | -| `Memory()` | x | x | x | x | -| `CPUTimer` | x | x | x | x | -| `VMStat` | | x | | | -| `NetworkCounters`| | x | | | - -| `Process` Features | Darwin | Linux | Windows | AIX/ppc64 | -|------------------------|--------|-------|---------|-----------| -| `Info()` | x | x | x | x | -| `Memory()` | x | x | x | x | -| `User()` | x | x | x | x | -| `Parent()` | x | x | x | x | -| `CPUTimer` | x | x | x | x | -| `Environment` | x | x | | x | -| `OpenHandleEnumerator` | | x | | | -| `OpenHandleCounter` | | x | | | -| `Seccomp` | | x | | | -| `Capabilities` | | x | | | -| `NetworkCounters` | | x | | | +| `Host` Features | Darwin | Linux | Windows | AIX | +|------------------|--------|-------|---------|-----| +| `Info()` | x | x | x | x | +| `Memory()` | x | x | x | x | +| `CPUTimer` | x | x | x | x | +| `VMStat` | | x | | | +| `NetworkCounters`| | x | | | + +| `Process` Features | Darwin | Linux | Windows | AIX | +|------------------------|--------|-------|---------|-----| +| `Info()` | x | x | x | x | +| `Memory()` | x | x | x | x | +| `User()` | x | x | x | x | +| `Parent()` | x | x | x | x | +| `CPUTimer` | x | x | x | x | +| `Environment` | x | x | | x | +| `OpenHandleEnumerator` | | x | | | +| `OpenHandleCounter` | | x | | | +| `Seccomp` | | x | | | +| `Capabilities` | | x | | | +| `NetworkCounters` | | x | | | + +### GOOS / GOARCH Pairs + +This table lists the OS and architectures for which a "provider" is implemented. + +| GOOS / GOARCH | Requires CGO | Tested | +|----------------|--------------|--------| +| aix/ppc64 | x | | +| darwin/amd64 | x | x | +| darwin/arm64 | x | x | +| linux/386 | | | +| linux/amd64 | | x | +| linux/arm | | | +| linux/arm64 | | | +| linux/mips | | | +| linux/mips64 | | | +| linux/mips64le | | | +| linux/mipsle | | | +| linux/ppc64 | | | +| linux/ppc64le | | | +| linux/riscv64 | | | +| linux/s390x | | | +| windows/amd64 | | x | +| windows/arm64 | | | +| windows/arm | | | diff --git a/go.mod b/go.mod index 927b9531..8ae92f3d 100644 --- a/go.mod +++ b/go.mod @@ -8,7 +8,7 @@ require ( github.com/pkg/errors v0.8.1 github.com/prometheus/procfs v0.0.0-20190425082905-87a4384529e0 github.com/stretchr/testify v1.3.0 - golang.org/x/sys v0.0.0-20191025021431-6c3a3bfe00ae + golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a howett.net/plist v0.0.0-20181124034731-591f970eefbb ) diff --git a/go.sum b/go.sum index 49a2b603..43db4ec3 100644 --- a/go.sum +++ b/go.sum @@ -18,8 +18,8 @@ github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+ github.com/stretchr/testify v1.3.0 h1:TivCn/peBQ7UY8ooIcPgZFpTNSz0Q2U6UrFlUfqbe0Q= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sys v0.0.0-20191025021431-6c3a3bfe00ae h1:QoJmnb9uyPCrH8GIg9uRLn4Ta45yhcQtpymCd0AavO8= -golang.org/x/sys v0.0.0-20191025021431-6c3a3bfe00ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a h1:dGzPydgVsqGcTRVwiLJ1jVbufYwmzD3LfVPLKsKg+0k= +golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= diff --git a/providers/aix/boottime_aix.go b/providers/aix/boottime_aix_ppc64.go similarity index 97% rename from providers/aix/boottime_aix.go rename to providers/aix/boottime_aix_ppc64.go index fee34288..beaaa553 100644 --- a/providers/aix/boottime_aix.go +++ b/providers/aix/boottime_aix_ppc64.go @@ -15,6 +15,9 @@ // specific language governing permissions and limitations // under the License. +//go:build aix && ppc64 +// +build aix,ppc64 + package aix import ( diff --git a/providers/aix/boottime_test.go b/providers/aix/boottime_aix_ppc64_test.go similarity index 95% rename from providers/aix/boottime_test.go rename to providers/aix/boottime_aix_ppc64_test.go index c60bc415..73f8a4d0 100644 --- a/providers/aix/boottime_test.go +++ b/providers/aix/boottime_aix_ppc64_test.go @@ -15,8 +15,8 @@ // specific language governing permissions and limitations // under the License. -//go:build aix -// +build aix +//go:build aix && ppc64 +// +build aix,ppc64 package aix diff --git a/providers/aix/doc.go b/providers/aix/doc.go index 6bc0787e..aadec23a 100644 --- a/providers/aix/doc.go +++ b/providers/aix/doc.go @@ -16,5 +16,5 @@ // under the License. // Package aix implements the HostProvider and ProcessProvider interfaces -// for providing information about MacOS. +// for providing information about IBM AIX on ppc64. package aix diff --git a/providers/aix/host_aix.go b/providers/aix/host_aix_ppc64.go similarity index 98% rename from providers/aix/host_aix.go rename to providers/aix/host_aix_ppc64.go index 7fd83d61..36257cb9 100644 --- a/providers/aix/host_aix.go +++ b/providers/aix/host_aix_ppc64.go @@ -15,6 +15,9 @@ // specific language governing permissions and limitations // under the License. +//go:build aix && ppc64 && cgo +// +build aix,ppc64,cgo + package aix /* diff --git a/providers/aix/kernel_aix.go b/providers/aix/kernel_aix_ppc64.go similarity index 96% rename from providers/aix/kernel_aix.go rename to providers/aix/kernel_aix_ppc64.go index 3c05ea4a..23bc987e 100644 --- a/providers/aix/kernel_aix.go +++ b/providers/aix/kernel_aix_ppc64.go @@ -15,6 +15,9 @@ // specific language governing permissions and limitations // under the License. +//go:build aix && ppc64 && cgo +// +build aix,ppc64,cgo + package aix /* diff --git a/providers/aix/machineid_aix.go b/providers/aix/machineid_aix_ppc64.go similarity index 95% rename from providers/aix/machineid_aix.go rename to providers/aix/machineid_aix_ppc64.go index 3d02ddd0..1aab374f 100644 --- a/providers/aix/machineid_aix.go +++ b/providers/aix/machineid_aix_ppc64.go @@ -15,6 +15,9 @@ // specific language governing permissions and limitations // under the License. +//go:build aix && ppc64 && cgo +// +build aix,ppc64,cgo + package aix /* diff --git a/providers/aix/os_aix.go b/providers/aix/os_aix_ppc64.go similarity index 96% rename from providers/aix/os_aix.go rename to providers/aix/os_aix_ppc64.go index 61863e5a..d10476da 100644 --- a/providers/aix/os_aix.go +++ b/providers/aix/os_aix_ppc64.go @@ -15,6 +15,9 @@ // specific language governing permissions and limitations // under the License. +//go:build aix && ppc64 && cgo +// +build aix,ppc64,cgo + package aix import ( diff --git a/providers/aix/process_aix.go b/providers/aix/process_aix_ppc64.go similarity index 99% rename from providers/aix/process_aix.go rename to providers/aix/process_aix_ppc64.go index cccb4bd1..e586decf 100644 --- a/providers/aix/process_aix.go +++ b/providers/aix/process_aix_ppc64.go @@ -15,6 +15,9 @@ // specific language governing permissions and limitations // under the License. +//go:build aix && ppc64 && cgo +// +build aix,ppc64,cgo + package aix /* diff --git a/providers/aix/ztypes_aix_ppc64.go b/providers/aix/ztypes_aix_ppc64.go index 20c6b245..fb60e7dd 100644 --- a/providers/aix/ztypes_aix_ppc64.go +++ b/providers/aix/ztypes_aix_ppc64.go @@ -18,6 +18,9 @@ // Code generated by cmd/cgo -godefs; DO NOT EDIT. // cgo -godefs defs_aix.go +//go:build aix && ppc64 +// +build aix,ppc64 + package aix type prcred struct {