Skip to content

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

Closed as duplicate

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

Activity

  1. added
    coreAnything pertaining to core functionality of the application (opencode server stuff)
    on Apr 29, 2026
  2. github-actions commented on Apr 29, 2026

    @github-actions
    Contributor

    This issue might be a duplicate of existing issues. Please check:

  3. marcioganzer commented on Apr 29, 2026

    @marcioganzer
    Author

    This seems to be a distribution/packaging issue rather than a runtime bug.

    The current release (opencode-darwin-x64) appears to be built targeting a modern x86_64 baseline (likely x86-64-v3 / AVX2). On CPUs without AVX2 support (e.g. Ivy Bridge), this results in an immediate SIGILL on startup.

    From what I can see, the installer (or upstream tooling such as llm-agents) always selects the same binary, without considering CPU capabilities.

    Suggested approach

    A robust fix would be one of the following:

    1. Provide multiple x86_64 builds

      • x86-64-v1 (baseline, no AVX2 — compatible with older CPUs)
      • x86-64-v3 (AVX2 optimized)
    2. Select binary dynamically at install time

      • Detect CPU features (e.g. AVX2 support)
      • Download the appropriate build
    3. Fallback strategy

      • Default to baseline build when CPU detection is not available

    Why this matters

    Without this, the current binary is unusable on:

    • pre-Haswell Intel Macs
    • any x86_64 CPU without AVX2

    This is not a misconfiguration — the binary itself is incompatible with the CPU.

    Happy to test a baseline-compatible build if one is provided.

  4. removed
    bugSomething isn't working
    coreAnything pertaining to core functionality of the application (opencode server stuff)
    on May 3, 2026
  5. diwu-sf commented on Jun 1, 2026

    @diwu-sf

    I think the fix belongs in packages/opencode/script/build.ts.
    The -baseline binaries are built, but not used in the packaged asset.

    If the published binary were mapped to the -baseline builds, then it would work on CPUs without AVX2.
    It's also not just a Mac problem, it's also a problem on linux and windows.

      opencode-linux-x64          -> bun-linux-x64-baseline
      opencode-linux-x64-musl     -> bun-linux-x64-baseline-musl
      opencode-darwin-x64         -> bun-darwin-x64-baseline
      opencode-windows-x64        -> bun-windows-x64-baseline
    
  6. tobocop2 commented on Jul 15, 2026

    @tobocop2

    Update — root cause found, upstream fix open, and there are builds you can try.

    What's actually wrong

    bun ships no baseline macOS build. @oven/bun-darwin-x64-baseline is byte-identical to @oven/bun-darwin-x64 (both the AVX2 build), which is why opencode's -baseline Mac binary is too. That's because oven-sh/WebKit never builds a baseline macOS WebKit — bun-webkit-macos-amd64-baseline.tar.gz returns HTTP 404.

    opencode's own packaging is fine — build.ts requests bun-darwin-x64-baseline correctly; there just isn't a real one upstream.

    Full evidence: oven-sh/bun#34206

    Upstream fix (open now)

    Builds you can try today

    👉 https://github.com/tobocop2/opencode-bun-pre-avx2-mac/releases/latest

    I built a baseline bun and compiled opencode against it:

    binary AVX2 (ymm) instructions
    shipped opencode-darwin-x64-baseline 248,019
    this build 14,407
    @oven/bun-linux-x64-baseline (verified working on real pre-AVX2 hardware) 12,328

    I need testers — I couldn't test this on a real Mac. I experienced this issue personally on my moms 2013 intel mac, but I no longer have access to it.

    No cloud provider rents a pre-AVX2 Intel Mac, so I verified the recipe on a pre-AVX2 linux box instead (the baseline runs opencode run to completion there; the AVX2 build crashes after ~21s / ~3.9 GB). If you have one of these Macs, I'd genuinely appreciate a report either way:

    chmod +x opencode-darwin-x64-baseline
    ./opencode-darwin-x64-baseline --version

    Unofficial builds — not affiliated with oven-sh or anomalyco, just a stopgap until the PRs land.

  7. marcioganzer commented on Jul 17, 2026

    @marcioganzer
    Author

    @tobocop2

    I just tested the opencode-darwin-x64-baseline build on my Mac Mini Late 2012 (Ivy Bridge).

    I can confirm that the application runs successfully without any SIGILL crashes. The performance is a bit slower compared to modern machines, but it is fully functional and stable enough for use.

    Thank you for providing the baseline build!

  8. tobocop2 commented on Jul 17, 2026

    @tobocop2

    @tobocop2

    I just tested the opencode-darwin-x64-baseline build on my Mac Mini Late 2012 (Ivy Bridge).

    I can confirm that the application runs successfully without any SIGILL crashes. The performance is a bit slower compared to modern machines, but it is fully functional and stable enough for use.

    Thank you for providing the baseline build!

    glad to hear! and no problem!

  9. tobocop2 commented on Aug 5, 2026

    @tobocop2

    Surfacing this again. @jlongster sorry to ping but I think I need an opencode maintainers help to nudge the oven-sh team.

    My builds are getting downloads (35 so far) and that's without me publicizing this in any capacity outside of these github issue comments.

    https://github.com/tobocop2/opencode-bun-pre-avx2-mac

  10. neriousy commented on Oct 1, 2026

    @neriousy
    Member

    Closing as a duplicate of #8345, which tracks OpenCode crashing with an illegal instruction on older Intel CPUs without AVX2. Please add your CPU model and 👍 there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions