Skip to content

fix(b10154): compile server-mcp.cpp + guard subprocess addchdir_np on old glibc - #365

Merged
bernardladenthin merged 1 commit into
mainfrom
claude/fix-b10154-subprocess-addchdir-np
Jul 27, 2026
Merged

fix(b10154): compile server-mcp.cpp + guard subprocess addchdir_np on old glibc#365
bernardladenthin merged 1 commit into
mainfrom
claude/fix-b10154-subprocess-addchdir-np

Conversation

@bernardladenthin

Copy link
Copy Markdown
Owner

Summary

The b10154 upgrade (#364) broke the Publish pipeline on 6 native jobs. All 6 trace to two independent root causes from upstream's new MCP-server support, plus one non-fatal warning:

  • Undefined server_mcp symbols (macOS 15 arm64 + all 4 Windows jobs; latent on Linux). b10154 added tools/server/server-mcp.cpp, and server.cpp (llama_server's mcp_mgr lifecycle) + server-tools.cpp (tools.setup(..., mcp_mgr) / server_mcp::call_tool) — both already compiled into jllama — now reference server_mcp, but the file was missing from the CMake target_sources. A Linux .so tolerates undefined symbols (why the local build and Linux CI "passed"); macOS/ld64 and Windows/MSVC hard-error. Fix: add server-mcp.cpp to the non-Android jllama block (it shares the subprocess.h/posix_spawn_* Android guard). Not added to jllama_test (which links neither server.cpp nor server-tools.cpp).
  • posix_spawn_file_actions_addchdir_np undeclared on manylinux2014 (glibc 2.17). b10154's vendored subprocess.h calls it (glibc ≥ 2.29 / bionic API ≥ 34 / macOS ≥ 10.15) but guards it only for macOS. Fix: patch 0009 adds a SUBPROCESS_HAVE_ADDCHDIR_NP probe (__GLIBC_PREREQ, nested under defined(__GLIBC__)) that falls back to ENOSYS on old glibc — this build never spawns with a cwd. Android already compiles it (the __ANDROID_UNAVAILABLE_SYMBOLS_ARE_WEAK__ macro).
  • C4566 (non-fatal warning): upstream server-tools.cpp embeds a U+2192 () in a narrow literal; MSVC/clang-cl warn and mangle it under code page 1252. Fix: /utf-8 scoped to jllama (gated on MSVC) — Microsoft's documented C4566 fix. No upstream source touched.

Test plan

  • All 9 patches apply clean against b10154; cmake configure (fail-loud patch applier + OuteTTS generator) passes
  • Full jllama build links; nm confirms server_mcp::{start,shutdown,call_tool,list_tools} are now defined (T) (were undefined on macOS/Windows)
  • CI is green on this branch (the 6 previously-failing native jobs — validated by CI, which has the macOS/Windows/manylinux toolchains the local sandbox lacks)
  • Docs updated (CLAUDE.md: new 0009 patch row + the compiled-server-sources note now documents server-mcp.cpp and the latent-on-Linux / hard-error-on-mac-win link trap)

Related issues / PRs

Follow-up to #364 (b10154 upgrade).

Checklist

  • My commits follow Conventional Commits
  • No security-sensitive changes

Generated by Claude Code

… old glibc

The b10154 upgrade (PR #364) broke the Publish pipeline on 6 native jobs.
Two independent root causes, both from upstream's new MCP-server support:

1. Undefined server_mcp symbols (macOS + all Windows jobs; latent on Linux).
   b10154 added tools/server/server-mcp.cpp, and server.cpp (llama_server's
   mcp_mgr lifecycle) + server-tools.cpp (tools.setup(..., mcp_mgr) /
   server_mcp::call_tool) — both already compiled into jllama — now reference
   server_mcp. server-mcp.cpp was missing from the CMake target_sources, so the
   link failed with undefined server_mcp::{start,shutdown,call_tool,list_tools,
   ~server_mcp}. A Linux .so tolerates undefined symbols (why the local build
   and Linux CI 'passed'); macOS/ld64 and Windows/MSVC hard-error. Add
   server-mcp.cpp to the non-Android jllama block (shares the subprocess.h
   posix_spawn Android guard). Not added to jllama_test (links neither
   server.cpp nor server-tools.cpp). Verified: nm now shows server_mcp::* as
   defined (T), and jllama links.

2. posix_spawn_file_actions_addchdir_np undeclared on manylinux2014 (glibc 2.17).
   b10154's vendored subprocess.h calls addchdir_np (glibc >= 2.29 / bionic API
   >= 34 / macOS >= 10.15) but guards it only for macOS. Add patch 0009 with a
   SUBPROCESS_HAVE_ADDCHDIR_NP probe (__GLIBC_PREREQ, nested under
   defined(__GLIBC__)) that falls back to ENOSYS on old glibc — this build never
   spawns with a cwd. Android already compiles it (weak-symbol macro).

Also: /utf-8 for MSVC (C4566). server-tools.cpp embeds a U+2192 arrow in a
narrow literal; MSVC/clang-cl warn C4566 and mangle it under code page 1252.
Scope /utf-8 to jllama (gated on MSVC) — the documented C4566 fix.

Verified locally: all 9 patches apply clean against b10154; cmake configure
(fail-loud patch applier + TTS generator) passes; full jllama build links.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MeheJtyQwUzJGLcYpyWURD
@bernardladenthin
bernardladenthin merged commit 8470230 into main Jul 27, 2026
10 of 16 checks passed
@bernardladenthin
bernardladenthin deleted the claude/fix-b10154-subprocess-addchdir-np branch July 27, 2026 20:23
@sonarqubecloud

Copy link
Copy Markdown

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.

2 participants