Open bearx3f opened 2 years ago
This doesn't seem to be a bug in gccgo itself.
The build of golang.org/x/sys/unix is getting the warning because the C file isn't including the right header file; I guess it should be including <sys/syscall.h>
. The warning by itself shouldn't be a problem, though. The program then appears to crash when it calls unix.Syscall
, crashing because it is trying to make a bad system call. But I don't know why the program is calling unix.Syscall
; do you? Try running it under the debugger; you may get a better stack trace.
Thank you for your response
look like github.com/mattn/go-isatty
is the one who call unix.Syscall
Reading symbols from ./bin/test3... (gdb) r Starting program: /export/home/oracle/test/bin/test3 [Thread debugging using libthread_db enabled] [New Thread 1 (LWP 1)] [New LWP 2 ] [New LWP 3 ] [New LWP 4 ] [New LWP 5 ] GOOS solaris GOARCH sparc64 [GIN-debug] [WARNING] Creating an Engine instance with the Logger and Recovery middleware already attached. [GIN-debug] [WARNING] Running in "debug" mode. Switch to "release" mode in production. - using env: export GIN_MODE=release - using code: gin.SetMode(gin.ReleaseMode) [New Thread 2 (LWP 2)] [New Thread 3 ] [New Thread 4 ] [New Thread 5 (LWP 5)] Thread 2 received signal SIGSYS, Bad system call. [Switching to Thread 1 (LWP 1)] 0xffffffff58de2d54 in syscall () from /lib/64/libc.so.1 (gdb) bt #0 0xffffffff58de2d54 in syscall () from /lib/64/libc.so.1 #1 0x00000001001f1b04 in golang_0org_1x_1sys_1unix.realSyscall (trap=16, a1=1, a2=21505, a3=824638662240, a4=0, a5=0, a6=0, a7=0, a8=0, a9=0) at ./vendor/golang.org/x/sys/unix/gccgo_c.c:34 #2 0x00000001001bc0a4 in golang_0org_1x_1sys_1unix.Syscall (trap=16, a1=1, a2=21505, a3=824638662240) at fdset.go:28 #3 0x00000001001d5ce8 in golang_0org_1x_1sys_1unix.ioctl (fd=1, req=21505, arg=824638662240) at zptrace_x86_linux.go:42 #4 0x00000001001bd544 in golang_0org_1x_1sys_1unix.IoctlGetTermios (fd=1, req=21505) at ifreq_linux.go:73 #5 0x00000001000425fc in github_0com_1mattn_1go_x2disatty.IsTerminal (fd=1) at ./vendor/github.com/mattn/go-isatty/doc.go:11 #6 0x000000010001a3f8 in github_0com_1gin_x2dgonic_1gin.LoggerWithConfig (conf=...) at gin.go:220 #7 0x0000000100019ef0 in github_0com_1gin_x2dgonic_1gin.Logger () at gin.go:184 #8 0x0000000100013800 in github_0com_1gin_x2dgonic_1gin.Default () at fs.go:183 #9 0x0000000100004368 in main.main () at ./cmd/test3/main.go:13
Something is wrong. A build for Solaris should not be running any code in zptrace_x86_linux.go.
When you run your go build
command, try setting GOOS=solaris
in the environment. That will tell the go command that you are building a cross-compiler.
I got this after when compiled with GOOS=solaris
I think GOARCH
and target of gccgo (sparcv9-sun-solaris2.11)
are conflicts
$ go build -compiler gccgo -o bin/$APP -trimpath -gccgoflags="-g1 -O0 -Wall -static-libgo" test-xcc/cmd/$APP
# golang.org/x/sys/unix
vendor/golang.org/x/sys/unix/zsyscall_solaris_amd64.go:171:3: error: procAccess is not a function; '//go:linkname' is only supported for functions
171 | //go:linkname procAccess libc_access
| ^
vendor/golang.org/x/sys/unix/zsyscall_solaris_amd64.go:172:3: error: procAdjtime is not a function; '//go:linkname' is only supported for functions
172 | //go:linkname procAdjtime libc_adjtime
| ^
vendor/golang.org/x/sys/unix/zsyscall_solaris_amd64.go:173:3: error: procChdir is not a function; '//go:linkname' is only supported for functions
173 | //go:linkname procChdir libc_chdir
| ^
----- snipped (many more) -----
go env after GOOS=solaris
$ go env
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/root/.cache/go-build"
GOENV="/root/.config/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GOMODCACHE="/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="solaris"
GOPATH="/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64"
GOVCS=""
GOVERSION="go1.17.2"
GCCGO="/usr/local/bin/gccgo"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="0"
GOMOD="/builds/booboo/sparcv9-sun-solaris2.11-xcc-toolchain-test/go.mod"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build3649007841=/tmp/go-build -gno-record-gcc-switches"
Setting GOOS
to match the gccgo target is required.
What you've discovered is that golang.org/x/sys/unix does not support Solaris when using gccgo. That is a bug that needs to be addressed in golang.org/x/sys/unix.
I looking forward to this bug to be fix
Thanks
hi, I experienced the same problem when I tried to use golang.org/x/sys under Solaris; is there any update on this bug? Thanks.
======= package main import ( "fmt" "golang.org/x/sys/unix" ) func main(){ name := "./test.log" fd, err := unix.Open(name, unix.O_CREAT|unix.O_RDWR|unix.O_CLOEXEC, 0) if err != nil { fmt.Println("Open failed: %v", err) } defer unix.Close(fd) flock := unix.Flock_t{ Type: unix.F_RDLCK, Start: 0, Len: 0, Whence: 1, } if err := unix.FcntlFlock(uintptr(fd), unix.F_GETLK, &flock); err != nil { fmt.Println("FcntlFlock failed: %v", err) } }
========== $go build syscall.go
../../go/pkg/mod/golang.org/x/sys@v0.0.0-20201029020603-3518587229cd/unix/zsyscall_solaris_amd64.go:162:3: error: procAccess is not a function; ‘//go:linkname’ is only supported for functions 162 | //go:linkname procAccess libc_access | ^ ../../go/pkg/mod/golang.org/x/sys@v0.0.0-20201029020603-3518587229cd/unix/zsyscall_solaris_amd64.go:163:3: error: procAdjtime is not a function; ‘//go:linkname’ is only supported for functions 163 | //go:linkname procAdjtime libc_adjtime | ^ .....
$uname -m -o -p -i i86pc i386 i86pc Solaris
$gccgo --version gccgo (GCC) 11.3.0
$go env GO111MODULE="" GOARCH="amd64" GOBIN="" GOCACHE="/builds/shifezha/.cache/go-build" GOENV="/home/shifezha/.config/go/env" GOEXE="" GOFLAGS="" GOHOSTARCH="amd64" GOHOSTOS="solaris" GOINSECURE="" GOMODCACHE="/builds/shifezha/go/pkg/mod" GONOPROXY="" GONOSUMDB="" GOOS="solaris" GOPATH="/builds/shifezha/go" GOPRIVATE="" GOPROXY="https://proxy.golang.org,direct" GOROOT="/usr/gcc/11" GOSUMDB="sum.golang.org" GOTMPDIR="" GOTOOLDIR="/usr/gcc/11/lib/gcc/x86_64-pc-solaris2.11/11.3.0" GOVCS="" GOVERSION="go1.16.5 gccgo (GCC) 11.3.0" GCCGO="/usr/gcc/11/bin/gccgo" AR="ar" CC="gcc" CXX="g++" CGO_ENABLED="1" GOMOD="/builds/shifezha/test/unixsyscall/go.mod" CGO_CFLAGS="-g -O2" CGO_CPPFLAGS="" CGO_CXXFLAGS="-g -O2" CGO_FFLAGS="-g -O2" CGO_LDFLAGS="-g -O2" PKG_CONFIG="pkg-config" GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build1559705635=/tmp/go-build -gno-record-gcc-switches -funwind-tables"
@ianlancetaylor I really want this gonna work Are there any potential workarounds or solutions available to me?
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
yes
latest gccgo is 11.2.0
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
using github.com/gin-gonic/gin and cross compile with gccgo 11.2.0
What did you expect to see?
successfully compile without any warning or errors
What did you see instead?
and when run
and sometime i got this