Skip to content

fix: replicate launcher's AVX2/musl detection in postinstall.mjs#875

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

fix: replicate launcher's AVX2/musl detection in postinstall.mjs#875
GautamKumarOffical wants to merge 1 commit into
XiaomiMiMo:mainfrom
GautamKumarOffical:fix/postinstall-avx2-detection

Conversation

@GautamKumarOffical

Copy link
Copy Markdown

Fixes #871

postinstall.mjs always hardcodes the non-baseline, non-musl binary package name. On non-AVX2 x64 CPUs (Sandy Bridge, Ivy Bridge, pre-Excavator AMD) this writes a cache file pointing to the wrong binary, and the launcher short-circuits to that cache before its own CPU detection runs, causing SIGILL.

What changed:

Replicated the launcher's (bin/mimo) binary selection logic in postinstall.mjs:

  • Added supportsAvx2() — checks /proc/cpuinfo on Linux, sysctl on macOS
  • Added detectMusl() — checks for Alpine or musl-linked ldd
  • findBinary() now builds the same candidate list with correct priority ordering (baseline first for non-AVX2, musl variants for Alpine) and picks the first that resolves

The cached bin/.mimocode now points to the correct binary for the user's CPU.

postinstall.mjs always hardcoded the non-baseline, non-musl binary
package name. On non-AVX2 x64 CPUs this wrote a cache file pointing
to the wrong binary, and the launcher short-circuited to that cache
before its own CPU detection ran, causing SIGILL.

Now postinstall.mjs builds the same candidate list as bin/mimo
(AVX2 detection, musl detection, priority ordering) and picks the
first one that resolves, so the cached binary matches what the
launcher would have chosen.
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.

postinstall.mjs picks AVX2 binary on non-AVX2 x64 CPUs → SIGILL on first run (cache shadows launcher's runtime detection)

1 participant