shirou / gopsutil

psutil for golang
Other
10.47k stars 1.58k forks source link

Can't compile for openbsd #1539

Closed Equationzhao closed 10 months ago

Equationzhao commented 11 months ago

Describe the bug I was trying to build my project in Openbsd and got the following compile error

# github.com/shirou/gopsutil/disk
../go/pkg/mod/github.com/shirou/gopsutil@v3.21.11+incompatible/disk/disk_openbsd.go:59:53: cannot use stat.F_mntfromname[:] (value of type []byte) as []int8 value in argument to common.IntToString
../go/pkg/mod/github.com/shirou/gopsutil@v3.21.11+incompatible/disk/disk_openbsd.go:60:51: cannot use stat.F_mntonname[:] (value of type []byte) as []int8 value in argument to common.IntToString
../go/pkg/mod/github.com/shirou/gopsutil@v3.21.11+incompatible/disk/disk_openbsd.go:61:52: cannot use stat.F_fstypename[:] (value of type []byte) as []int8 value in argument to common.IntToString
../go/pkg/mod/github.com/shirou/gopsutil@v3.21.11+incompatible/disk/disk_openbsd.go:149:45: cannot use stat.F_fstypename[:] (value of type []byte) as []int8 value in argument to common.IntToString

To Reproduce

CGO_ENABLED="0" GOOS=openbsd gob 

Expected behavior pass the compilation

Environment (please complete the following information):

sw_vers

ProductName:            macOS
ProductVersion:         14.1
BuildVersion:           23B5056e

uname -a

Darwin MacBook 23.1.0 Darwin Kernel Version 23.1.0: Tue Sep 26 22:11:22 PDT 2023; root:xnu-10002.40.89.501.1~3/RELEASE_ARM64_T8112 arm64

I was doing a cross-compile in macOS, target platform OpenBSD arm64

Additional context

command

CGO_ENABLED="0" GOOS=openbsd gob 

go env

GO111MODULE='on'
GOARCH='arm64'
GOBIN='/Users/equationzhao/go/bin'
GOCACHE='/Users/equationzhao/Library/Caches/go-build'
GOENV='/Users/equationzhao/Library/Application Support/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFLAGS=''
GOHOSTARCH='arm64'
GOHOSTOS='darwin'
GOINSECURE=''
GOMODCACHE='/Users/equationzhao/go/pkg/mod'
GONOPROXY=''
GONOSUMDB=''
GOOS='darwin'
GOPATH='/Users/equationzhao/go'
GOPRIVATE=''
GOPROXY='https://goproxy.cn,direct'
GOROOT='/opt/homebrew/opt/go/libexec'
GOSUMDB='sum.golang.org'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/opt/homebrew/opt/go/libexec/pkg/tool/darwin_arm64'
GOVCS=''
GOVERSION='go1.21.3'
GCCGO='gccgo'
AR='ar'
CC='cc'
CXX='c++'
CGO_ENABLED='1'
GOMOD='/Users/equationzhao/g/go.mod'
GOWORK=''
CGO_CFLAGS='-O2 -g'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-O2 -g'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-O2 -g'
PKG_CONFIG='pkg-config'
GOGCCFLAGS='-fPIC -arch arm64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -ffile-prefix-map=/var/folders/nk/ph0hr4095336ty09grw2v_740000gn/T/go-build4237779211=/tmp/go-build -gno-record-gcc-switches -fno-common'
Equationzhao commented 11 months ago
image
Lomanic commented 10 months ago

This is a duplicate of #1309 as you are using an obsolete v2 version from 2021, switch to v3.

Confirmed with

go mod init issue1539
go get -v github.com/shirou/gopsutil/v3/...
GOOS=openbsd go build github.com/shirou/gopsutil/v3/...