Compiling go for FreeBSD 13.2 arm

39 Views Asked by At

I would like to compile some Go code for a FreeBSD machine:

quark$ uname -a
FreeBSD quark 13.2-RELEASE FreeBSD 13.2-RELEASE releng/13.2-n254617-525ecfdad597 RPI-B arm

I am cross compiling from a Linux machine:

archlinux$ uname -a
Linux archlinux 6.7.6-arch1-1 #1 SMP PREEMPT_DYNAMIC Fri, 23 Feb 2024 16:31:48 +0000 x86_64 GNU/Linux
archlinux$ go version
go version go1.22.0 linux/amd64

Some Go code:

package main

import (
        "fmt"
        "time"
)

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

Compile steps:

archlinux$ export GOARCH=arm
archlinux$ export GOOS=freebsd
archlinux$ export GOARM=6
archlinux$ go build time.go
archlinux$ file time
time: ELF 32-bit LSB executable, ARM, EABI5 version 1 (FreeBSD), statically linked, for FreeBSD 12.3, FreeBSD-style, Go BuildID=xdfWXxT__aMomffvV1zx/MU0rcYoRAe-TcUCtTzOB/NTCZChXbctQS2ubirhCR/-Ez3jurVLV9a1Wskk5xa, with debug_info, not stripped

Yet when I attempt to execute this binary on the target machine:

quark$ file time
time: ELF 32-bit LSB executable, ARM, EABI5 version 1 (FreeBSD), statically linked, for FreeBSD 12.3, FreeBSD-style, Go BuildID=xdfWXxT__aMomffvV1zx/MU0rcYoRAe-TcUCtTzOB/NTCZChXbctQS2ubirhCR/-Ez3jurVLV9a1Wskk5xa, with debug_info, not stripped
quark$ ./time
Illegal instruction (core dumped)

Related thread: How to cross compile go application for FreeBSD within a Raspberry pi 1 model B, did not solve my issue

0

There are 0 best solutions below