Skip to content

cmd/compile: cross compile for OpenBSD arm64 fails with SIGILL Illegal instruction #66040

@ikmckenz

Description

@ikmckenz

Go version

go version go1.22.0 darwin/arm64

Output of go env in your module/workspace:

GO111MODULE=''
GOARCH='arm64'
GOBIN=''
GOCACHE='/Users/ian/Library/Caches/go-build'
GOENV='/Users/ian/Library/Application Support/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFLAGS=''
GOHOSTARCH='arm64'
GOHOSTOS='darwin'
GOINSECURE=''
GOMODCACHE='/Users/ian/go/pkg/mod'
GONOPROXY=''
GONOSUMDB=''
GOOS='darwin'
GOPATH='/Users/ian/go'
GOPRIVATE=''
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/opt/homebrew/Cellar/go/1.22.0/libexec'
GOSUMDB='sum.golang.org'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/opt/homebrew/Cellar/go/1.22.0/libexec/pkg/tool/darwin_arm64'
GOVCS=''
GOVERSION='go1.22.0'
GCCGO='gccgo'
AR='ar'
CC='cc'
CXX='c++'
CGO_ENABLED='1'
GOMOD='/dev/null'
GOWORK=''
CGO_CFLAGS='-O2 -g'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-O2 -g'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-O2 -g'
PKG_CONFIG='pkg-config'
GOGCCFLAGS='-fPIC -arch arm64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -ffile-prefix-map=/var/folders/gh/8flwtdfn4c526_bx0m7ht8380000gn/T/go-build3231430879=/tmp/go-build -gno-record-gcc-switches -fno-common'

What did you do?

Cross compiling a simple hello world program for OpenBSD arm64 fails with SIGILL Illegal instruction.

Hello world code:

package main

import "fmt"

func main() {
    fmt.Println("hello world")
}

Compiled with GOOS=openbsd GOARCH=arm64 go build hello.go from a different machine, and run on an OpenBSD VM running on my MacBook with an M3 Max chip: OpenBSD openbsd-dev.my.domain 7.4 GENERIC.MP#2273 arm64 fails with illegal instruction.

What did you see happen?

Natively building hello world on OpenBSD arm64 works fine, and that machine does have GOOS=openbsd and GOARCH=arm64 defined in the go env, but building the above code with the above command from my darwin/arm64 machine running go1.22.0 as above, and also my linux/amd64 machine running go 1.21.7 produces the illegal instruction error.

GDB on openbsd with the build from linux:

Program received signal SIGILL, Illegal instruction.
_rt0_arm64_openbsd () at /usr/lib/go-1.21/src/runtime/rt0_openbsd_arm64.s:15
15	/usr/lib/go-1.21/src/runtime/rt0_openbsd_arm64.s: No such file or directory.

GDB on openbsd from the build from my Mac:

Program received signal SIGILL, Illegal instruction.
_rt0_arm64_openbsd ()
    at /opt/homebrew/Cellar/go/1.22.0/libexec/src/runtime/rt0_openbsd_arm64.s:15
15	/opt/homebrew/Cellar/go/1.22.0/libexec/src/runtime/rt0_openbsd_arm64.s: No such file or directory.

GDB on openbsd from mac with GOOS=openbsd GOARCH=arm64 go build -trimpath hello.go:

Program received signal SIGILL, Illegal instruction.
_rt0_arm64_openbsd () at runtime/rt0_openbsd_arm64.s:15
15	runtime/rt0_openbsd_arm64.s: No such file or directory.

What did you expect to see?

Note that building the above hello world code into an OpenBSD amd64 binary from both my darwin/arm64 machine and my linux/amd64 machine works and the resulting binary works on a separate OpenBSD amd64 machine I have without issue, so something seems to be wrong with OpenBSD arm64 specifically. I do see openbsd/arm64 in the output of go tool dist list, so I would expect it to work.

Metadata

Metadata

Assignees

No one assigned

    Labels

    FrozenDueToAgeNeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.OS-OpenBSDcompiler/runtimeIssues related to the Go compiler and/or runtime.

    Type

    No type

    Projects

    Status

    Done

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions