Skip to content

[ggml][llama-cpp] Add portable-cpu feature to avoid SIGILL from binary (Fixes #53372) - #53482

Open
Reeshabh Choudhary (reeshabh90) wants to merge 3 commits into
microsoft:masterfrom
reeshabh90:master
Open

[ggml][llama-cpp] Add portable-cpu feature to avoid SIGILL from binary (Fixes #53372)#53482
Reeshabh Choudhary (reeshabh90) wants to merge 3 commits into
microsoft:masterfrom
reeshabh90:master

Conversation

@reeshabh90

Copy link
Copy Markdown

caching

ggml defaults to GGML_NATIVE=ON, enabling CPU-specific instruction sets for the host that performs the build. vcpkg's binary cache key does not encode the physical CPU used to produce a cached binary, so a binary built on one host can be served from cache and executed on a different host lacking the required instruction set, causing SIGILL.

Add a 'portable-cpu' feature to ggml that disables native CPU detection and architecture-specific instruction sets to produce portable CPU binaries. llama-cpp gets a matching 'portable-cpu' feature that forwards to ggml's feature when using the system ggml library.

Fixes #53372

@BillyONeal Billy O'Neal (BillyONeal) left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In general we discourage features to select CPU support like this because it's unreasonable for users to figure out which cocktail of features to use. Given how binary caching works, we probably need to do what your portable-cpu feature does all of the time.

@BillyONeal

Copy link
Copy Markdown
Member

Additionally GPT 5.6 Sol reports:

portable-cpu does not disable GGML_FMA or GGML_F16C. With GGML_NATIVE=OFF, upstream defaults both options to enabled, and non-MSVC x86 builds consequently retain -mfma and -mf16c. The resulting binary-cache artifacts can still execute unsupported instructions and raise SIGILL on older consumers, contrary to the feature's portability contract. The relevant upstream defaults are defined here.

@BillyONeal
Billy O'Neal (BillyONeal) marked this pull request as draft August 19, 2026 19:17
@BillyONeal

Copy link
Copy Markdown
Member

Sorry, rereading what I wrote sounds a bit harsh. My point is, this is a good change, thank you! It just needs to be done all the time rather than being a feature.

caching

ggml defaults to GGML_NATIVE=ON, enabling CPU-specific instruction sets
for the host that performs the build. vcpkg's binary cache key does not
encode the physical CPU used to produce a cached binary, so a binary
built on one host can be served from cache and executed on a different
host lacking the required instruction set, causing SIGILL.

Add a 'portable-cpu' feature to ggml that disables native CPU detection
and architecture-specific instruction sets to produce portable CPU
binaries. llama-cpp gets a matching 'portable-cpu' feature that forwards
to ggml's feature when using the system ggml library.

Fixes microsoft#53372
and made the CPU-portability flags unconditional. Also added
GGML_FMA=OFF and GGML_F16C=OFF per your note, since those aren't gated
by GGML_NATIVE upstream.
@reeshabh90
Reeshabh Choudhary (reeshabh90) marked this pull request as ready for review August 20, 2026 07:56
@reeshabh90

Copy link
Copy Markdown
Author

@microsoft-github-policy-service agree

@reeshabh90

Copy link
Copy Markdown
Author

Sorry, rereading what I wrote sounds a bit harsh. My point is, this is a good change, thank you! It just needs to be done all the time rather than being a feature.

No problem. I have made suggested changes. Kindly take a look.

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.

[ggml] Expose GGML_NATIVE / CPU ISA options as vcpkg features to avoid SIGILL from binary caching

2 participants