xenserver / xe-guest-utilities

XenServer guest utilities for unix-like operating systems
BSD 2-Clause "Simplified" License
63 stars 57 forks source link

unsafe.Slice requires go1.17 or later #132

Closed kevdogg closed 1 year ago

kevdogg commented 2 years ago

Trying to build with go version 1.18.

I'm getting the following error:

# golang.org/x/sys/unix
vendor/golang.org/x/sys/unix/syscall.go:83:16: unsafe.Slice requires go1.17 or later (-lang was set to go1.16; check go.mod)
vendor/golang.org/x/sys/unix/syscall_linux.go:2255:9: unsafe.Slice requires go1.17 or later (-lang was set to go1.16; check go.mod)
vendor/golang.org/x/sys/unix/syscall_unix.go:118:7: unsafe.Slice requires go1.17 or later (-lang was set to go1.16; check go.mod)
vendor/golang.org/x/sys/unix/sysvshm_unix.go:33:7: unsafe.Slice requires go1.17 or later (-lang was set to go1.16; check go.mod)
make: *** [Makefile:90: /home/kevdog/src/xe-guest-utilities/build/obj/xenstore] Error 2

My go.mod file is as follows:

module github.com/xenserver/xe-guest-utilities

go 1.16

require golang.org/x/sys v0.1.0 
xihuan-citrix commented 2 years ago

Hi @kevdogg , you could modify the go.mod during build with go mod tidy

kevdogg commented 2 years ago

I've never used go -- but here are my steps:

root@ubuntuxo:/# set GOPATH=$(pwd)

root@ubuntuxo:/# git clone https://github.com/xenserver/xe-guest-utilities.git $GOPATH/src/xe-guest-utilities
Cloning into '/src/xe-guest-utilities'...
remote: Enumerating objects: 698, done.
remote: Counting objects: 100% (140/140), done.
remote: Compressing objects: 100% (57/57), done.
remote: Total 698 (delta 109), reused 87 (delta 81), pack-reused 558
Receiving objects: 100% (698/698), 165.59 KiB | 2.55 MiB/s, done.
Resolving deltas: 100% (342/342), done.

root@ubuntuxo:/# cd /src/xe-guest-utilities

root@ubuntuxo:/src/xe-guest-utilities# go mod tidy

root@ubuntuxo:/src/xe-guest-utilities# make
****** Replace product version for: [/src/xe-guest-utilities/xe-daemon/xe-daemon.go] *****
mkdir -p $(dirname /src/xe-guest-utilities/build/gobuild/xe-daemon/xe-daemon.go)
cat /src/xe-guest-utilities/xe-daemon/xe-daemon.go | \
sed -e "s/@PRODUCT_MAJOR_VERSION@/6/g" | \
sed -e "s/@PRODUCT_MINOR_VERSION@/6/g" | \
sed -e "s/@PRODUCT_MICRO_VERSION@/80/g" | \
sed -e "s/@NUMERIC_BUILD_NUMBER@/154/g" \
> /src/xe-guest-utilities/build/gobuild/xe-daemon/xe-daemon.go
****** Replace product version for: [/src/xe-guest-utilities/syslog/syslog.go] *****
mkdir -p $(dirname /src/xe-guest-utilities/build/gobuild/syslog/syslog.go)
cat /src/xe-guest-utilities/syslog/syslog.go | \
sed -e "s/@PRODUCT_MAJOR_VERSION@/6/g" | \
sed -e "s/@PRODUCT_MINOR_VERSION@/6/g" | \
sed -e "s/@PRODUCT_MICRO_VERSION@/80/g" | \
sed -e "s/@NUMERIC_BUILD_NUMBER@/154/g" \
> /src/xe-guest-utilities/build/gobuild/syslog/syslog.go
****** Replace product version for: [/src/xe-guest-utilities/system/system.go] *****
mkdir -p $(dirname /src/xe-guest-utilities/build/gobuild/system/system.go)
cat /src/xe-guest-utilities/system/system.go | \
sed -e "s/@PRODUCT_MAJOR_VERSION@/6/g" | \
sed -e "s/@PRODUCT_MINOR_VERSION@/6/g" | \
sed -e "s/@PRODUCT_MICRO_VERSION@/80/g" | \
sed -e "s/@NUMERIC_BUILD_NUMBER@/154/g" \
> /src/xe-guest-utilities/build/gobuild/system/system.go
****** Replace product version for: [/src/xe-guest-utilities/guestmetric/guestmetric.go] *****
mkdir -p $(dirname /src/xe-guest-utilities/build/gobuild/guestmetric/guestmetric.go)
cat /src/xe-guest-utilities/guestmetric/guestmetric.go | \
sed -e "s/@PRODUCT_MAJOR_VERSION@/6/g" | \
sed -e "s/@PRODUCT_MINOR_VERSION@/6/g" | \
sed -e "s/@PRODUCT_MICRO_VERSION@/80/g" | \
sed -e "s/@NUMERIC_BUILD_NUMBER@/154/g" \
> /src/xe-guest-utilities/build/gobuild/guestmetric/guestmetric.go
****** Replace product version for: [/src/xe-guest-utilities/guestmetric/guestmetric_linux.go] *****
mkdir -p $(dirname /src/xe-guest-utilities/build/gobuild/guestmetric/guestmetric_linux.go)
cat /src/xe-guest-utilities/guestmetric/guestmetric_linux.go | \
sed -e "s/@PRODUCT_MAJOR_VERSION@/6/g" | \
sed -e "s/@PRODUCT_MINOR_VERSION@/6/g" | \
sed -e "s/@PRODUCT_MICRO_VERSION@/80/g" | \
sed -e "s/@NUMERIC_BUILD_NUMBER@/154/g" \
> /src/xe-guest-utilities/build/gobuild/guestmetric/guestmetric_linux.go
****** Replace product version for: [/src/xe-guest-utilities/xenstoreclient/xenstore.go] *****
mkdir -p $(dirname /src/xe-guest-utilities/build/gobuild/xenstoreclient/xenstore.go)
cat /src/xe-guest-utilities/xenstoreclient/xenstore.go | \
sed -e "s/@PRODUCT_MAJOR_VERSION@/6/g" | \
sed -e "s/@PRODUCT_MINOR_VERSION@/6/g" | \
sed -e "s/@PRODUCT_MICRO_VERSION@/80/g" | \
sed -e "s/@NUMERIC_BUILD_NUMBER@/154/g" \
> /src/xe-guest-utilities/build/gobuild/xenstoreclient/xenstore.go
***** Build xe-daemon ******
(cd /src/xe-guest-utilities/vendor/xe-guest-utilities && ln -sfn ../../build/gobuild/guestmetric guestmetric)
(cd /src/xe-guest-utilities/vendor/xe-guest-utilities && ln -sfn ../../build/gobuild/syslog syslog)
(cd /src/xe-guest-utilities/vendor/xe-guest-utilities && ln -sfn ../../build/gobuild/system system)
(cd /src/xe-guest-utilities/vendor/xe-guest-utilities && ln -sfn ../../build/gobuild/xenstoreclient xenstoreclient)
mkdir -p /src/xe-guest-utilities/build/obj
go build -v -o /src/xe-guest-utilities/build/obj/xe-daemon /src/xe-guest-utilities/build/gobuild/xe-daemon/xe-daemon.go
****** Replace product version for: [/src/xe-guest-utilities/xenstore/xenstore.go] *****
mkdir -p $(dirname /src/xe-guest-utilities/build/gobuild/xenstore/xenstore.go)
cat /src/xe-guest-utilities/xenstore/xenstore.go | \
sed -e "s/@PRODUCT_MAJOR_VERSION@/6/g" | \
sed -e "s/@PRODUCT_MINOR_VERSION@/6/g" | \
sed -e "s/@PRODUCT_MICRO_VERSION@/80/g" | \
sed -e "s/@NUMERIC_BUILD_NUMBER@/154/g" \
> /src/xe-guest-utilities/build/gobuild/xenstore/xenstore.go
***** Build xenstore ******
mkdir -p /src/xe-guest-utilities/build/obj
go build -v -o /src/xe-guest-utilities/build/obj/xenstore /src/xe-guest-utilities/build/gobuild/xenstore/xenstore.go
build/gobuild/xenstore/xenstore.go:6:2: cannot find package "." in:
    /src/xe-guest-utilities/vendor/golang.org/x/sys/unix
make: *** [Makefile:90: /src/xe-guest-utilities/build/obj/xenstore] Error 1
xihuan-citrix commented 1 year ago

I will check this issue and open an PR

kevdogg commented 1 year ago

Hey just some more feedback with the issue. I finally was able to compile from source however I had to do a lot of work since the instructions on the main page were definitely not correct because of the changes with how the make process works introduced from with go 1.17.

I downloaded the git sources. Then installed the unix modules which in the process the go.mod file was overwritten. I also when asked choose to sync the system's vendor file chose yes which ended up overwriting the vendor/modules.txt file.

For disclosure my test system was the following:

# lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 22.04.1 LTS
Release:    22.04
Codename:   jammy

# go version
go version go1.18.1 linux/amd64

I ended up using the following go.mod file:

module github.com/xenserver/xe-guest-utilities

go 1.18

require golang.org/x/sys v0.2.0

My vendor/modules.txt file was the following:

# golang.org/x/sys v0.2.0
## explicit; go 1.18
golang.org/x/sys/internal/unsafeheader
golang.org/x/sys/unix

What I can't understand however is that after compiling from source the resultant sources are labeled:xe-guest-utilities_6.6.80-155_x86_64.tgz

Is this version number correct as I have some over machines currently using agent version 7.30.0-11 which I ended up installing from xcp-ng source distro.

Thanks for help.

xihuan-citrix commented 1 year ago
  1. Above version number, should change it yourself during building. Any way I am already raised a PR https://github.com/xenserver/xe-guest-utilities/pull/134
  2. The unsafe.Slice requires go1.17 did show if I change the golang.org/x/sys to the latest version e.g. 0.2.0
xihuan-citrix commented 1 year ago

With the above new PR and modiy go.mod

# cat go.mod
module github.com/xenserver/xe-guest-utilities

go 1.19

require golang.org/x/sys v0.2.0
# cat go.sum
golang.org/x/sys v0.2.0 h1:ljd4t30dBnAvMZaQCevtY0xLLD0A+bRZXbgLMLU1F/A=

Successfully built with modify go.mod go mod tidy go mod vendor make

xihuan-citrix commented 1 year ago

Will close this issue for already resolved