title: How to cross compile go application for FreeBSD within a Raspberry pi 1 model B
body: <p>On a <a href="https://www.raspberrypi.org/products/model-b/" rel="nofollow noreferrer">Raspberry Pi 1 model B</a> I installed <a href="https://www.freebsd.org/where.html" rel="nofollow noreferrer">FreeBSD 10.3</a> using the SD Card Images <a href="ftp://ftp.freebsd.org/pub/FreeBSD/releases/arm/armv6/ISO-IMAGES/10.3/FreeBSD-10.3-RELEASE-arm-armv6-RPI-B.img.xz" rel="nofollow noreferrer">RPI-B</a>.</p>
  
  <p>I can boot, get network, ssh into it, etc, all seems to be ok and functional. This is part of the dmesg output:</p>
  
  <pre><code>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)
  </code></pre>
  
  <p>On a mac os X (10.11.6) with go 1.7.1:</p>
  
  <pre><code>go version go1.7.1 darwin/amd64
  </code></pre>
  
  <p>I am cross compile this code:</p>
  
  <p></p>
  
  <pre><code>package main
  
  import (
          "fmt"
          "time"
  )
  
  func main() {
          t := time.Now().UTC()
          fmt.Println("Location:", t.Location(), ":Time:", t.Format(time.RFC3339Nano))
  }
  </code></pre>
  
  <p>With:</p>
  
  <pre><code>env GOOS=freebsd GOARCH=arm go build
  </code></pre>
  
  <p>Running the generated binary on the raspberry-pi generates a coredump:</p>
  
  <pre><code>freebsd@rpi-b:~ % ./time 
  Illegal instruction (core dumped)
  </code></pre>
  
  <p>On the <code>time.core</code> after typing:</p>
  
  <pre><code>$ strings time.core
  </code></pre>
  
  <p>besides many characters I see this:</p>
  
  <pre><code>fatal error: cgo callback before cgo call
  </code></pre>
  
  <p>Any idea how what flags to use or how to properly cross-compile for FreeBSD within a Raspberry pi ?</p>