Skip to content
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

gccgo: cross compiling with GCC11.1 cause many undefined reference #45843

Closed
bearx3f opened this issue Apr 29, 2021 · 10 comments
Closed

gccgo: cross compiling with GCC11.1 cause many undefined reference #45843

bearx3f opened this issue Apr 29, 2021 · 10 comments
Assignees
Milestone

Comments

@bearx3f
Copy link

@bearx3f bearx3f commented Apr 29, 2021

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

$ go version
1.16.3

Does this issue reproduce with the latest release?

yes

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/booboo/test-cross-compile-gccgo-sparcv9-sun-solaris/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-build2245835495=/tmp/go-build -gno-record-gcc-switches"

What did you do?

compile go with gccgo

I'm guessing link func name is missing last character

sparcv9-sun-solaris2.11-ld -v Output
$ sparcv9-sun-solaris2.11-ld -v
GNU ld (GNU Binutils) 2.35.2
gccgo -v Output
$ gccgo -v
Using built-in specs.
COLLECT_GCC=gccgo
COLLECT_LTO_WRAPPER=/usr/local/libexec/gcc/sparcv9-sun-solaris2.11/11.1.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
go build -compiler gccgo -o bin_gcc11 -trimpath -gccgoflags="-O3 -Wall -s -static-libgo -Wl,-dy -lnsl -lsocket -lrt"

What did you expect to see?

successfully compile

What did you see instead?

# test-cross-compile-gccgo-sparcv9-sun-solaris
/usr/local/lib/gcc/sparcv9-sun-solaris2.11/11.1.0/../../../../sparcv9-sun-solaris2.11/bin/ld: /usr/local/lib/gcc/sparcv9-sun-solaris2.11/11.1.0/../../../../sparcv9-sun-solaris2.11/lib/sparcv9/libgo.a(runtime.o): in function `runtime.fatalpanic..func1':
/usr/src/gcc/libgo/go/runtime/panic.go:1109: undefined reference to `exi'
/usr/local/lib/gcc/sparcv9-sun-solaris2.11/11.1.0/../../../../sparcv9-sun-solaris2.11/bin/ld: /usr/local/lib/gcc/sparcv9-sun-solaris2.11/11.1.0/../../../../sparcv9-sun-solaris2.11/lib/sparcv9/libgo.a(runtime.o): in function `runtime.afterfork':
/usr/src/gcc/libgo/go/runtime/signal_unix.go:988: undefined reference to `sigprocmas'
/usr/local/lib/gcc/sparcv9-sun-solaris2.11/11.1.0/../../../../sparcv9-sun-solaris2.11/bin/ld: /usr/local/lib/gcc/sparcv9-sun-solaris2.11/11.1.0/../../../../sparcv9-sun-solaris2.11/lib/sparcv9/libgo.a(runtime.o): in function `runtime.beforefork':
/usr/src/gcc/libgo/go/runtime/signal_unix.go:977: undefined reference to `sigprocmas'
/usr/local/lib/gcc/sparcv9-sun-solaris2.11/11.1.0/../../../../sparcv9-sun-solaris2.11/bin/ld: /usr/src/gcc/libgo/go/runtime/signal_unix.go:1002: undefined reference to `sigfillse'
/usr/local/lib/gcc/sparcv9-sun-solaris2.11/11.1.0/../../../../sparcv9-sun-solaris2.11/bin/ld: /usr/local/lib/gcc/sparcv9-sun-solaris2.11/11.1.0/../../../../sparcv9-sun-solaris2.11/lib/sparcv9/libgo.a(runtime.o): in function `runtime.sigblock':
/usr/src/gcc/libgo/go/runtime/signal_unix.go:1003: undefined reference to `sigprocmas'
/usr/local/lib/gcc/sparcv9-sun-solaris2.11/11.1.0/../../../../sparcv9-sun-solaris2.11/bin/ld: /usr/local/lib/gcc/sparcv9-sun-solaris2.11/11.1.0/../../../../sparcv9-sun-solaris2.11/lib/sparcv9/libgo.a(runtime.o): in function `syscall.Exit':
/usr/src/gcc/libgo/go/runtime/runtime.go:66: undefined reference to `exi'
/usr/local/lib/gcc/sparcv9-sun-solaris2.11/11.1.0/../../../../sparcv9-sun-solaris2.11/bin/ld: /usr/local/lib/gcc/sparcv9-sun-solaris2.11/11.1.0/../../../../sparcv9-sun-solaris2.11/lib/sparcv9/libgo.a(runtime.o): in function `runtime.setsig':
/usr/src/gcc/libgo/go/runtime/signal_gccgo.go:81: undefined reference to `sigfillse'
/usr/local/lib/gcc/sparcv9-sun-solaris2.11/11.1.0/../../../../sparcv9-sun-solaris2.11/bin/ld: /usr/src/gcc/libgo/go/runtime/signal_gccgo.go:83: undefined reference to `sigactio'
/usr/local/lib/gcc/sparcv9-sun-solaris2.11/11.1.0/../../../../sparcv9-sun-solaris2.11/bin/ld: /usr/local/lib/gcc/sparcv9-sun-solaris2.11/11.1.0/../../../../sparcv9-sun-solaris2.11/lib/sparcv9/libgo.a(runtime.o): in function `syscall.runtime__AfterForkInChild':
/usr/src/gcc/libgo/go/runtime/signal_unix.go:988: undefined reference to `sigprocmas'
/usr/local/lib/gcc/sparcv9-sun-solaris2.11/11.1.0/../../../../sparcv9-sun-solaris2.11/bin/ld: /usr/local/lib/gcc/sparcv9-sun-solaris2.11/11.1.0/../../../../sparcv9-sun-solaris2.11/lib/sparcv9/libgo.a(runtime.o): in function `runtime.sigaddset':
/usr/src/gcc/libgo/go/runtime/signal_gccgo.go:137: undefined reference to `sigaddse'
/usr/local/lib/gcc/sparcv9-sun-solaris2.11/11.1.0/../../../../sparcv9-sun-solaris2.11/bin/ld: /usr/local/lib/gcc/sparcv9-sun-solaris2.11/11.1.0/../../../../sparcv9-sun-solaris2.11/lib/sparcv9/libgo.a(runtime.o): in function `runtime.dieFromSignal':
/usr/src/gcc/libgo/go/runtime/signal_unix.go:1014: undefined reference to `sigemptyse'
/usr/local/lib/gcc/sparcv9-sun-solaris2.11/11.1.0/../../../../sparcv9-sun-solaris2.11/bin/ld: /usr/local/lib/gcc/sparcv9-sun-solaris2.11/11.1.0/../../../../sparcv9-sun-solaris2.11/lib/sparcv9/libgo.a(runtime.o): in function `runtime.dieFromSignal':
/usr/src/gcc/libgo/go/runtime/signal_gccgo.go:137: undefined reference to `sigaddse'
/usr/local/lib/gcc/sparcv9-sun-solaris2.11/11.1.0/../../../../sparcv9-sun-solaris2.11/bin/ld: /usr/local/lib/gcc/sparcv9-sun-solaris2.11/11.1.0/../../../../sparcv9-sun-solaris2.11/lib/sparcv9/libgo.a(runtime.o): in function `runtime.unblocksig':
/usr/src/gcc/libgo/go/runtime/signal_unix.go:1016: undefined reference to `sigprocmas'
/usr/local/lib/gcc/sparcv9-sun-solaris2.11/11.1.0/../../../../sparcv9-sun-solaris2.11/bin/ld: /usr/local/lib/gcc/sparcv9-sun-solaris2.11/11.1.0/../../../../sparcv9-sun-solaris2.11/lib/sparcv9/libgo.a(runtime.o): in function `runtime.dieFromSignal':
/usr/src/gcc/libgo/go/runtime/signal_unix.go:709: undefined reference to `rais'
/usr/local/lib/gcc/sparcv9-sun-solaris2.11/11.1.0/../../../../sparcv9-sun-solaris2.11/bin/ld: /usr/src/gcc/libgo/go/runtime/signal_unix.go:722: undefined reference to `rais'
/usr/local/lib/gcc/sparcv9-sun-solaris2.11/11.1.0/../../../../sparcv9-sun-solaris2.11/bin/ld: /usr/src/gcc/libgo/go/runtime/signal_unix.go:729: undefined reference to `exi'
/usr/local/lib/gcc/sparcv9-sun-solaris2.11/11.1.0/../../../../sparcv9-sun-solaris2.11/bin/ld: /usr/local/lib/gcc/sparcv9-sun-solaris2.11/11.1.0/../../../../sparcv9-sun-solaris2.11/lib/sparcv9/libgo.a(runtime.o): in function `runtime.minitSignalStack':
/usr/src/gcc/libgo/go/runtime/signal_unix.go:1039: undefined reference to `sigaltstac'
/usr/local/lib/gcc/sparcv9-sun-solaris2.11/11.1.0/../../../../sparcv9-sun-solaris2.11/bin/ld: /usr/local/lib/gcc/sparcv9-sun-solaris2.11/11.1.0/../../../../sparcv9-sun-solaris2.11/lib/sparcv9/libgo.a(runtime.o): in function `runtime.minitSignalMask':
/usr/src/gcc/libgo/go/runtime/signal_gccgo.go:141: undefined reference to `sigdelse'
/usr/local/lib/gcc/sparcv9-sun-solaris2.11/11.1.0/../../../../sparcv9-sun-solaris2.11/bin/ld: /usr/local/lib/gcc/sparcv9-sun-solaris2.11/11.1.0/../../../../sparcv9-sun-solaris2.11/lib/sparcv9/libgo.a(runtime.o): in function `runtime.minitSignalMask':
/usr/src/gcc/libgo/go/runtime/signal_unix.go:1063: undefined reference to `sigprocmas'
/usr/local/lib/gcc/sparcv9-sun-solaris2.11/11.1.0/../../../../sparcv9-sun-solaris2.11/bin/ld: /usr/local/lib/gcc/sparcv9-sun-solaris2.11/11.1.0/../../../../sparcv9-sun-solaris2.11/lib/sparcv9/libgo.a(runtime.o): in function `runtime.throw':
/usr/src/gcc/libgo/go/runtime/panic.go:1071: undefined reference to `exi'
/usr/local/lib/gcc/sparcv9-sun-solaris2.11/11.1.0/../../../../sparcv9-sun-solaris2.11/bin/ld: /usr/local/lib/gcc/sparcv9-sun-solaris2.11/11.1.0/../../../../sparcv9-sun-solaris2.11/lib/sparcv9/libgo.a(runtime.o): in function `runtime.getsig':
/usr/src/gcc/libgo/go/runtime/signal_gccgo.go:106: undefined reference to `sigactio'
/usr/local/lib/gcc/sparcv9-sun-solaris2.11/11.1.0/../../../../sparcv9-sun-solaris2.11/bin/ld: /usr/local/lib/gcc/sparcv9-sun-solaris2.11/11.1.0/../../../../sparcv9-sun-solaris2.11/lib/sparcv9/libgo.a(runtime.o): in function `runtime.initsig':
/usr/src/gcc/libgo/go/runtime/signal_gccgo.go:90: undefined reference to `sigactio'
/usr/local/lib/gcc/sparcv9-sun-solaris2.11/11.1.0/../../../../sparcv9-sun-solaris2.11/bin/ld: /usr/local/lib/gcc/sparcv9-sun-solaris2.11/11.1.0/../../../../sparcv9-sun-solaris2.11/lib/sparcv9/libgo.a(runtime.o): in function `runtime.setsigstack':
/usr/src/gcc/libgo/go/runtime/signal_gccgo.go:99: undefined reference to `sigactio'
/usr/local/lib/gcc/sparcv9-sun-solaris2.11/11.1.0/../../../../sparcv9-sun-solaris2.11/bin/ld: /usr/local/lib/gcc/sparcv9-sun-solaris2.11/11.1.0/../../../../sparcv9-sun-solaris2.11/lib/sparcv9/libgo.a(runtime.o): in function `runtime.setcpuprofilerate':
/usr/src/gcc/libgo/go/runtime/signal_unix.go:289: undefined reference to `setitime'
/usr/local/lib/gcc/sparcv9-sun-solaris2.11/11.1.0/../../../../sparcv9-sun-solaris2.11/bin/ld: /usr/local/lib/gcc/sparcv9-sun-solaris2.11/11.1.0/../../../../sparcv9-sun-solaris2.11/lib/sparcv9/libgo.a(runtime.o): in function `runtime.setProcessCPUProfiler':
/usr/src/gcc/libgo/go/runtime/signal_unix.go:315: undefined reference to `setitime'
/usr/local/lib/gcc/sparcv9-sun-solaris2.11/11.1.0/../../../../sparcv9-sun-solaris2.11/bin/ld: /usr/local/lib/gcc/sparcv9-sun-solaris2.11/11.1.0/../../../../sparcv9-sun-solaris2.11/lib/sparcv9/libgo.a(runtime.o): in function `runtime.startpanic__m':
/usr/src/gcc/libgo/go/runtime/panic.go:1170: undefined reference to `exi'
/usr/local/lib/gcc/sparcv9-sun-solaris2.11/11.1.0/../../../../sparcv9-sun-solaris2.11/bin/ld: /usr/src/gcc/libgo/go/runtime/panic.go:1166: undefined reference to `exi'
/usr/local/lib/gcc/sparcv9-sun-solaris2.11/11.1.0/../../../../sparcv9-sun-solaris2.11/bin/ld: /usr/local/lib/gcc/sparcv9-sun-solaris2.11/11.1.0/../../../../sparcv9-sun-solaris2.11/lib/sparcv9/libgo.a(runtime.o): in function `runtime.sysAlloc':
/usr/src/gcc/libgo/go/runtime/mem_gccgo.go:60: undefined reference to `exi'
/usr/local/lib/gcc/sparcv9-sun-solaris2.11/11.1.0/../../../../sparcv9-sun-solaris2.11/bin/ld: /usr/src/gcc/libgo/go/runtime/mem_gccgo.go:56: undefined reference to `exi'
/usr/local/lib/gcc/sparcv9-sun-solaris2.11/11.1.0/../../../../sparcv9-sun-solaris2.11/bin/ld: /usr/local/lib/gcc/sparcv9-sun-solaris2.11/11.1.0/../../../../sparcv9-sun-solaris2.11/lib/sparcv9/libgo.a(runtime.o): in function `runtime.dropm':
/usr/src/gcc/libgo/go/runtime/signal_unix.go:1002: undefined reference to `sigfillse'
/usr/local/lib/gcc/sparcv9-sun-solaris2.11/11.1.0/../../../../sparcv9-sun-solaris2.11/bin/ld: /usr/local/lib/gcc/sparcv9-sun-solaris2.11/11.1.0/../../../../sparcv9-sun-solaris2.11/lib/sparcv9/libgo.a(runtime.o): in function `runtime.sigblock':
/usr/src/gcc/libgo/go/runtime/signal_unix.go:1003: undefined reference to `sigprocmas'
/usr/local/lib/gcc/sparcv9-sun-solaris2.11/11.1.0/../../../../sparcv9-sun-solaris2.11/bin/ld: /usr/local/lib/gcc/sparcv9-sun-solaris2.11/11.1.0/../../../../sparcv9-sun-solaris2.11/lib/sparcv9/libgo.a(runtime.o): in function `runtime.dropm':
/usr/src/gcc/libgo/go/runtime/signal_unix.go:988: undefined reference to `sigprocmas'
/usr/local/lib/gcc/sparcv9-sun-solaris2.11/11.1.0/../../../../sparcv9-sun-solaris2.11/bin/ld: /usr/local/lib/gcc/sparcv9-sun-solaris2.11/11.1.0/../../../../sparcv9-sun-solaris2.11/lib/sparcv9/libgo.a(runtime.o): in function `runtime.needm':
/usr/src/gcc/libgo/go/runtime/proc.go:1626: undefined reference to `exi'
/usr/local/lib/gcc/sparcv9-sun-solaris2.11/11.1.0/../../../../sparcv9-sun-solaris2.11/bin/ld: /usr/local/lib/gcc/sparcv9-sun-solaris2.11/11.1.0/../../../../sparcv9-sun-solaris2.11/lib/sparcv9/libgo.a(runtime.o): in function `runtime.needm':
/usr/src/gcc/libgo/go/runtime/signal_unix.go:977: undefined reference to `sigprocmas'
/usr/local/lib/gcc/sparcv9-sun-solaris2.11/11.1.0/../../../../sparcv9-sun-solaris2.11/bin/ld: /usr/src/gcc/libgo/go/runtime/signal_unix.go:1002: undefined reference to `sigfillse'
/usr/local/lib/gcc/sparcv9-sun-solaris2.11/11.1.0/../../../../sparcv9-sun-solaris2.11/bin/ld: /usr/local/lib/gcc/sparcv9-sun-solaris2.11/11.1.0/../../../../sparcv9-sun-solaris2.11/lib/sparcv9/libgo.a(runtime.o): in function `runtime.sigblock':
/usr/src/gcc/libgo/go/runtime/signal_unix.go:1003: undefined reference to `sigprocmas'
/usr/local/lib/gcc/sparcv9-sun-solaris2.11/11.1.0/../../../../sparcv9-sun-solaris2.11/bin/ld: /usr/local/lib/gcc/sparcv9-sun-solaris2.11/11.1.0/../../../../sparcv9-sun-solaris2.11/lib/sparcv9/libgo.a(runtime.o): in function `runtime.sigtrampgo':
/usr/src/gcc/libgo/go/runtime/signal_unix.go:889: undefined reference to `exi'
/usr/local/lib/gcc/sparcv9-sun-solaris2.11/11.1.0/../../../../sparcv9-sun-solaris2.11/bin/ld: /usr/src/gcc/libgo/go/runtime/signal_unix.go:637: undefined reference to `exi'
/usr/local/lib/gcc/sparcv9-sun-solaris2.11/11.1.0/../../../../sparcv9-sun-solaris2.11/bin/ld: /usr/src/gcc/libgo/go/runtime/signal_unix.go:1014: undefined reference to `sigemptyse'
/usr/local/lib/gcc/sparcv9-sun-solaris2.11/11.1.0/../../../../sparcv9-sun-solaris2.11/bin/ld: /usr/local/lib/gcc/sparcv9-sun-solaris2.11/11.1.0/../../../../sparcv9-sun-solaris2.11/lib/sparcv9/libgo.a(runtime.o): in function `runtime.sigtrampgo':
/usr/src/gcc/libgo/go/runtime/signal_gccgo.go:137: undefined reference to `sigaddse'
/usr/local/lib/gcc/sparcv9-sun-solaris2.11/11.1.0/../../../../sparcv9-sun-solaris2.11/bin/ld: /usr/local/lib/gcc/sparcv9-sun-solaris2.11/11.1.0/../../../../sparcv9-sun-solaris2.11/lib/sparcv9/libgo.a(runtime.o): in function `runtime.unblocksig':
/usr/src/gcc/libgo/go/runtime/signal_unix.go:1016: undefined reference to `sigprocmas'
/usr/local/lib/gcc/sparcv9-sun-solaris2.11/11.1.0/../../../../sparcv9-sun-solaris2.11/bin/ld: /usr/local/lib/gcc/sparcv9-sun-solaris2.11/11.1.0/../../../../sparcv9-sun-solaris2.11/lib/sparcv9/libgo.a(runtime.o): in function `runtime.sigtrampgo':
/usr/src/gcc/libgo/go/runtime/signal_unix.go:776: undefined reference to `rais'
/usr/local/lib/gcc/sparcv9-sun-solaris2.11/11.1.0/../../../../sparcv9-sun-solaris2.11/bin/ld: /usr/local/lib/gcc/sparcv9-sun-solaris2.11/11.1.0/../../../../sparcv9-sun-solaris2.11/lib/sparcv9/libgo.a(runtime.o): in function `runtime.sighandler':
/usr/src/gcc/libgo/go/runtime/signal_unix.go:531: undefined reference to `sigfillse'
/usr/local/lib/gcc/sparcv9-sun-solaris2.11/11.1.0/../../../../sparcv9-sun-solaris2.11/bin/ld: /usr/src/gcc/libgo/go/runtime/signal_unix.go:532: undefined reference to `sigprocmas'
/usr/local/lib/gcc/sparcv9-sun-solaris2.11/11.1.0/../../../../sparcv9-sun-solaris2.11/bin/ld: /usr/local/lib/gcc/sparcv9-sun-solaris2.11/11.1.0/../../../../sparcv9-sun-solaris2.11/lib/sparcv9/libgo.a(runtime.o): in function `runtime.unblocksig':
/usr/src/gcc/libgo/go/runtime/signal_unix.go:1014: undefined reference to `sigemptyse'
/usr/local/lib/gcc/sparcv9-sun-solaris2.11/11.1.0/../../../../sparcv9-sun-solaris2.11/bin/ld: /usr/local/lib/gcc/sparcv9-sun-solaris2.11/11.1.0/../../../../sparcv9-sun-solaris2.11/lib/sparcv9/libgo.a(runtime.o): in function `runtime.sigaddset':
/usr/src/gcc/libgo/go/runtime/signal_gccgo.go:137: undefined reference to `sigaddse'
/usr/local/lib/gcc/sparcv9-sun-solaris2.11/11.1.0/../../../../sparcv9-sun-solaris2.11/bin/ld: /usr/local/lib/gcc/sparcv9-sun-solaris2.11/11.1.0/../../../../sparcv9-sun-solaris2.11/lib/sparcv9/libgo.a(runtime.o): in function `runtime.unblocksig':
/usr/src/gcc/libgo/go/runtime/signal_unix.go:1016: undefined reference to `sigprocmas'
/usr/local/lib/gcc/sparcv9-sun-solaris2.11/11.1.0/../../../../sparcv9-sun-solaris2.11/bin/ld: /usr/local/lib/gcc/sparcv9-sun-solaris2.11/11.1.0/../../../../sparcv9-sun-solaris2.11/lib/sparcv9/libgo.a(runtime.o): in function `runtime.sigtrampgo':
/usr/src/gcc/libgo/go/runtime/signal_gccgo.go:122: undefined reference to `getpi'
/usr/local/lib/gcc/sparcv9-sun-solaris2.11/11.1.0/../../../../sparcv9-sun-solaris2.11/bin/ld: /usr/local/lib/gcc/sparcv9-sun-solaris2.11/11.1.0/../../../../sparcv9-sun-solaris2.11/lib/sparcv9/libgo.a(runtime.o): in function `runtime.raiseproc':
/usr/src/gcc/libgo/go/runtime/signal_gccgo.go:122: undefined reference to `kil'
/usr/local/lib/gcc/sparcv9-sun-solaris2.11/11.1.0/../../../../sparcv9-sun-solaris2.11/bin/ld: /usr/local/lib/gcc/sparcv9-sun-solaris2.11/11.1.0/../../../../sparcv9-sun-solaris2.11/lib/sparcv9/libgo.a(runtime.o): in function `runtime.scanstack':
/usr/src/gcc/libgo/go/runtime/mgcmark.go:740: undefined reference to `getpi'
/usr/local/lib/gcc/sparcv9-sun-solaris2.11/11.1.0/../../../../sparcv9-sun-solaris2.11/bin/ld: /usr/local/lib/gcc/sparcv9-sun-solaris2.11/11.1.0/../../../../sparcv9-sun-solaris2.11/lib/sparcv9/libgo.a(runtime.o): in function `runtime.mexit':
/usr/src/gcc/libgo/go/runtime/signal_unix.go:1002: undefined reference to `sigfillse'
/usr/local/lib/gcc/sparcv9-sun-solaris2.11/11.1.0/../../../../sparcv9-sun-solaris2.11/bin/ld: /usr/local/lib/gcc/sparcv9-sun-solaris2.11/11.1.0/../../../../sparcv9-sun-solaris2.11/lib/sparcv9/libgo.a(runtime.o): in function `runtime.sigblock':
/usr/src/gcc/libgo/go/runtime/signal_unix.go:1003: undefined reference to `sigprocmas'
/usr/local/lib/gcc/sparcv9-sun-solaris2.11/11.1.0/../../../../sparcv9-sun-solaris2.11/bin/ld: /usr/local/lib/gcc/sparcv9-sun-solaris2.11/11.1.0/../../../../sparcv9-sun-solaris2.11/lib/sparcv9/libgo.a(runtime.o): in function `runtime.main':
/usr/src/gcc/libgo/go/runtime/proc.go:281: undefined reference to `exi'
/usr/local/lib/gcc/sparcv9-sun-solaris2.11/11.1.0/../../../../sparcv9-sun-solaris2.11/bin/ld: /usr/local/lib/gcc/sparcv9-sun-solaris2.11/11.1.0/../../../../sparcv9-sun-solaris2.11/lib/sparcv9/libgo.a(runtime.o): in function `runtime.ensureSigM..func1':
/usr/src/gcc/libgo/go/runtime/signal_unix.go:826: undefined reference to `sigfillse'
/usr/local/lib/gcc/sparcv9-sun-solaris2.11/11.1.0/../../../../sparcv9-sun-solaris2.11/bin/ld: /usr/local/lib/gcc/sparcv9-sun-solaris2.11/11.1.0/../../../../sparcv9-sun-solaris2.11/lib/sparcv9/libgo.a(runtime.o): in function `runtime.ensureSigM..func1':
/usr/src/gcc/libgo/go/runtime/signal_gccgo.go:141: undefined reference to `sigdelse'
/usr/local/lib/gcc/sparcv9-sun-solaris2.11/11.1.0/../../../../sparcv9-sun-solaris2.11/bin/ld: /usr/local/lib/gcc/sparcv9-sun-solaris2.11/11.1.0/../../../../sparcv9-sun-solaris2.11/lib/sparcv9/libgo.a(runtime.o): in function `runtime.ensureSigM..func1':
/usr/src/gcc/libgo/go/runtime/signal_unix.go:832: undefined reference to `sigprocmas'
/usr/local/lib/gcc/sparcv9-sun-solaris2.11/11.1.0/../../../../sparcv9-sun-solaris2.11/bin/ld: /usr/src/gcc/libgo/go/runtime/signal_unix.go:844: undefined reference to `sigprocmas'
/usr/local/lib/gcc/sparcv9-sun-solaris2.11/11.1.0/../../../../sparcv9-sun-solaris2.11/bin/ld: /usr/local/lib/gcc/sparcv9-sun-solaris2.11/11.1.0/../../../../sparcv9-sun-solaris2.11/lib/sparcv9/libgo.a(runtime.o): in function `runtime.ensureSigM..func1':
/usr/src/gcc/libgo/go/runtime/signal_gccgo.go:141: undefined reference to `sigdelse'
/usr/local/lib/gcc/sparcv9-sun-solaris2.11/11.1.0/../../../../sparcv9-sun-solaris2.11/bin/ld: /usr/src/gcc/libgo/go/runtime/signal_gccgo.go:137: undefined reference to `sigaddse'
/usr/local/lib/gcc/sparcv9-sun-solaris2.11/11.1.0/../../../../sparcv9-sun-solaris2.11/bin/ld: /usr/local/lib/gcc/sparcv9-sun-solaris2.11/11.1.0/../../../../sparcv9-sun-solaris2.11/lib/sparcv9/libgo.a(runtime.o): in function `runtime.schedinit':
/usr/src/gcc/libgo/go/runtime/signal_unix.go:977: undefined reference to `sigprocmas'
collect2: error: ld returned 1 exit status
@ianlancetaylor
Copy link
Contributor

