blob: 470216562aefd7d7c41651a8b5f0390d262bf692 [file] [log] [blame] [view]
Andrew Gerrand5bc444d2014-12-10 11:35:11 +11001# Introduction
2
3Go is fully supported on linux/arm. Any Go program that you can compile for x86/x86\_64 should work on Arm.
4
5# Supported architectures
6
7Go supports the following ARM architectural families.
8
9| **Architecture** | **Status** | **GOARM value** | **Notes** |
10|:-----------------|:-----------|:----------------|:----------|
11| ARMv4 and below | sorry, not supported | n/a | |
12| ARMv5 | supported | GOARM=5 | |
13| ARMv6 | supported | | GOARM=6 is the default value|
14| ARMv7 | supported | GOARM=7 | |
15| ARMv8 | work in progress | n/a | contact aram for details |
16
17Starting from Go 1.1, the appropriate GOARM value will be chosen if you compile Go from source on the target machine. In cross compilation situations, it is recommended that you always export an appropriate GOARM value.
18
19# Supported operating systems
20
21Go supports ARM on Linux. You must be running a [EABI](http://wiki.debian.org/ArmEabiPort) kernel. These are generally known as ` armel ` for softfloat (compatible with ARMv5) or ` armhf ` for hardware floating point (ARMv6 and above).
22
23# Recommended Go version
24
25The recommended minimum version for running Go on arm systems is Go 1.1.
26
27# Tips and tricks
28
29## /tmp and tmpfs
30The ` go ` build tool uses ` /tmp ` when compiling and testing, this can cause heavy wear and tear if ` /tmp ` lives on your SD card. To minimise this effect, either ` export TMPDIR ` to somewhere that lives on another filesystem. Alternatively if you have lots of physical memory you can mount a swap backed tmpfs filesystem on /tmp by adding this line to ` /etc/fstab `
31
32```
33tmpfs /tmp tmpfs nodev,nosuid,mode=1777 0 0
34```
35
36## Swap
37Building Go from source requires at least 256mb of RAM. Running the tests requires at least 256mb of memory and at least 512mb of swap space.
38
39## Build failures due to lack of memory
40The Go tool will try to keep all your cpu cores busy when installing packages (during make.bash),
41this is normally preferable on PCs where memory is abundant.
42However, some powerful multicore ARM machines don't have enough memory to support parallel
43builds utilizing all available cores, and you can work around that by using the ` taskset(1) ` utility
44to limit Go to only use one core without resorting to swaps.
45```
46taskset 1 ./make.bash # use 3 if you want to use two cores
47```
48Note: the 1 here is a bitmask for cpu affinity and it's not the number of cpu cores you're
49willing to use, please refer to ` taskset(1) ` manual for details.
50
51# Known issues
52
53## Lack of floating point hardware on ARMv5
54The major issue with ARMv5 is the lack of floating point support in common ARMv5 harware<sup>†</sup>. When compiled with the GOARM=5 environment variable, the 5l linker will insert a call to ` _sfloat ` before any block of floating point instructions to branch into the floating point emulator. This means that binaries produced with a Go installation that was compiled with soft float support will work on all supported architectures, but builds compiled without soft floating point support will not work on ARMv5.
55
56<sup>†</sup> This isn't strictly true, there exist ARMv5 implementations which have VFP1 floating point. However the compiler doesn't support VFP1 yet.
57
58## html/template and test/nilptr.go test fail on HTC Android
59html/template test and test/nilptr.go is known to fail on HTC's Android kernels ([ref](http://www.mail-archive.com/android-developers@googlegroups.com/msg153389.html)), because the kernel will kill the application after 10 segfaults.
60
61## Potential kernel bug in 2.6.32-5-kirkwood on QNAP 219P
nathany2c4a8d92014-12-10 22:16:11 -080062See [Issue 5466](https://github.com/golang/go/issues/5466) for details. Updating to 3.2.0-4-kirkwood solved the issue.
Andrew Gerrand5bc444d2014-12-10 11:35:11 +110063
64# Success stories
65
66ARM hardware comes in a myriad of shapes and sizes. If you've had a success story building and running Go on your Arm system, please detail your results here.
67
68## Netgear Stora
69
70Architecture: ARMv5
71
72Operating System: Debian Sid
73
74The Netgear Stora is an ARMv5 (Marvell Kirkwood) platform. I flashed mine with a Debian Sid distribution and it was, until Go1, a solid platform for Go development. The main drawback is the Stora only has 128mb of ram, which is not quite enough to run ./all.bash as 5l can use more than 100mb of ram when linking some commands.
75
76Instructions for installing Debian on your Stora can be found on the OpenStora website, http://www.openstora.com/wiki/index.php?title=How_to_install_Debian_Linux_on_NETGEAR_Stora.
77
78> _-- dave cheney_
79
80## Qnap TS-119P II
81
82Architecture: ARMv5
83
84Operating System: Debian Squeeze
85
86The Qnap TS series of NASs are excellent hackable little linux hosts. The TS-11P9 II is a 2Ghz Marvell Kirkwood ARMv5 processor with 512mb of ram and a single SATA drive bay.
87
88The kirkwood platform is supported by the native debian installer. http://www.cyrius.com/debian/kirkwood/qnap/ts-119/install.html
89
90> _-- dave cheney_
91
92## Pandaboard
93
94Architecture: ARMv7
95
96Operating System: Ubuntu 12.04LTS (armhf)
97
98The Pandaboard is a dual core ARMv7 development board based on the Texas Instruments OMAP4 SoC platform. I run ubuntu 12.04 LTS server on mine, which is an excellent distribution for Arm development. The Pandaboard has a gig of ram which makes it excellent for development and benchmarking.
99
100Instructions and SD card image can be found on on the Ubuntu wiki, https://wiki.ubuntu.com/ARM/Server/Install#Installing_pre-installed_OMAP4_Precise_.2812.04.29_Server_Images.
101
102> _-- dave cheney_
103
104## BeagleBone
105
106Architecture: ARMv7 single core, Cortex-A8, 256MB RAM, 720 MHz
107
108Operating System: Angstrom Linux
109
110BeagleBone is similar to Beagleboard, but without the video components. Angstrom is a very small Linux distribution for ARM based systems. It is built on top of Yocto and OpenEmbedded with additional tools and recipes to make it even easier to build a distribution. You can think of Angstrom as Ubuntu and OpenEmbedded/Yocto as Debian. Angstrom is very light weight and fast compared to Ubuntu. It uses systemd instead of the sys5 scripts which help give you a very fast boot time of a few seconds.
111
112BeagleBone is probably faster than a RasberryPI because of it's newer Cortex-A8 dual-issue superscalar architecture, but the PI has the GPU which theoretically could be used with something like OpenCL to really run circles around the BeagleBone. However, for embedded applications the BeagleBone is easier to work with because it is ready out of the box with GPIO connections.
113
114I've cross compiled for ARM with 5g from a Mac and so far I haven't run into any problems. You can build on the BeagleBone, but cross compiling with Go is so easy that it is better to save wear and tear on the flash drive and just compile somewhere else.
115
116> _-- hans stimer_
117
118### Zyxel NSA 310
119
120Architecture: ARM5
121Platform: Debian Wheeze
122
123Successfuly built default branch, going to write fan control daemon for this device in golang.
124
125### Raspberry Pi
126
127Architecture: ARM1176JZFS, with floating point, running at 700Mhz
128
129Operating System: Debian Wheezy beta distribution (http://www.raspberrypi.org/archives/1435) reported as:
130
131` Linux raspberrypi 3.1.9+ #125 PREEMPT Sun Jun 17 16:09:36 BST 2012 armv6l GNU/Linux `
132
133**Memory Split**: the Pi shares its 256mb of memory between the CPU and the GPU. You should allocate as much memory as possible to the CPU for a successful compilation. The configuration for the memory split is stored on your SD card. This link has a script to adjust the configuration, http://sirlagz.net/?p=445.
134
135Go version weekly.2012-03-27 +645947213cac, with timeout and GOARM 7 patches http://codereview.appspot.com/5987063/) builds with 2 test failures: encoding/gob fails with out of memory, and fmt fails the NaN test.
136
137Successfully installed and run SVGo via go get github.com/ajstarks/svgo, tested with goplay:
138
139![http://farm8.staticflickr.com/7139/7451061716_fbb585c55f.jpg](http://farm8.staticflickr.com/7139/7451061716_fbb585c55f.jpg)
140
141Division benchmark via http://codereview.appspot.com/6258067:
142
143
144```
145$ cd $GOROOT/src/pkg/runtime
146$ go test -test.bench=BenchmarkUint
147
148
149BenchmarkUint32Div7 5000000 547 ns/op
150BenchmarkUint32Div37 5000000 547 ns/op
151BenchmarkUint32Div123 5000000 547 ns/op
152BenchmarkUint32Div763 5000000 547 ns/op
153BenchmarkUint32Div1247 5000000 547 ns/op
154BenchmarkUint32Div9305 5000000 547 ns/op
155BenchmarkUint32Div13307 5000000 547 ns/op
156BenchmarkUint32Div52513 5000000 547 ns/op
157BenchmarkUint32Div60978747 5000000 547 ns/op
158BenchmarkUint32Div106956295 5000000 547 ns/op
159BenchmarkUint32Mod7 5000000 547 ns/op
160BenchmarkUint32Mod37 5000000 547 ns/op
161BenchmarkUint32Mod123 5000000 547 ns/op
162BenchmarkUint32Mod763 5000000 547 ns/op
163BenchmarkUint32Mod1247 5000000 547 ns/op
164BenchmarkUint32Mod9305 5000000 547 ns/op
165BenchmarkUint32Mod13307 5000000 547 ns/op
166BenchmarkUint32Mod52513 5000000 547 ns/op
167BenchmarkUint32Mod60978747 5000000 547 ns/op
168BenchmarkUint32Mod106956295 5000000 547 ns/op
169```
170
171Running the hardware floating point distribution, Raspbian "pisces" (http://www.raspbian.org/PiscesImages) and applying the patches in https://gist.github.com/3116118, here are the results of the Eleanor McHugh gospeed benchmark:
172
173```
174raspbian@pisces:~/gowork/src/github.com/feyeleanor/gospeed$ uname -a
175Linux pisces 3.1.9+ #171 PREEMPT Tue Jul 17 01:08:22 BST 2012 armv6l GNU/Linux
176raspbian@pisces:~/gowork/src/github.com/feyeleanor/gospeed$ go test -test.bench=".*"
177PASS
178BenchmarkBaselineCastInt32ToInt 100000000 13.5 ns/op
179BenchmarkBaselineCastIntToInt32 100000000 13.5 ns/op
180BenchmarkBaselineCastInt64ToUint64 100000000 17.8 ns/op
181BenchmarkBaselineCastUint64ToInt64 100000000 17.2 ns/op
182BenchmarkBaselineVariableGet 100000000 13.4 ns/op
183BenchmarkBaselineVariableSet 100000000 22.4 ns/op
184BenchmarkBaselineVariableGetInterface 100000000 13.5 ns/op
185BenchmarkBaselineVariableSetInterface 50000000 31.3 ns/op
186BenchmarkBaselineVariableIncrement 100000000 23.9 ns/op
187BenchmarkBaselineVariableDecrement 100000000 23.9 ns/op
188BenchmarkBaselineFieldGet 100000000 13.5 ns/op
189BenchmarkBaselineFieldSet 100000000 20.9 ns/op
190BenchmarkBaselineSliceGet 50000000 32.9 ns/op
191BenchmarkBaselineSliceSet 50000000 34.5 ns/op
192BenchmarkBaselineMapIntGet 1000000 1448 ns/op
193BenchmarkBaselineMapIntSet 1000000 1968 ns/op
194BenchmarkBaselineMapStringGet 1000000 1119 ns/op
195BenchmarkBaselineMapStringSet 1000000 1675 ns/op
196BenchmarkBaselineIf 100000000 15.0 ns/op
197BenchmarkBaselineIfElse 100000000 15.0 ns/op
198BenchmarkBaselineSwitchDefault 100000000 13.5 ns/op
199BenchmarkBaselineSwitchOneCase 100000000 15.0 ns/op
200BenchmarkBaselineSwitchTwoCases 100000000 18.0 ns/op
201BenchmarkBaselineSwitchTwoCasesFallthrough 100000000 18.0 ns/op
202BenchmarkBaselineForLoopIteration 50000000 42.0 ns/op
203BenchmarkBaselineForReverseLoopIteration 50000000 36.0 ns/op
204BenchmarkBaselineForRange 20000000 80.9 ns/op
205BenchmarkBaselineForSliceLength 50000000 39.0 ns/op
206BenchmarkBaselineForReverseSliceLength 50000000 36.0 ns/op
207BenchmarkBaselineForLoopIteration10 20000000 119 ns/op
208BenchmarkBaselineForReverseLoopIteration10 20000000 92.9 ns/op
209BenchmarkBaselineForRange10 10000000 215 ns/op
210BenchmarkBaselineForSliceLength10 20000000 109 ns/op
211BenchmarkBaselineForReverseSliceLength10 20000000 92.9 ns/op
212BenchmarkBaselineForLoopIteration100 2000000 929 ns/op
213BenchmarkBaselineForReverseLoopIteration100 5000000 700 ns/op
214BenchmarkBaselineForRange100 1000000 1567 ns/op
215BenchmarkBaselineForSliceLength100 2000000 853 ns/op
216BenchmarkBaselineForReverseSliceLength100 5000000 700 ns/op
217BenchmarkBaselineForLoopIteration10000 10000 106006 ns/op
218BenchmarkBaselineForReverseLoopIteration10000 50000 67480 ns/op
219BenchmarkBaselineForRange10000 10000 153841 ns/op
220BenchmarkBaselineForSliceLength10000 20000 85735 ns/op
221BenchmarkBaselineForReverseSliceLength10000 50000 69461 ns/op
222BenchmarkBaselineMakeChannelBoolUnbuffered 200000 10162 ns/op
223BenchmarkBaselineMakeChannelBool1 200000 12517 ns/op
224BenchmarkBaselineMakeChannelBool10 200000 12521 ns/op
225BenchmarkBaselineMakeChannelStringUnbuffered 500000 10369 ns/op
226BenchmarkBaselineMakeChannelString1 200000 12576 ns/op
227BenchmarkBaselineMakeChannelString10 100000 22358 ns/op
228BenchmarkBaselineGo 50000 367593 ns/op
229BenchmarkBaselineFunctionCall 50000000 57.0 ns/op
230BenchmarkBaselineFunctionCallArg 20000000 81.0 ns/op
231BenchmarkBaselineFunctionCall5VarArgs 500000 6852 ns/op
232BenchmarkBaselineFunctionCallInt 50000000 60.3 ns/op
233BenchmarkBaselineFunctionCall5VarInts 1000000 3185 ns/op
234BenchmarkBaselineFunctionCallWithDefer 1000000 2330 ns/op
235BenchmarkBaselineFunctionCallPanicRecover 500000 6222 ns/op
236BenchmarkBaselineMethodCallDirect 20000000 83.8 ns/op
237BenchmarkBaselineMethodCallDirect1Arg 20000000 106 ns/op
238BenchmarkBaselineMethodCallDirect1Int 20000000 85.2 ns/op
239BenchmarkBaselineMethodCallDirect5Args 5000000 368 ns/op
240BenchmarkBaselineMethodCallDirect5Ints 10000000 233 ns/op
241BenchmarkBaselineMethodCallIndirect 100000000 18.0 ns/op
242BenchmarkBaselineMethodCallIndirect1Arg 50000000 42.0 ns/op
243BenchmarkBaselineMethodCallIndirect1Int 100000000 19.5 ns/op
244BenchmarkBaselineMethodCallIndirect5Args 5000000 309 ns/op
245BenchmarkBaselineMethodCallIndirect5Ints 10000000 168 ns/op
246BenchmarkBaselineTypeAssertion 10000000 218 ns/op
247BenchmarkBaselineTypeAssertionEmptyInterface 20000000 106 ns/op
248BenchmarkBaselineTypeAssertionInterface1 5000000 576 ns/op
249BenchmarkBaselineTypeAssertionInterface2 5000000 579 ns/op
250BenchmarkBaselineTypeReflectPrimitiveToValue 5000000 425 ns/op
251BenchmarkBaselineTypeReflectSliceToValue 1000000 3218 ns/op
252BenchmarkBaselineTypeReflectStructToValue 500000 4760 ns/op
253BenchmarkBaselineTypeCheck 10000000 189 ns/op
254BenchmarkBaselineTypeCheckEmptyInterface 20000000 93.1 ns/op
255BenchmarkBaselineTypeCheckInterface1 5000000 511 ns/op
256BenchmarkBaselineTypeCheckInterface2 5000000 516 ns/op
257BenchmarkBaselineTypeSwitchOneCase 10000000 262 ns/op
258BenchmarkBaselineTypeSwitchBasicTypesCase 10000000 295 ns/op
259BenchmarkBaselineTypeSwitchEmptyInterface 10000000 163 ns/op
260BenchmarkBaselineTypeSwitchInterface1 5000000 588 ns/op
261BenchmarkBaselineTypeSwitchInterface2 5000000 602 ns/op
262BenchmarkBaselineNewStructureLiteral 20000000 84.0 ns/op
263BenchmarkBaselineNewStructure 20000000 127 ns/op
264BenchmarkBaselineNewSliceLiteral 50000000 54.2 ns/op
265BenchmarkBaselineNewSlice 1000000 3124 ns/op
266BenchmarkBaselineNewMapLiteralIntToInt 500000 9083 ns/op
267BenchmarkBaselineNewMapLiteralIntToInterface 500000 9807 ns/op
268BenchmarkBaselineNewMapLiteralStringToInt 500000 9792 ns/op
269BenchmarkBaselineNewMapLiteralStringToInterface 500000 10595 ns/op
270BenchmarkBaselineNewMapLiteralIntToInt2Item 200000 14265 ns/op
271BenchmarkBaselineNewMapLiteralIntToInterface2Item 200000 14669 ns/op
272BenchmarkBaselineNewMapLiteralStringToInt2Item 200000 14025 ns/op
273BenchmarkBaselineNewMapLiteralStringToInterface2Item 200000 15086 ns/op
274BenchmarkBaselineNewMapIntToInt 500000 9025 ns/op
275BenchmarkBaselineNewMapIntToInterface 500000 9753 ns/op
276BenchmarkBaselineNewMapStringToInt 500000 9740 ns/op
277BenchmarkBaselineNewMapStringToInterface 500000 10486 ns/op
278BenchmarkBaselineSliceCopy 5000000 300 ns/op
279BenchmarkBaselineNewSliceAppendElement1 1000000 3318 ns/op
280BenchmarkBaselineNewSliceAppendElement10 1000000 5174 ns/op
281ok github.com/feyeleanor/gospeed 417.296s
282```
283
284_-- anthony starks_
285
286## ODROID-X
287
288Architecture: ARMv7 quad-core Cortex-A9 (Samsung Exynos 4412 1.4GHz), 1GB RAM, Mali graphics (untested).
289
290Operating System: [Archlinux ARM](http://archlinuxarm.org/)
291
292Go pre-1.1 compiles out of the box. The four cores make it particularly suited to Go multi-threaded programs. An ODROID-X2 is coming (Nov 2012) with more RAM.
293
294_-- Rémy Oudompheng_
295
296## BananaPi
297
298[BananaPi](http://bananapi.org) has a few enhanced hardware components compare with Raspberry Pi.
299
300| **Architecture** | **Comments** |
301|:-----------------|:-------------|
302| [Allwinner A20(ARM Cortex-A7 Dual-core, 1GHz, Mali400MP2 GPU)](http://www.allwinnertech.com/en/clq/processora/A20.html) | tbc |
303| eSATA | No worry to wear out your root SD Card|
304| Onboard Microphone | tbc |
305| 1G Etherenet | tbc |
306| 1G RAM | tbc |
307| Reset Switch | To reset the board ?|
308| Power Switch | To power cycle the board ?|
309
310```
Andrew Gerrand5bc444d2014-12-10 11:35:11 +1100311root@bpi01:/data/go13/src# cat ./buildgo.bash
312#!/bin/bash
313# use 1 CPU to avoid out of memory compilation issue.
314time taskset 2 ./make.bash
315
316root@bpi01:/data/go13/src# ./buildgo.bash
317
318<snipped>
319
320Installed Go for linux/arm in /data/go1.3
321Installed commands in /data/go1.3/bin
322
323real 9m9.222s
324user 8m18.960s
325sys 0m40.920s
326root@bpi01:/data/go1.3/src#
327```
328
329_--T.J. Yang_
330
331## AppliedMicro X-Gene (ARMv8)
332
333Architecture: ARMv8 (64-bit) 8-core, 2.4GHz, 16GB RAM
334
335Operating System: Linux
336
337The linux/arm64 Go port is not functional yet, but you can run the linux/arm port.
338
339```
340$ sudo apt-get install gcc-arm-linux-gnueabihf libc6-dev-armhf-cross
341$
342$ cd go/src && CC='arm-linux-gnueabihf-gcc -static' GO_DISTFLAGS=-s GOHOSTARCH=arm GOARM=7 CGO_ENABLED=0 ./make.bash
343$
344$ uname -a
345Linux xgene 3.16.0-25-generic #33-Ubuntu SMP Tue Nov 4 12:06:56 UTC 2014 aarch64 aarch64 aarch64 GNU/Linux
346$ go version
347go version devel +6a8045fd9da9 Wed Dec 03 18:33:35 2014 +0100 linux/arm
348$ go env
349GOARCH="arm"
350GOBIN=""
351GOCHAR="5"
352GOEXE=""
353GOHOSTARCH="arm"
354GOHOSTOS="linux"
355GOOS="linux"
356GOPATH="/home/aram"
357GORACE=""
358GOROOT="/home/aram/go"
359GOTOOLDIR="/home/aram/go/pkg/tool/linux_arm"
360CC="arm-linux-gnueabihf-gcc"
361GOGCCFLAGS="-static -fPIC -marm -pthread -fmessage-length=0"
362CXX="g++"
363CGO_ENABLED="1"
364```
365
366A static toolchain is required as arm64 Linux distributions don't ship the necessary 32-bit arm libraries (except in a sysroot). ` GO_DISTFLAGS=-s ` is not enough, ` CC='arm-linux-gnueabihf-gcc -static' ` is required to build a static dist tool.
367
368_-- Aram Hăvărneanu_