fix: detect AVX2 support in postinstall to select correct binary on older CPUs#1136
Open
ukarpenkov wants to merge 1 commit into
Open
fix: detect AVX2 support in postinstall to select correct binary on older CPUs#1136ukarpenkov wants to merge 1 commit into
ukarpenkov wants to merge 1 commit into
Conversation
…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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
postinstall.mjsso it selects the baseline binary on older CPUs (e.g. Ivy Bridge)postinstall.mjsalways resolved to the non-baseline package, bypassing the fallback logic inbin/mimoProblem
On x64 CPUs without AVX2 (Intel 3rd gen / Ivy Bridge and older),
npm install @mimo-ai/clifollowed by runningmimocrashes withzsh: illegal hardware instruction.Root cause:
postinstall.mjsalways resolves to@mimo-ai/mimocode-<platform>-<arch>(the non-baseline binary with AVX2). It creates a.mimocodesymlink to this binary. Whenbin/mimoruns, it finds the cached.mimocodeand executes it directly — before ever reaching the AVX2-aware fallback logic.Fix: Add
supportsAvx2()detection topostinstall.mjs(same logic already used inbin/mimo) so it selects@mimo-ai/mimocode-darwin-x64-baseline(or equivalent) when AVX2 is not available.Changes
packages/opencode/script/postinstall.mjs:child_processimportsupportsAvx2(platform, arch)function (mirrorsbin/mimo:57-105)findBinary()to build a priority list of package names based on AVX2/musl detection, matching the fallback logic inbin/mimoTesting
Verified that the logic mirrors
bin/mimoexactly. The baseline binary package@mimo-ai/mimocode-darwin-x64-baselineis already published at v0.1.1.Fixes #1130