← All tasks
cppikawrakow/ik_llama.cpp #2135Not a task: already works

GGML_NATIVE appends -march=native after user GGML_ARCH_FLAGS, breaking fullfp16 (iqk) builds on Apple Silicon

envgap__ikawrakow__ik_llama.cpp-2135

01 / FAILURE SIGNATURE

As reported upstream

error: '...' requires target feature 'fullfp16'
Not a benchmark task.
  • The project already builds and runs before the fix, so there is nothing to repair.

02 / ENVIRONMENT RECIPE

Base commit
5596a41a38b1963a2f1b9355439fe420ab34192b
Manifest
ggml/src/CMakeLists.txt
Reproduce
Awaiting issue-specific recipe
Run under trace
Awaiting a meaningful runtime command

03 / ORIGINAL ISSUE TEXT

ikawrakow/ik_llama.cpp #2135 · read the original issue
## Summary

With the default `GGML_NATIVE=ON`, user-supplied `GGML_ARCH_FLAGS` are silently overridden, and on Apple Silicon (M2, Xcode clang 21) the resulting build fails compiling the `iqk` sources with:

```
error: '...' requires target feature 'fullfp16'
```

Found while building `main` for the #2133 / #2134 verification.

## Root cause

In `ggml/src/CMakeLists.txt` the flag order guarantees `-march=native` wins over anything the user passes:

```cmake
set(ARCH_FLAGS ${GGML_ARCH_FLAGS})        # line ~1042 — user flags first
...
if (GGML_NATIVE)
    list(APPEND ARCH_FLAGS -march=native) # line ~1104 — appended after, so it overrides
endif()
```

So `-DGGML_ARCH_FLAGS=-mcpu=apple-m2` produces a compile line ending `-mcpu=apple-m2 ... -march=native`, the later flag takes precedence, and on this toolchain whatever `-march=native` resolves to does not enable the `fullfp16` feature the iqk fp16 intrinsics require.

## Workaround

```
cmake -B build -DGGML_METAL=ON -DGGML_NATIVE=OFF -DGGML_ARCH_FLAGS=-mcpu=apple-m2
```

builds and runs correctly (this is how the #2133 M2 numbers were produced).

## Suggested fix (maintainer's call)

Any of these would resolve it:

1. Skip appending `-march=native` when the user has set `GGML_ARCH_FLAGS` (explicit user intent should win over auto-detection);
2. Append `GGML_ARCH_FLAGS` *after* the native flag instead of before, so user flags always take precedence;
3. On AArch64, use `-mcpu=native` rather than `-march=native` (the preferred spelling on this target, and it carries the fp16 feature bits on Apple cores).

Happy to send a PR for whichever direction you prefer.

## Environment

- Apple M2, macOS, Xcode clang 21
- ik_llama.cpp `main` @ 6d78a87c
- `cmake -B build -DGGML_METAL=ON` (defaults otherwise)
Continue on GitHub ↗

04 / LABELS

Labels from the report text only; not yet run

No supported category has been assigned.

Label rules and the text that matched
[]