Skip to content

Crash on older Intel Macs (Illegal instruction / AVX2 incompatibility) #24876

@marcioganzer

Description

@marcioganzer

Description

Description

The opencode binary crashes immediately on launch on older Intel Macs with the following error:

EXC_BAD_INSTRUCTION (SIGILL)
Illegal instruction: 4

This happens before the application fully initializes (during dyld initializer phase).


Environment

  • macOS: 13.7.4
  • Machine: Macmini6,2 (Intel Ivy Bridge, 2012)
  • CPU: x86_64 (supports AVX, but NOT AVX2)
  • Installation method: Homebrew (anomalyco/tap/opencode)

Crash details

Relevant excerpt:

Exception Type:        EXC_BAD_INSTRUCTION (SIGILL)
Termination Reason:    Illegal instruction: 4

Thread 0 Crashed:
0   opencode  ...
...
dyld4::Loader::findAndRunAllInitializers

Instruction stream shows AVX-prefixed opcodes (e.g. c4 ...), which indicates usage of instructions not supported by this CPU.


Root cause (analysis)

The distributed binary:

opencode-darwin-x64.zip

appears to be compiled targeting a modern x86_64 CPU baseline (likely x86-64-v3 or -march=native), which requires AVX2.

However:

  • Ivy Bridge CPUs only support AVX1, not AVX2
  • Executing AVX2 instructions results in SIGILL (illegal instruction)

Because the Homebrew formula only downloads a prebuilt binary (no local compilation), there is no way to adapt the build to older CPUs.


Why this matters

This makes the tool unusable on:

  • Intel Macs pre-Haswell (≈ 2013 and earlier)
  • Any x86_64 CPU without AVX2 support

These machines are still relatively common in development environments.


Suggested fixes

1. Provide a baseline-compatible build

Publish an additional binary targeting a more compatible baseline, e.g.:

  • x86-64 (v1/v2)
  • or -march=nehalem / -C target-cpu=x86-64

Example naming:

opencode-darwin-x64-legacy.zip

2. Avoid -march=native in release builds

If currently used, this should be avoided for distributed binaries, as it makes them dependent on the build machine CPU.


3. Explicit target configuration

Depending on the toolchain:

  • Rust

    RUSTFLAGS="-C target-cpu=x86-64"
    
  • Go

    GOAMD64=v1
    
  • Bun / Zig / others
    Ensure target is not implicitly x86-64-v3


4. (Optional) Document CPU requirements

If AVX2 is required by design, it would be helpful to explicitly document:

Requires x86_64 CPU with AVX2 support


Workarounds

Currently, there is no workaround via Homebrew, since it only installs the prebuilt binary.


Summary

  • Crash is caused by AVX2 instructions on non-AVX2 CPU
  • Not a macOS issue or misconfiguration
  • Requires either a compatible build or documented requirement

Plugins

No response

OpenCode version

last

Steps to reproduce

run brew install anomaly/tap/opencode

Screenshot and/or share link

No response

Operating System

macOS 13.7.4

Terminal

native macOS terminal

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions