如何在 Raspberry pi 1 模型 B 中为 FreeBSD 交叉编译 go 应用程序
How to cross compile go application for FreeBSD within a Raspberry pi 1 model B
在 Raspberry Pi 1 model B I installed FreeBSD 10.3 using the SD Card Images RPI-B.
我可以启动、获取网络、通过 ssh 连接等等,一切似乎都正常且功能正常。这是 dmesg 输出的一部分:
FreeBSD 10.3-RELEASE #0 r297264: Fri Mar 25 08:01:14 UTC 2016
root@releng1.nyi.freebsd.org:/usr/obj/arm.armv6/usr/src/sys/RPI-B arm
FreeBSD clang version 3.4.1 (tags/RELEASE_34/dot1-final 208032) 20140512
VT: init without driver.
CPU: ARM1176JZ-S rev 7 (ARM11J core)
Supported features: ARM_ISA THUMB2 JAZELLE ARMv4 Security_Ext
WB enabled LABT branch prediction enabled
16KB/32B 4-way instruction cache
16KB/32B 4-way write-back-locking-C data cache
real memory = 503312384 (479 MB)
avail memory = 483127296 (460 MB)
在 mac os X (10.11.6) 上 go 1.7.1:
go version go1.7.1 darwin/amd64
我是cross 编译这段代码:
package main
import (
"fmt"
"time"
)
func main() {
t := time.Now().UTC()
fmt.Println("Location:", t.Location(), ":Time:", t.Format(time.RFC3339Nano))
}
有:
env GOOS=freebsd GOARCH=arm go build
运行 raspberry-pi 上生成的二进制文件生成一个 coredump:
freebsd@rpi-b:~ % ./time
Illegal instruction (core dumped)
在 time.core
输入后:
$ strings time.core
除了很多字符我还看到这个:
fatal error: cgo callback before cgo call
知道如何使用什么标志或如何在 Raspberry pi 中正确地为 FreeBSD cross 编译吗?
感谢@putu 的评论,我可以使用 GOARM=6
进行交叉编译
env GOOS=freebsd GOARCH=arm GOARM=6 go build
在 Raspberry Pi 1 model B I installed FreeBSD 10.3 using the SD Card Images RPI-B.
我可以启动、获取网络、通过 ssh 连接等等,一切似乎都正常且功能正常。这是 dmesg 输出的一部分:
FreeBSD 10.3-RELEASE #0 r297264: Fri Mar 25 08:01:14 UTC 2016
root@releng1.nyi.freebsd.org:/usr/obj/arm.armv6/usr/src/sys/RPI-B arm
FreeBSD clang version 3.4.1 (tags/RELEASE_34/dot1-final 208032) 20140512
VT: init without driver.
CPU: ARM1176JZ-S rev 7 (ARM11J core)
Supported features: ARM_ISA THUMB2 JAZELLE ARMv4 Security_Ext
WB enabled LABT branch prediction enabled
16KB/32B 4-way instruction cache
16KB/32B 4-way write-back-locking-C data cache
real memory = 503312384 (479 MB)
avail memory = 483127296 (460 MB)
在 mac os X (10.11.6) 上 go 1.7.1:
go version go1.7.1 darwin/amd64
我是cross 编译这段代码:
package main
import (
"fmt"
"time"
)
func main() {
t := time.Now().UTC()
fmt.Println("Location:", t.Location(), ":Time:", t.Format(time.RFC3339Nano))
}
有:
env GOOS=freebsd GOARCH=arm go build
运行 raspberry-pi 上生成的二进制文件生成一个 coredump:
freebsd@rpi-b:~ % ./time
Illegal instruction (core dumped)
在 time.core
输入后:
$ strings time.core
除了很多字符我还看到这个:
fatal error: cgo callback before cgo call
知道如何使用什么标志或如何在 Raspberry pi 中正确地为 FreeBSD cross 编译吗?
感谢@putu 的评论,我可以使用 GOARM=6
env GOOS=freebsd GOARCH=arm GOARM=6 go build