@ianlancetaylor ianlancetaylor commented Apr 29, 2021

Did you build gccgo yourself? In your build directory, what is the contents of the generated file sparcv9-sun-solaris2.11/libgo/runtime_linknames.go? Thanks.

@ianlancetaylor ianlancetaylor changed the title Cross compiling with GCC11.1 cause many undefined reference gccgo: cross compiling with GCC11.1 cause many undefined reference Apr 29, 2021
@ianlancetaylor ianlancetaylor self-assigned this Apr 29, 2021
@ianlancetaylor ianlancetaylor added this to the Gccgo milestone Apr 29, 2021
@bearx3f
Copy link
Author

@bearx3f bearx3f commented Apr 29, 2021

Yes I'm build gcc by myself

and here you are content of sparcv9-sun-solaris2.11/libgo/runtime_linknames.go

root@d3fc663ba707:/tmp/tmp.x6cBnklrDH# cat sparcv9-sun-solaris2.11/libgo/runtime_linknames.go
// Code generated by mklinknames.awk. DO NOT EDIT.

package runtime

import _ "unsafe"

//go:linkname libcPipe pip
//go:linkname libcPipe2 pipe
//go:linkname sigaction sigactio
//go:linkname sigprocmask sigprocmas
//go:linkname sigfillset sigfillse
//go:linkname sigemptyset sigemptyse
//go:linkname c_sigaddset sigaddse
//go:linkname c_sigdelset sigdelse
//go:linkname sigaltstack sigaltstac
//go:linkname raise rais
//go:linkname getpid getpi
//go:linkname kill kil
//go:linkname setitimer setitime
//go:linkname exit exi
@ianlancetaylor
Copy link
Contributor

