Port-arm archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Golang for NetBSD/arm



Hello all,

I'm trying to build golang in netbsd/arm on RPI during several months,
but does not work by some problems yet.

1st problem:

version.mk in pkgsrc/lang/go,

ONLY_FOR_PLATFORM=     *-*-i386 *-*-x86_64 *-*-evbarm

'evbarm' is Machine-name, not CPU architecture. So I changed it following:

ONLY_FOR_PLATFORM=     *-*-i386 *-*-x86_64 *-*-arm *-*-earm

The default of NetBSD/evbarm for many arm-machines is 'earm' but
I don't know  which is better earm or arm, so defined the both now.

Complete changes is here:
  https://gist.github.com/oshimaya/358589271a0bf4bfec08

2nd probrem:

After above changes, when start make in NetBSD/evbearm-el on RPI,
OS became hangup.

Environment:
rpiearm $ uname -a -p
NetBSD rpiearm 7.0_RC2 NetBSD 7.0_RC2 (RPI.201507270310Z) evbarm earm


build log is here:
  https://gist.github.com/oshimaya/aca7e1ff61e7e552029c

It seems that the first compile with go_bootstrap.
With kernel debugger when this:

db> bt
0x964e7b84: netbsd:plcomintr+0xc
0x964e7ba4: netbsd:pic_dispatch+0x28
0x964e7c24: netbsd:pic_do_pending_ints+0x378
0x964e7c84: netbsd:irq_entry+0x64
0x964e7cc4: netbsd:vmcmd_readvn+0xc8
0x964e7d64: netbsd:execve_runproc+0x1ac
0x964e7eec: netbsd:execve1+0x44
0x964e7f04: netbsd:sys_execve+0x20
0x964e7f74: netbsd:syscall+0x8c
0x964e7fac: netbsd:swi_handler+0x94
db> ps
PID    LID S CPU     FLAGS       STRUCT LWP *               NAME WAIT
7804 >   1 7   0         0           99b56620               bash
11267    1 3   0        80           9b852e40               bash wait

(more: https://gist.github.com/oshimaya/d501ec45f17a6ebe9053 )

By current PID, this occurs in bash, not go or make or any build tools.
Perhaps this is during execve go_bootstarp.

After restart, the following file had left in work/go/pkg/tool/netbsd_arm/

rpiearm$ ls
5a*             5g*             dist*
5c*             5l*             go_bootstrap*
rpiearm$ file *
5a:           ELF 32-bit LSB executable, ARM, EABI5 version 1 (SYSV), dynamicall
y linked (uses shared libs), for NetBSD 7.0, compiled for: earm, not stripped
5c:           ELF 32-bit LSB executable, ARM, EABI5 version 1 (SYSV), dynamically linked (uses shared libs), for NetBSD 7.0, compiled for: earm, not stripped
5g:           ELF 32-bit LSB executable, ARM, EABI5 version 1 (SYSV), dynamically linked (uses shared libs), for NetBSD 7.0, compiled for: earm, not stripped
5l:           ELF 32-bit LSB executable, ARM, EABI5 version 1 (SYSV), dynamically linked (uses shared libs), for NetBSD 7.0, compiled for: earm, not stripped
dist:         ELF 32-bit LSB executable, ARM, EABI5 version 1 (SYSV), dynamically linked (uses shared libs), for NetBSD 7.0, compiled for: earm, not stripped
go_bootstrap: ELF 32-bit LSB executable, ARM, version 1 (NetBSD), statically lin
y linked (uses shared libs), for NetBSD 7.0, compiled for: earm, not stripped
go_bootstrap: ELF 32-bit LSB executable, ARM, version 1 (NetBSD), statically linked, for NetBSD 5.99, not stripped

In these files, when execute the 'go_bootstap' OS became hangup.

evbearm$ ./go_bootstarp
(send break)
Stopped in pid 50.1 (sh) at     netbsd:cpu_Debugger+0x4:        bx      r14
db> bt
0x9b90fb84: netbsd:plcomintr+0xc
0x9b90fba4: netbsd:pic_dispatch+0x28
0x9b90fc24: netbsd:pic_do_pending_ints+0x378
0x9b90fc84: netbsd:irq_entry+0x64
0x9b90fcc4: netbsd:vmcmd_readvn+0xc8
0x9b90fd64: netbsd:execve_runproc+0x1ac
0x9b90feec: netbsd:execve1+0x44
0x9b90ff04: netbsd:sys_execve+0x20
0x9b90ff74: netbsd:syscall+0x8c
0x9b90ffac: netbsd:swi_handler+0x94
db> ps 
PID    LID S CPU     FLAGS       STRUCT LWP *               NAME WAIT
50   >   1 7   0         0           9bd305e0                 sh
1717     1 3   0         0           9bd30320                 sh wait
1706     1 3   0        80           9bd308a0                 sh wait

This is the same when building.

I think this cause wrong ELF header made by golang, but OS hangup is 
a serious problem, too.

3rd problem:

In the case of NetBSD/evbarm 6.1.5 (of course, this is oarm not EABI).
when start build,

# Building packages and commands for netbsd/arm.
runtime
# runtime
copying $WORK/runtime/_obj/defs.5 to $WORK/runtime.a: file larger than size repo
rted by stat
*** Error code 2
( complete log: https://gist.github.com/oshimaya/353968db5281dc6834b0 )

This cause will be the define of golang's syscall types for netbsd-arm
is for EABI, change this like the following patch:
  https://gist.github.com/oshimaya/0e2be9a12974675eb726

After patch, build success and it works well (maybe).

pi6$ go version
go version go1.4.2 netbsd/arm
rpi6$ cat hello.go
package main

import "fmt"

func main() {
        fmt.Println("Hello, world.")
}
rpi6$ go build hello.go
rpi6$ ./hello
Hello, world.
rpi6$ file hello
hello: ELF 32-bit LSB executable, ARM, version 1 (NetBSD), statically linked, fo
r NetBSD 5.99, not stripped


4th problem:

On NetBSD/earm 7.0RC2,  when executing the hello binary which made by golang
on NetBSD/arm 6.1.5, Abort trap occurd.

rpiearm$ uname -srmp
NetBSD 7.0_RC2 evbarm earm
rpiearm$ file hello
hello: ELF 32-bit LSB executable, ARM, version 1, statically linked, for NetBSD
5.99, not stripped
rpiearm$ ./hello
[1]   Abort trap              ./hello
rpiearm$ ktruss ./hello
  1525      1 ktruss   fcntl(0x4, 0x3, 0)          = 4194305
  1525      1 ktruss   emul(netbsd)
  1525      1 ktruss   fcntl(0x4, 0x4, 0x400001)   = 0
rpiearm$

First, I thought this is a problem of OABI binary in NetBSD/earm environment.
However the same occur on NetBSD/evbarm-el(OABI).
This problem is not caused by whether EABI or OABI.
This hello binary works well on NetBSD/arm 6.1.5, but not work on 
NetBSD/{arm,earm} 7.0_RC2.

I think some problem in the ELF loader on NetBSD/arm after 7
But not yet found anything for solved.


For test use:
- The binary package for NetBSD/arm 6.1.5 is:
 http://www.yagoto-urayama.jp/~oshimaya/netbsd/files/goarm_n6/go-1.4.2nb2.tgz
 (Requires: bash and perl binary)
^ The hello binary is:
 http://www.yagoto-urayama.jp/~oshimaya/netbsd/files/goarm_n6/hello.gz
 (Statically binary)

These binary works on NetBSD/arm 6.1.5 on RPI,
The go command in binary package cause hangup in NetBSD/arm 7.0_RC2 on RPI.
The hello binary makes Abort trap.


Please help.

-- 
Yasushi Oshima


Home | Main Index | Thread Index | Old Index