Skip to content

Make AVX support an optional build arg instead of a hardcoded assumption - #3

Open
johnnyxmas wants to merge 1 commit into
janholtzhausen:mainfrom
johnnyxmas:fix/optional-avx-build-flag
Open

johnnyxmas wants to merge 1 commit into
janholtzhausen:mainfrom
johnnyxmas:fix/optional-avx-build-flag

Conversation

@johnnyxmas

Copy link
Copy Markdown

Summary

The Dockerfile hardcodes AVX support at both compile time (-p:UseAVX=true, baked into the ReadyToRun binary) and runtime (DOTNET_EnableAVX=1), with no way to override either without editing the Dockerfile.

Any CPU without AVX -- including budget/low-power chips like Intel's Atom-derived Celeron/Pentium Silver line (e.g. Gemini Lake, common in consumer NAS devices) -- hits an illegal-instruction fault the moment the ReadyToRun binary or a JIT-emitted code path executes an AVX instruction, since the CPU physically cannot decode it. I ran into this building for a Celeron J4125-based Synology NAS, where the container would have crashed on startup with SIGILL.

Change

Adds ENABLE_AVX as a build arg (default 1, so behavior is unchanged for anyone not overriding it) that drives both the compile-time UseAVX MSBuild property and the runtime DOTNET_EnableAVX env var together. Builders on non-AVX hardware can now do:

docker build --build-arg ENABLE_AVX=0 .

without touching the Dockerfile. Other SSE variants, AES, POPCNT, and PCLMUL are left untouched since those are supported on essentially all relevant x86_64 hardware (Gemini Lake included) and provide real benefit.

Test plan

  • Built with ENABLE_AVX=0 on a Celeron J4125 (no AVX/AVX2 per /proc/cpuinfo) -- container starts and runs correctly
  • Confirmed default (ENABLE_AVX=1, i.e. omitted) reproduces the exact flags the Dockerfile already had, so this is a no-op for existing AVX-capable deployments

UseAVX=true (compile-time, baked into the ReadyToRun binary) and
DOTNET_EnableAVX=1 (runtime JIT) were both hardcoded with no way to
override without editing the Dockerfile directly. Any CPU without AVX
support -- including budget/low-power chips like Intel's Atom-derived
Celeron/Pentium Silver line (e.g. Gemini Lake, common in consumer NAS
devices) -- will hit an illegal-instruction fault the moment the
ReadyToRun binary or a JIT-emitted code path executes an AVX
instruction, since the CPU physically cannot decode it.

Add ENABLE_AVX as a build arg (default 1, matching current behavior)
that controls both the compile-time UseAVX flag and the runtime
DOTNET_EnableAVX env var together, so builders on non-AVX hardware can
opt out with `--build-arg ENABLE_AVX=0` without touching the Dockerfile.
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.

1 participant