@ianlancetaylor ianlancetaylor commented Apr 29, 2021

Thanks. That file is generated by libgo/mklinknames.awk, and clearly it is not working. But I don't see why. What version of awk do you have installed? What do you see if you run grep sigaltstack sparcv9-sun-solaris2.11/libgo/gen-sysinfo.go? Thanks.

@bearx3f
Copy link
Author

@bearx3f bearx3f commented Apr 30, 2021

I was compile gcc in docker build base on buildpack-deps:buster

root@e815928baf27:/tmp/tmp.x6cBnklrDH# grep sigaltstack sparcv9-sun-solaris2.11/libgo/gen-sysinfo.go
type _sigaltstack struct { ss_sp *byte; ss_size uint64; ss_flags int32; Godump_0_pad [4]byte; }
const _sizeof_sigaltstack = 24
type _stack_t _sigaltstack
func _sigaltstack (*_stack_t, *_stack_t) int32 __asm__("sigaltstack")
const _SYS_sigaltstack = 97

and awk version

root@e815928baf27:/tmp/tmp.x6cBnklrDH# awk -W version
mawk 1.3.3 Nov 1996, Copyright (C) Michael D. Brennan

compiled limits:
max NF             32767
sprintf buffer      2040
@choeger
Copy link

@choeger choeger commented May 7, 2021

