Last active
March 10, 2017 12:25
-
-
Save oshimaya/19bc0f52e9f9c2fbde0c79f1abb91ed3 to your computer and use it in GitHub Desktop.
let's go netbsd '2017
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Let's Go NetBSD/arm with ARM | |
Yasushi Oshima | |
---------------- | |
Who am I? | |
One of a General NetBSD User | |
---------------- | |
Conclusion | |
Now Go 1.8 works NetBSD/earm! | |
(but only earmv6hf or earmv7hf) | |
---------------- | |
How to build go toolchain for NetBSD/arm | |
Cross Build: | |
On any platform which support Go runtime, of caouse include NetBSD/{amd64,i386}: | |
$ tar zxf go1.8.src.tar.gz | |
$ cd go/src | |
$ GOROOT_BOOTSTRAP=/where/to/host-GOROOT GOOS=netbsd GOARCH=arm GOARM=? ./bootstrap.sh | |
? is 6(earm6hf) or 7(earm7hf) | |
---------------- | |
How to build application binary from *.go | |
Cross Build: | |
On any platform which support Go 1.8 runtime, of caouse include NetBSD/{amd64,i386}: | |
$ GOOS=netbsd GOARCH=arm GOARM=? go build *.go | |
*: ? is 6(earm6hf) or 7(earm7hf) | |
---------------- | |
Okey, Enjoy Go on NetBSD/arm! | |
---------------- | |
...Is this a special thing? | |
It seems to be normaly. | |
---------------- | |
Yes. but it is not normaly in the past on NetBSD/arm. | |
---------------- | |
History of my fight | |
2015/? First fight. This takes small win only on NetBSD/arm 6.x(OABI) | |
2015/10 Secound challenge.The problem part in NetBSD/earm 7.0 has became clear. | |
2016/?? It works roughly, and reports to upstream. | |
2017/1 The last major problem was fixed in upstream. | |
2017/2 Go 1.8 has released. | |
---------------- | |
In PkgSrc till 2016/11: | |
$ cd /usr/pkgsrc/lang/go | |
$ make | |
=> Bootstrap dependency digest =>20010302:fond digest--20121220 | |
ERROR: This package is only availavle for these platforms: *-*-i386 *-*-x86_64 *-*-evbarm. | |
ERROR: This package has set PKG_SKIP_REASON: | |
EROOR: go-1.4.2 is not available for NetBSD-7.0-earm | |
Not Support !? | |
What is "*-*-evbarm" ??? | |
(evbarm is port machine name, not processor arch) | |
---------------- | |
After 2016/12: | |
$ cd /usr/pkgsrc/lang/go14 | |
$ make | |
=> Bootstrap dependency digest => ... | |
[...] | |
go/doc | |
go/build | |
cmd/go | |
Building started, But... | |
System Hang-Up! | |
Kernel not responding | |
(But responsible by ping from network) | |
---------------- | |
In manual build (till go 1.7) | |
$ tar zxf go1.4.3.src.tar.gz | |
$ cd go/src | |
$ ./make.bash | |
[...] | |
go/doc | |
go/build | |
cmd/go | |
System Hang-Up! | |
Same as bilding from pkgsrc... | |
---------------- | |
Why? | |
Because there is multiple problems. See also PR PKG/51653 | |
Problem 1: | |
Support of EABI for NetBSD/earm has not finished yet in Go netbsd_arm | |
(till Go 1.7). it was fixed. | |
Problem 2: | |
The page size has increased from 4K to 8K when ARMv6 or lator after | |
NetBSD-7, However, Go_arm defines the page size as 'HardCorded' 4K | |
in go's memory management. (till Go 1.7) | |
It was changed to dynamic value from kernel. | |
---------------- | |
Problem 3: | |
The p_align: memory and file alignment in ELF header created by Go | |
linker is 4K (. The loader of NetBSD kernel cannot load this binary. | |
(cf. NetBSD's default binary is 64K, created by default linker, | |
Gnu-toolchain). | |
This may cause of system-hangup! | |
Kernel loader to be able to by invalid elf header.) | |
It was changed to 64K in 2017/Jan. It was in time for release 1.8! | |
Then now works Go-Runtime and Go-Toolchain in NetBSD/earmv{6,7}hf! | |
---------------- | |
Why only earmv{6,7}hf? | |
1. Go cannot support OABI and EABI at the same source in the same os | |
in arm. | |
2. Go support ARMv5 or lator in ARM, but always uses ARMv6 instruction | |
except on Linux/arm. | |
And, the next-release(Go 1.9) drops ARMv5 even on Linux. | |
---------------- | |
The binary which build with GOARM=6 (=earmv6hf) can be run on ARMv7 machine? | |
Partly, 'Yes'. | |
However in many cases, 'No' | |
If the machine which has ARMv7 single core cpu can run the binary | |
which build with GOARM=6. | |
If the machine which has ARMv7 multi core cpu cannot run the binary | |
which build with GOARM=6. | |
ex: RPi is single ARMv6 GOARM=6 work GOARM=7 not work | |
RPi2 is 4-core ARMv7 GOARM=6 not work GOARM=7 work | |
NetWalker is single ARMv7 GOARM=6 work GOARM=7 work | |
Go runtime uses ARMv7 instruction in their synchronization | |
control of multithread. | |
---------------- | |
Self Building Go-Toolchain on NetBSD/arm? | |
Now, Go is written in Go. To build Go, it needs go which already working. | |
Usually, it uses Go 1.4 which is last release written by C-Language. | |
But Go 1.4 does not work in NetBSD/earm. | |
And Go 1.4 has been EOL already, so not changed now and future. | |
... So, | |
I ported Go 1.4 to NetBSD/earm for only building Go 1.5 or lator. | |
(But I don't know how stable...) | |
---------------- | |
Pkgsrc? | |
How to prepare bootstrap go? | |
- Local port of go 1.4 | |
or | |
- Provide bootstrap-binary (for both earmv6hf and earmv7hf?) | |
---------------- | |
Remaining problem | |
- See Known Issue in Release Note in GO1.8 | |
- Test case 'TestPassFD' in syscall failes. | |
The problem exists in NetBSD's Kernel? | |
---------------- | |
More Frontier | |
Other Supported architecture in Go: | |
arm64, ppc64, ppc64le, mips, mipsle, mips64, mips64le, s390x | |
Only Linux supports them now, | |
Is this enough? | |
---------------- | |
Thanks | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment