Skip to content

Commit 8d047dd

Browse files
committed
fix(build): restore C++ include order broken by clang-format include sort
The clang-format enforcement commit ran with SortIncludes: CaseSensitive, which alphabetically reordered includes and moved jni_helpers.hpp / json_helpers.hpp ahead of the server-*.h headers that define the `json` alias they depend on. CI then failed to build jllama with "'json' does not name a type" cascading through json_helpers.hpp / jni_helpers.hpp / jllama.cpp on the manylinux, Linux aarch64, Android and C++-test compilers. (A local build masks it — the local toolchain resolves `json` regardless of include order.) Set SortIncludes: Never in .clang-format (the project has order-sensitive includes, documented in CLAUDE.md) and restore the required order — server-*.h + utils.hpp before the helper headers — in jllama.cpp and the affected C++ test files. Document the constraint in CLAUDE.md. clang-format --dry-run --Werror stays clean; the affected targets rebuild and the C++ tests pass. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_014L2dLbAtwdq7C6a2gFRsQQ
1 parent 93bd732 commit 8d047dd

6 files changed

Lines changed: 23 additions & 13 deletions

File tree

.clang-format

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,10 @@ RequiresClausePosition: OwnLine
175175
RequiresExpressionIndentation: OuterScope
176176
SeparateDefinitionBlocks: Leave
177177
ShortNamespaceLines: 1
178-
SortIncludes: CaseSensitive
178+
# Never reorder #include lines: this project has order-sensitive includes — the upstream
179+
# server-*.h headers must precede json_helpers.hpp / jni_helpers.hpp (which use the `json`
180+
# alias those headers define). Alphabetical sorting breaks the build (json undefined).
181+
SortIncludes: Never
179182
SortJavaStaticImport: Before
180183
SortUsingDeclarations: LexicographicNumeric
181184
SpaceAfterCStyleCast: false

CLAUDE.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -407,6 +407,13 @@ The generated JNI header `src/main/cpp/jllama.h` (produced by `javac -h`) is int
407407
To bump the enforced version, update the pin in **both** the workflow (`CLANG_FORMAT_VERSION`) and
408408
this line, then reformat the whole tree with the new version in the same commit.
409409

410+
**`.clang-format` sets `SortIncludes: Never` — do not re-enable include sorting.** The project has
411+
order-sensitive includes (see the "Include order rule" above): the upstream `server-*.h` headers and
412+
`utils.hpp` must precede `json_helpers.hpp` / `jni_helpers.hpp`, which use the `json` alias those
413+
headers define. Alphabetical sorting moves the helper headers first and breaks the build with
414+
`'json' does not name a type` (it slips past a local build whose toolchain resolves `json` anyway,
415+
but fails the manylinux/aarch64/Android CI compilers). Keep include order manual.
416+
410417
### Javadoc — must build cleanly before `mvn package`
411418

412419
The release packaging job runs `mvn package` with the `release` profile, which attaches

src/main/cpp/jllama.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,18 @@
77

88
#include "arg.h"
99
#include "build-info.h"
10-
#include "jni_helpers.hpp"
1110
#include "json-schema-to-grammar.h"
1211
#include "llama.h"
1312
#include "log.h"
14-
#include "log_helpers.hpp"
1513
#include "nlohmann/json.hpp"
16-
#include "server-chat.h"
17-
#include "server-common.h"
1814
#include "server-context.h"
1915
#include "server-queue.h"
2016
#include "server-task.h"
17+
#include "server-common.h"
18+
#include "server-chat.h"
2119
#include "utils.hpp"
20+
#include "jni_helpers.hpp"
21+
#include "log_helpers.hpp"
2222

2323
#include <atomic>
2424
#include <chrono>

src/test/cpp/test_jni_helpers.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,13 @@
2222

2323
#include <gtest/gtest.h>
2424

25-
#include "jni_helpers.hpp"
26-
#include "server-chat.h"
27-
#include "server-common.h"
2825
#include "server-context.h"
2926
#include "server-queue.h"
3027
#include "server-task.h"
28+
#include "server-common.h"
29+
#include "server-chat.h"
3130
#include "utils.hpp"
31+
#include "jni_helpers.hpp"
3232
#include <cstring>
3333
#include <memory>
3434
#include <string>

src/test/cpp/test_json_helpers.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,13 @@
2828
#include <string>
2929
#include <vector>
3030

31-
#include "json_helpers.hpp"
32-
#include "server-chat.h"
33-
#include "server-common.h"
3431
#include "server-context.h"
3532
#include "server-queue.h"
3633
#include "server-task.h"
34+
#include "server-common.h"
35+
#include "server-chat.h"
3736
#include "utils.hpp"
37+
#include "json_helpers.hpp"
3838

3939
// ============================================================
4040
// Minimal fake result types

src/test/cpp/test_server.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,11 @@
2020

2121
#include <gtest/gtest.h>
2222

23-
#include "server-chat.h"
24-
#include "server-common.h"
2523
#include "server-context.h"
2624
#include "server-queue.h"
2725
#include "server-task.h"
26+
#include "server-common.h"
27+
#include "server-chat.h"
2828
#include "utils.hpp"
2929

3030
// ============================================================

0 commit comments

Comments
 (0)