tl;dr: Check the binutils version used when linking go object files

I encountered the very same problem without cross compiling today.

Unfortunately, I do not have access to the log files right now, but here is how to replicate it:

  1. Start on a distribution with "old" binutils (e.g., Ubuntu 18.04 with binutils 2.30)
  2. Download gcc 11.1 and binutils 2.36 and unpack both
  3. Link ld, as, and whatever else you want into the gcc dir (I used bfd, gas, ld, gold, opcodes,libctf)
  4. configure (my options where --enable-languages=go,c,c++ --disable-nls --disable-multilib --enable-gold --enable-ld=default)
  5. make

The result is a very similar error as above. The failing step was the compilation of some go tools. When I tried to dig into it, it looked like all references had one letter cut off. I digged further and what I found was that collect2 was running /usr/bin/ld instead of the one bootstrapped from the binutils. Now I am not an expert regarding the build/bootstrap/cross compilation process and it might be that I missed some environment variables when digging, so take this with a grain of salt. But I am 100% certain that the same build script worked just fine on fedora 33 and I think it also passed on ubuntu 20.04 - so the older version of binutils seems to be related.

I think gcc upgraded some internal formats (DWARF?) and the older binutils cannot cope with that.

@choeger
Copy link

@choeger choeger commented May 10, 2021

My last comment is not the root cause. The cause is in the mklinknames.awk script. It contains the following line:

asmname = substr(asmname, 0, length(asmname) - 2)

That 0 should be a 1 according to man awk:

       substr(s, i [, n])      Return the at most n-character substring of s starting at i.  If n is  omitted,  use
                               the rest of s.

I will try to come up with a patch. Where do I submit it, if it works?

@choeger
Copy link

@choeger choeger commented May 10, 2021

Here is the patch I used to fix the build problem. @bearx3f you might want to give it a try. I tried to upstream it, but somehow I cannot send to gcc-patches@gcc.gnu.org .

(The changelog part might not apply to the 11.1.0 release tarball, just delete it, it doesn't matter).
0001-Fix-awk-substr-invocation-in-libgo-buildsystem.zip

@bearx3f
Copy link
Author

@bearx3f bearx3f commented May 11, 2021

@ianlancetaylor I confirm that @choeger's solution works

  • compile
  • execute
@bearx3f
Copy link
Author

@bearx3f bearx3f commented May 11, 2021

@choeger I think here https://github.com/golang/gofrontend is proper way to submit patch

choeger added a commit to choeger/gofrontend that referenced this issue May 11, 2021
The awk script used a zero-based index which worked on surprisingly
many plattforms. According to the man page, however, the function
expects one-based indexing.

For reference see this bug in the go git repository:

golang/go#45843

Signed-off-by: Christoph Höger <choeger@umpa-net.de>
@bearx3f
Copy link
Author

@bearx3f bearx3f commented May 12, 2021

@ianlancetaylor maybe my problem is all about awk version

problem version

root@e815928baf27:/tmp/tmp.x6cBnklrDH# awk -W version
mawk 1.3.3 Nov 1996, Copyright (C) Michael D. Brennan

compiled limits:
max NF             32767
sprintf buffer      2040

success version

apt-get install gawk
root@d772f8344b47:/go# awk -W version
GNU Awk 4.2.1, API: 2.0 (GNU MPFR 4.0.2, GNU MP 6.1.2)
Copyright (C) 1989, 1991-2018 Free Software Foundation.

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the.
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program. If not, see http://www.gnu.org/licenses/.

my issue is closed.

@bearx3f bearx3f closed this May 12, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants