Skip to content

fix: detect AVX2 support in postinstall to select correct binary on older CPUs#1136

Open
ukarpenkov wants to merge 1 commit into
XiaomiMiMo:mainfrom
ukarpenkov:fix/postinstall-avx2-detection
Open

fix: detect AVX2 support in postinstall to select correct binary on older CPUs#1136
ukarpenkov wants to merge 1 commit into
XiaomiMiMo:mainfrom
ukarpenkov:fix/postinstall-avx2-detection

Conversation

@ukarpenkov

Copy link
Copy Markdown

Summary

  • Add AVX2 CPU detection to postinstall.mjs so it selects the baseline binary on older CPUs (e.g. Ivy Bridge)
  • Previously postinstall.mjs always resolved to the non-baseline package, bypassing the fallback logic in bin/mimo

Problem

On x64 CPUs without AVX2 (Intel 3rd gen / Ivy Bridge and older), npm install @mimo-ai/cli followed by running mimo crashes with zsh: illegal hardware instruction.

Root cause: postinstall.mjs always resolves to @mimo-ai/mimocode-<platform>-<arch> (the non-baseline binary with AVX2). It creates a .mimocode symlink to this binary. When bin/mimo runs, it finds the cached .mimocode and executes it directly — before ever reaching the AVX2-aware fallback logic.

Fix: Add supportsAvx2() detection to postinstall.mjs (same logic already used in bin/mimo) so it selects @mimo-ai/mimocode-darwin-x64-baseline (or equivalent) when AVX2 is not available.

Changes

  • packages/opencode/script/postinstall.mjs:
    • Add child_process import
    • Add supportsAvx2(platform, arch) function (mirrors bin/mimo:57-105)
    • Update findBinary() to build a priority list of package names based on AVX2/musl detection, matching the fallback logic in bin/mimo

Testing

Verified that the logic mirrors bin/mimo exactly. The baseline binary package @mimo-ai/mimocode-darwin-x64-baseline is already published at v0.1.1.

Fixes #1130

…lder CPUs

The postinstall script always resolved to the non-baseline binary
package, bypassing the AVX2 fallback logic in bin/mimo. On CPUs without
AVX2 (e.g. Ivy Bridge), this caused 'illegal hardware instruction'.

Add supportsAvx2() detection (same logic as bin/mimo) to postinstall.mjs
so it selects the baseline binary when needed.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

zsh: illegal hardware instruction on iMac 27" Late 2012 (Ivy Bridge CPU)

1 participant