-
Notifications
You must be signed in to change notification settings - Fork 230
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
Broken change of golang.org/x/sys causes build failed in go1.16 #163
Comments
I can't reproduce this error, could you list a more detailed reproduction process? thanks! My steps:
|
This is because bytedance/gopkg doesn't depend on golang.org/x/sys/unix. Let's create a package that depends on it then you will see the problem:
$ /usr/local/go1.16.15/bin/go version
go version go1.16.15 linux/amd64
$ mkdir -p ~/go/src/test/issue163 && cd ~/go/src/test/issue163
$ touch go.mod
$ touch main.go
//go:build linux
// +build linux
package main
import (
"github.com/bytedance/gopkg/util/gopool"
"golang.org/x/sys/unix"
)
func main() {
_ = gopool.NewPool
_ = unix.Fadvise
}
module test/issue163
go 1.16
$ /usr/local/go1.16.15/bin/go mod tidy
go: finding module for package golang.org/x/sys/unix
go: finding module for package github.com/bytedance/gopkg/util/gopool
go: found github.com/bytedance/gopkg/util/gopool in github.com/bytedance/gopkg v0.0.0-20221122125632-68358b8ecec6
go: found golang.org/x/sys/unix in golang.org/x/sys v0.3.0 after current step our go.mod will look like this: module test/issue163
go 1.16
require (
github.com/bytedance/gopkg v0.0.0-20221122125632-68358b8ecec6
golang.org/x/sys v0.3.0
)
$ /usr/local/go1.16.15/bin/go build
# golang.org/x/sys/unix
../../../pkg/mod/golang.org/x/[email protected]/unix/syscall.go:83:16: undefined: unsafe.Slice
../../../pkg/mod/golang.org/x/[email protected]/unix/syscall_linux.go:2256:9: undefined: unsafe.Slice
../../../pkg/mod/golang.org/x/[email protected]/unix/syscall_unix.go:118:7: undefined: unsafe.Slice
../../../pkg/mod/golang.org/x/[email protected]/unix/sysvshm_unix.go:33:7: undefined: unsafe.Slice
note: module requires Go 1.17
module test/issue163
go 1.16
require (
github.com/bytedance/gopkg v0.0.0-20221122125632-68358b8ecec6
golang.org/x/sys v0.0.0-20220110181412-a018aaa089fe
) NOTE: a commonly used library in ByteDance use golang.org/x/sys v0.0.0-20220110181412-a018aaa089fe
$ /usr/local/go1.16.15/bin/go mod tidy then our go.mod will look like this: module test/issue163
go 1.16
require (
github.com/bytedance/gopkg v0.0.0-20221122125632-68358b8ecec6
golang.org/x/sys v0.0.0-20221010170243-090e33056c14
) the version of golang.org/x/sys will be changed to v0.0.0-20221010170243-090e33056c14 since bytedance/gopkg choose it.
$ /usr/local/go1.16.15/bin/go build
# golang.org/x/sys/unix
../../../pkg/mod/golang.org/x/[email protected]/unix/syscall.go:83:16: undefined: unsafe.Slice
../../../pkg/mod/golang.org/x/[email protected]/unix/syscall_linux.go:2255:9: undefined: unsafe.Slice
../../../pkg/mod/golang.org/x/[email protected]/unix/syscall_unix.go:118:7: undefined: unsafe.Slice
../../../pkg/mod/golang.org/x/[email protected]/unix/sysvshm_unix.go:33:7: undefined: unsafe.Slice
note: module requires Go 1.17 |
Question
Current go.mod use go1.16 with golang.org/x/sys v0.0.0-20221010170243-090e33056c14 package which introduced go1.17's unsafe.Slice in 20220910 (see history https://cs.opensource.google/go/x/sys/+/master:unix/syscall.go;bpv=1). This will cause build failed in go1.16 with following error messges.
The text was updated successfully, but these errors were encountered: