dtl85148 2016-09-24 15:43
浏览 106
已采纳

如何在Raspberry pi 1模型B中交叉编译FreeBSD的go应用程序

On a Raspberry Pi 1 model B I installed FreeBSD 10.3 using the SD Card Images RPI-B.

I can boot, get network, ssh into it, etc, all seems to be ok and functional. This is part of the dmesg output:

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)

On a mac os X (10.11.6) with go 1.7.1:

go version go1.7.1 darwin/amd64

I am cross compile this code:

package main

import (
        "fmt"
        "time"
)

func main() {
        t := time.Now().UTC()
        fmt.Println("Location:", t.Location(), ":Time:", t.Format(time.RFC3339Nano))
}

With:

env GOOS=freebsd GOARCH=arm go build

Running the generated binary on the raspberry-pi generates a coredump:

freebsd@rpi-b:~ % ./time 
Illegal instruction (core dumped)

On the time.core after typing:

$ strings time.core

besides many characters I see this:

fatal error: cgo callback before cgo call

Any idea how what flags to use or how to properly cross-compile for FreeBSD within a Raspberry pi ?

  • 写回答

1条回答 默认 最新

  • douyouqian8550 2016-09-25 17:53
    关注

    Thanks to @putu comment, I was available to cross-compile using GOARM=6

    env GOOS=freebsd GOARCH=arm GOARM=6 go build
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥50 成都蓉城足球俱乐部小程序抢票
  • ¥15 yolov7训练自己的数据集
  • ¥15 esp8266与51单片机连接问题(标签-单片机|关键词-串口)(相关搜索:51单片机|单片机|测试代码)
  • ¥15 电力市场出清matlab yalmip kkt 双层优化问题
  • ¥30 ros小车路径规划实现不了,如何解决?(操作系统-ubuntu)
  • ¥20 matlab yalmip kkt 双层优化问题
  • ¥15 如何在3D高斯飞溅的渲染的场景中获得一个可控的旋转物体
  • ¥88 实在没有想法,需要个思路
  • ¥15 MATLAB报错输入参数太多
  • ¥15 python中合并修改日期相同的CSV文件并按照修改日期的名字命名文件