Files
codex/patches/toolchains_llvm_bootstrapped_macos_toolchain.patch
Michael Mitchell 922ffb811e codex: fix darwin bazel toolchain integration
The Darwin Bazel build started failing after we pulled in coreaudio-sys through the voice-input dependency chain. `bazel build //codex-rs/cli:cli` would fail in two places:

- the patched macOS SDK headers in toolchains_llvm_bootstrapped no longer produced a module map that satisfied strict decluse and layering_check, so Clang could not find exported modules for headers like `<memory>` and `<utility>`
- `coreaudio-sys` build script could not find a hermetic clang, libclang, and SDK setup, so bindgen would either reach for `xcrun` or fail to load `libclang`

Fix this in our Bazel wiring instead of patching the Rust dependency:

- replace the old resource-dir patch with a macOS toolchain patch that models copied SDK headers correctly, adds generated header submodules, uses execroot-relative module-map paths with `-fmodule-map-file-home-is-cwd`, and wires the copied `usr/include` headers into both C and C++ compile actions
- point coreaudio-sys directly at `@llvm-project//clang:libclang.dylib` and `@toolchains_llvm_bootstrapped//tools:clang`, while keeping the hermetic builtin headers and SDK path in its build script environment
- remove the now-unnecessary local `//:clang` wrapper target
- refresh `MODULE.bazel.lock` for the updated module graph

With these changes, `bazel build //codex-rs/cli:cli` succeeds on Darwin without skipping package layering checks and without patching coreaudio-sys.

Co-authored-by: Codex <noreply@openai.com>
2026-03-03 17:18:30 -08:00

20 KiB