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

cmd/compile: go1.8 failed to install from source on mips64le #19140

Closed
isolesty opened this issue Feb 17, 2017 · 9 comments

Comments

Projects
None yet
4 participants
@isolesty
Copy link

commented Feb 17, 2017

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

go 1.8 bootstrap from amd64

What operating system and processor architecture are you using (go env)?

go env from go-linux-mips64le-bootstrap/bin/go
GOARCH="mips64le"
GOBIN=""
GOEXE=""
GOHOSTARCH="mips64le"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/test/go"
GORACE=""
GOROOT="/home/test/go-linux-mips64le-bootstrap"
GOTOOLDIR="/home/test/go-linux-mips64le-bootstrap/pkg/tool/linux_mips64le"
GCCGO="gccgo"
CC="gcc"
GOGCCFLAGS="-fPIC -mabi=64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build176825134=/tmp/go-build -gno-record-gcc-switches"
CXX="g++"
CGO_ENABLED="1"
PKG_CONFIG="pkg-config"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"

What did you do?

try to build go 1.8 from source on loongson

What did you expect to see?

successfully build go 1.8 on mips64le

the same steps from https://golang.org/doc/install/source build go 1.7.5 right.

What did you see instead?

cmd/compile/internal/gc
cmd/compile/internal/arm
cmd/compile/internal/arm64
cmd/compile/internal/mips
cmd/compile/internal/amd64
cmd/compile/internal/mips64
cmd/compile/internal/ppc64
cmd/compile/internal/s390x
cmd/compile/internal/x86
cmd/compile

SIGILL: illegal instruction
PC=0x1203ce804 m=0 sigcode=128

goroutine 0 [idle]:

goroutine 1 [runnable, locked to thread]:
runtime.init.3()
/home/test/go/src/runtime/proc.go:214 +0x1c
runtime.init()
/home/test/go/src/runtime/write_err.go:14 +0x108
runtime.main()
/home/test/go/src/runtime/proc.go:141 +0x100
runtime.goexit()
/home/test/go/src/runtime/asm_mips64x.s:868 +0x4

goroutine 17 [syscall, locked to thread]:
runtime.goexit()
/home/test/go/src/runtime/asm_mips64x.s:868 +0x4

r0 0x0 r1 0xffffd38ef0
r2 0x2d8 r3 0xffffd38eb8
r4 0xffffd38ef0 r5 0x1206b34a0
r6 0x1206b2f20 r7 0xc420000d00
r8 0x0 r9 0xfff1554000
r10 0x1350 r11 0x1204e0322
r12 0x0 r13 0x0
r14 0xc41fffff8c r15 0xf3
r16 0x0 r17 0x120063c48
r18 0x0 r19 0xffffd38dc0
r20 0xffffd38eb8 r21 0x12004e078
r22 0x1204c4548 r23 0x120670000
r24 0x0 r25 0x1203ce800
r26 0xc420030800 r27 0x0
r28 0x100000000 r29 0xffffd38e88
r30 0x1206b2f20 r31 0x120063bc4
pc 0x1203ce804 link 0x120063bc4
lo 0xd00 hi 0x0
SIGILL: illegal instruction
PC=0x1203ce804 m=0 sigcode=128

goroutine 0 [idle]:

goroutine 1 [runnable, locked to thread]:
runtime.gcenable()
/home/test/go/src/runtime/mgc.go:210 +0x1c
runtime.main()
/home/test/go/src/runtime/proc.go:151 +0x140
runtime.goexit()
/home/test/go/src/runtime/asm_mips64x.s:868 +0x4

goroutine 17 [syscall, locked to thread]:
runtime.goexit()
/home/test/go/src/runtime/asm_mips64x.s:868 +0x4

r0 0x0 r1 0xffffe69270
r2 0x2d8 r3 0xffffe69238
r4 0xffffe69270 r5 0x1206b34a0
r6 0x1206b2f20 r7 0xc4200011e0
r8 0x0 r9 0xffec5d4000
r10 0x1b00 r11 0x1204e0322
r12 0x0 r13 0x0
r14 0xc41fffff65 r15 0xf3
r16 0x0 r17 0x120063c48
r18 0x0 r19 0xffffe69140
r20 0xffffe69238 r21 0x12004e078
r22 0x1204c4548 r23 0x120670000
r24 0x30 r25 0x1203ce800
r26 0x0 r27 0x0
r28 0x100000000 r29 0xffffe69208
r30 0x1206b2f20 r31 0x120063bc4
pc 0x1203ce804 link 0x120063bc4
lo 0x11e0 hi 0x0

@ianlancetaylor

This comment has been minimized.

Copy link
Contributor

commented Feb 17, 2017

My understanding is that you need to have an FPU.

CC @cherrymui @vstefanovic

@ianlancetaylor ianlancetaylor changed the title go1.8 failed to install from source on mips64le cmd/compile: go1.8 failed to install from source on mips64le Feb 17, 2017

@cherrymui

This comment has been minimized.

Copy link
Contributor

commented Feb 17, 2017

@isolesty Could you use a debugger to find out what the faulty instruction is?
I believe Loongson machine should have FPU. The mips64le builder is also Loongson, and it builds successfully.

@isolesty

This comment has been minimized.

Copy link
Author

commented Feb 20, 2017

@cherrymui Sorry, I can't get any useful information in gdb.

Thread 1 "go" received signal SIGILL, Illegal instruction.
0x00000001203ce804 in x_cgo_thread_start ()
(gdb) bt
#0 0x00000001203ce804 in x_cgo_thread_start ()
#1 0x0000000120063bc4 in _ftext ()
Backtrace stopped: frame did not save the PC
(gdb)

P.S. It builds successfully on Loongson 3a 2000 and Loongson 3a 3000, failed on Loongson 3b 1500. So it may be a CPU dependent error. Some programs builded by go 1.7 get the same illegal instruction error on Loongson 3b 1500.

@cherrymui

This comment has been minimized.

Copy link
Contributor

commented Feb 20, 2017

Is there any instruction that Loongson 3a has but Loongson 3b doesn't?

@cherrymui

This comment has been minimized.

Copy link
Contributor

commented Feb 20, 2017

When it receives SIGILL in gdb, could you run x/i $pc and x/wx $pc? So it prints the instruction at the faulting pc.

@cherrymui

This comment has been minimized.

Copy link
Contributor

commented Feb 20, 2017

The fault is in x_cgo_thread_start which is a C function compiled by gcc. Did you have some gcc flag set so it didn't use machine native instruction set?
Or you can try setting CGO_ENABLED=0 if you don't need cgo.

@isolesty

This comment has been minimized.

Copy link
Author

commented Feb 20, 2017

Sorry, I don't know the difference between 3a 2000 and 3b 1500.

In gdb, the x/i $pc show

test@localhost:~/go$ gdb ./bin/go
(gdb) set env USE_GCCGO 0
(gdb) r env
Starting program: /home/test/go/bin/go env
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/mips64el-linux-gnuabi64/libthread_db.so.1".
[New Thread 0xfff7d4f1f0 (LWP 2370)]
[New Thread 0xfff754f1f0 (LWP 2371)]

Thread 1 "go" received signal SIGILL, Illegal instruction.
0x00000001203ce804 in x_cgo_thread_start (arg=0xffffffb200) at /home/test/go/src/runtime/cgo/gcc_util.c:10
10	{
(gdb) x/i $pc
=> 0x1203ce804 <x_cgo_thread_start+4>:	gssq	ra,gp,16(sp)
(gdb) x/wx $pc
0x1203ce804 <x_cgo_thread_start+4>:	0xebbc007f
@cherrymui

This comment has been minimized.

Copy link
Contributor

commented Feb 21, 2017

gssq looks like a Loongson specific instruction, instead of normal MIPS instruction. The Go compiler never generate it. This is generated by gcc. I don't know why gcc would do it on a machine that doesn't support it. You can try setting CGO_CFLAGS=-mips3 and CGO_LDFLAGS=-mips3 to explicitly disable it.
Also, if you don't need cgo, try bootstrapping without cgo: CGO_ENABLED=0 ./make.bash.

@isolesty

This comment has been minimized.

Copy link
Author

commented Feb 21, 2017

@cherrymui I use a new gcc from Debian and go 1.8 builds successfully. The failed gcc had been patched by Loongson, I will report this bug to Loongson.
Thank you

@isolesty isolesty closed this Feb 21, 2017

@golang golang locked and limited conversation to collaborators Feb 21, 2018

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
You can’t perform that action at this time.