oven-sh / bun

Incredibly fast JavaScript runtime, bundler, test runner, and package manager – all in one
https://bun.sh
Other
74.29k stars 2.77k forks source link

Exit on startup if SSE4.2 is not available #14745

Open 190n opened 3 weeks ago

190n commented 3 weeks ago

Bun does not support x86_64 CPUs without SSE4.2 (older than Intel Nehalem or AMD Bulldozer) at this time, even in our x64-baseline builds. On unsupported CPUs, currently Bun crashes with "illegal instruction" at some unpredictable point depending on what you call. We should instead perform CPU feature detection as early as possible at startup, and call a function that prints an error message and exits if desired features are missing. This function should be in a separate object file so that we can compile it using minimal x86_64 features (so we don't use an illegal instruction while trying to print this error).

In non-baseline builds, we should check for AVX2 and crash with an error telling them to use the baseline build.

190n commented 3 weeks ago

For context, in terms of microarchitecture levels: