Skip to content

Commit 67655e8

Browse files
committed
fix: avoid dyld env injection on macos
1 parent 8b57104 commit 67655e8

2 files changed

Lines changed: 5 additions & 2 deletions

File tree

.agents/docs/2026-05-26-build-error-output-optimization-plan.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ std::string prepend_path_list(std::string_view key,
188188
| 平台 | 变量 | 说明 |
189189
|------|------|------|
190190
| Linux | `LD_LIBRARY_PATH` | 当前实际需要,替代 `toolenv` |
191-
| macOS | `DYLD_LIBRARY_PATH` | 仅给 mcpp 启动的 ninja/clang 子进程使用;如后续不需要可返回空 |
191+
| macOS | 空 | 不设置 `DYLD_LIBRARY_PATH`;它会影响 ninja 自身和系统 framework 的 dyld 解析,依赖 toolchain/rpath |
192192
| Windows | `PATH` | 如果私有工具链 DLL 需要搜索路径,按 `;` prepend;当前可先空实现 |
193193
194194
`NinjaBackend::build()` 中:

src/platform/env.cppm

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,10 @@ std::string runtime_library_path_key() {
112112
#if defined(_WIN32)
113113
return "PATH";
114114
#elif defined(__APPLE__)
115-
return "DYLD_LIBRARY_PATH";
115+
// DYLD_LIBRARY_PATH affects every executable launched by ninja, including
116+
// ninja itself, and can make macOS system frameworks load an incompatible
117+
// private libc++/libc++abi. Keep macOS on toolchain-provided rpaths.
118+
return "";
116119
#elif defined(__linux__)
117120
return "LD_LIBRARY_PATH";
118121
#else

0 commit comments

Comments
 (0)