Commit c10a6ec
committed
build(server): compile upstream server-http.cpp + cpp-httplib into libjllama
First step toward driving the OpenAI-compatible server natively from JNI,
shipped inside libjllama rather than as a standalone llama-server executable
(a JNI .so/.dll/.dylib loads anywhere a JVM runs; a separate binary does not,
which is the whole point of preferring the JNI path here). This commit only
makes the HTTP layer build and link — no JNI route wiring yet.
What changed (CMakeLists.txt):
- Compile tools/server/server-http.cpp (the upstream server_http_context HTTP
transport) and vendor/cpp-httplib/httplib.cpp directly into jllama, on all
platforms (the getifaddrs API-24 gate cpp-httplib needs on Android is already
satisfied by the existing __ANDROID_UNAVAILABLE_SYMBOLS_ARE_WEAK__ define).
- <cpp-httplib/httplib.h> already resolves via llama-common's vendor/ include
dir, whose bundled nlohmann/json is the same 3.12.0 as our FetchContent copy,
so nothing is shadowed and no extra include dir is required for it.
- Mirror upstream's cpp-httplib tuning defines (payload/URI/backlog limits,
TCP_NODELAY) on jllama so httplib.cpp and the server-http.cpp that includes
httplib.h agree on the inline behaviour those macros control.
- Silence httplib.cpp warnings (-w / /w), matching upstream's own target.
- Link ws2_32 on MinGW (MSVC auto-links it via a pragma in httplib.h).
- No SSL: CPPHTTPLIB_OPENSSL_SUPPORT is left undefined (plain HTTP for now;
bind localhost or front with a TLS proxy).
WebUI stub (src/main/cpp/webui_stub/ui.h):
- server-http.cpp does #include "ui.h" — the asset table tools/ui (llama-ui)
normally GENERATES via the llama-ui-embed host tool. We do not ship the Svelte
WebUI (it needs npm or a prebuilt-asset download), so this header supplies the
exact "empty asset table" interface embed.cpp emits for n_assets == 0: the
llama_ui_asset struct plus llama_ui_find_asset / llama_ui_use_gzip /
llama_ui_get_assets. LLAMA_UI_HAS_ASSETS is intentionally left undefined, so
every static-asset-serving block in server-http.cpp compiles out; the single
unguarded use iterates the (empty) asset list. Header-only (.h) so it is
outside the clang-format glob, which only covers *.cpp/*.hpp.
server.cpp (standalone main() + route wiring) stays excluded — wiring those
routes to a JNI entry point is the next step.
Verified locally (Linux x86_64):
- cmake --build --target jllama -> [100%] Built target jllama (clean).
- libjllama.so contains server_http_context::init/start/stop (T) and ~1.8k
httplib symbols, with zero undefined server-http/httplib symbols.
- NativeLibraryLoadSmokeTest: Tests run: 1, Failures: 0, Skipped: 0 (the larger
lib still loads and JNI_OnLoad resolves every referenced Java class).
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JdLpWD8nedY7LwNnHefZLF1 parent ff614d2 commit c10a6ec
3 files changed
Lines changed: 100 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
483 | 483 | | |
484 | 484 | | |
485 | 485 | | |
486 | | - | |
| 486 | + | |
487 | 487 | | |
488 | 488 | | |
489 | 489 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
261 | 261 | | |
262 | 262 | | |
263 | 263 | | |
264 | | - | |
265 | 264 | | |
266 | 265 | | |
267 | 266 | | |
| |||
278 | 277 | | |
279 | 278 | | |
280 | 279 | | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
281 | 318 | | |
282 | 319 | | |
283 | 320 | | |
| 321 | + | |
| 322 | + | |
284 | 323 | | |
285 | 324 | | |
286 | 325 | | |
| |||
289 | 328 | | |
290 | 329 | | |
291 | 330 | | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
292 | 338 | | |
293 | 339 | | |
294 | 340 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
0 commit comments