Skip to content

x/sys/unix: does not support building on Solaris with gccgo #49161

@bearx3f

Description

@bearx3f

What version of Go are you using (go version)?

$ gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/local/libexec/gcc/sparcv9-sun-solaris2.11/11.2.0/lto-wrapper
Target: sparcv9-sun-solaris2.11
Configured with: /usr/src/gcc/configure --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=sparcv9-sun-solaris2.11 --with-sysroot=/sysroot/sparcv9-sun-solaris2.11 --with-gnu-as --with-gnu-ld --with-static-standard-libraries --disable-documentation --disable-libgcj --disable-multilib --disable-shared --enable-stage1-languages=c --enable-languages=c,c++,go -v
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 11.2.0 (GCC) 

$ gccgo -v
Using built-in specs.
COLLECT_GCC=gccgo
COLLECT_LTO_WRAPPER=/usr/local/libexec/gcc/sparcv9-sun-solaris2.11/11.2.0/lto-wrapper
Target: sparcv9-sun-solaris2.11
Configured with: /usr/src/gcc/configure --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=sparcv9-sun-solaris2.11 --with-sysroot=/sysroot/sparcv9-sun-solaris2.11 --with-gnu-as --with-gnu-ld --with-static-standard-libraries --disable-documentation --disable-libgcj --disable-multilib --disable-shared --enable-stage1-languages=c --enable-languages=c,c++,go -v
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 11.2.0 (GCC) 

$ go version
go version go1.16.3 linux/amd64

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 Output
$ go env
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/root/.cache/go-build"
GOENV="/root/.config/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GOMODCACHE="/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
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.16.3"
GCCGO="/usr/local/bin/gccgo"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/builds/app/gravitron2/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-build4161522405=/tmp/go-build -gno-record-gcc-switches"

What did you do?

using github.com/gin-gonic/gin
and cross compile with gccgo 11.2.0

  • host amd64
  • target sparcv9-sun-solaris2.11
$ go build -compiler gccgo -trimpath -gccgoflags="-O3 -Wall -s -static-libgo -Wl,-dy -lnsl -lsocket -lrt" test-xcc/cmd/test3
package main

import "github.com/gin-gonic/gin"

func main() {
	r := gin.Default()
	r.Run(":80")
}

What did you expect to see?

successfully compile without any warning or errors

What did you see instead?

go: downloading github.com/gin-gonic/gin v1.7.4
go: downloading github.com/gin-contrib/sse v0.1.0
go: downloading github.com/mattn/go-isatty v0.0.14
go: downloading gopkg.in/yaml.v2 v2.4.0
go: downloading github.com/ugorji/go v1.2.6
go: downloading github.com/go-playground/validator/v10 v10.9.0
go: downloading github.com/golang/protobuf v1.5.2
go: downloading golang.org/x/sys v0.0.0-20211025201205-69cdffdb9359
go: downloading github.com/ugorji/go/codec v1.2.6
go: downloading github.com/leodido/go-urn v1.2.1
go: downloading github.com/go-playground/universal-translator v0.18.0
go: downloading golang.org/x/crypto v0.0.0-20210921155107-089bfa567519
go: downloading golang.org/x/text v0.3.7
go: downloading google.golang.org/protobuf v1.27.1
go: downloading github.com/go-playground/locales v0.14.0
# golang.org/x/sys/unix
/go/pkg/mod/golang.org/x/sys@v0.0.0-20211025201205-69cdffdb9359/unix/gccgo_c.c: In function 'gccgoRealSyscall':
/go/pkg/mod/golang.org/x/sys@v0.0.0-20211025201205-69cdffdb9359/unix/gccgo_c.c:33:15: warning: implicit declaration of function 'syscall' [-Wimplicit-function-declaration]
   33 |         r.r = syscall(trap, a1, a2, a3, a4, a5, a6, a7, a8, a9);
      |               ^~~~~~~

and when run

$ GIN_MODE=release ./test3
SIGSYS: bad system call
PC=0x1001f12f4 m=0 sigcode=32767

goroutine 1 [syscall]:
__sighndlr
        :0
_syscall
        :0

and sometime i got this

SIGSYS: bad system call
PC=0x0 m=0 sigcode=32767

goroutine 1 [syscall]:
syscall
        :0
golang_0org_1x_1sys_1unix.realSyscall
        /go/pkg/mod/golang.org/x/sys@v0.0.0-20211025201205-69cdffdb9359/unix/gccgo_c.c:33

Metadata

Metadata

Assignees

No one assigned

    Labels

    NeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.compiler/runtimeIssues related to the Go compiler and/or runtime.

    Type

    No type

    Projects

    Status

    Triage Backlog

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions