(BUG REPORT) Wrong CGO conditions in golang/glog

130 views
Skip to first unread message

方佳文

unread,
Jun 19, 2023, 2:46:32 PM6/19/23
to golan...@googlegroups.com

There is a bug in golang/glog that the CGO condition is wrong.


//go:build linux


//go:build !(unix || windows)

On the Linux platform, the function will be declared twice. The problem is actually caused by the wrong CGO conditions, instead of the low Go version.

GOOS=linux ~/go1.18/bin/go build -o exe ./example/main.go 
../../go/pkg/mod/github.com/golang/gl...@v1.1.1/glog_file_other.go:27:6: abortProcess redeclared in this block
        ../../go/pkg/mod/github.com/golang/gl...@v1.1.1/glog_file_linux.go:33:6: other declaration of abortProcess
note: module requires Go 1.19

The correct condition should be:

//go:build !(unix || windows || linux)

Because you already have glog_file_linux.go

Sincerely,
Garen Fang

Ian Lance Taylor

unread,
Jun 19, 2023, 5:18:51 PM6/19/23
to 方佳文, golan...@googlegroups.com
The build constraint "unix" matches "GOOS=linux".

Your problem is that the "unix" build constraint was only added in Go
1.19 (see https://go.dev/doc/go1.19#go-unix). As the error message
above says "note: module requires Go 1.19". Go 1.18 is no longer
supported, and the glog package requires at least Go 1.19.

Ian
Reply all
Reply to author
Forward
0 new messages