Fix: clang-tidy on macOS resolve Apple SDK headers#724
Merged
ChaoWao merged 1 commit intohw-native-sys:mainfrom May 9, 2026
Merged
Fix: clang-tidy on macOS resolve Apple SDK headers#724ChaoWao merged 1 commit intohw-native-sys:mainfrom
ChaoWao merged 1 commit intohw-native-sys:mainfrom
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces a new macOS troubleshooting guide and updates documentation paths across the repository. It also implements a fix in the linting script to handle macOS-specific header resolution for clang-tidy by injecting sysroot flags. Feedback indicates that the documentation snippet for the new logic should be updated to match the actual, more robust implementation in the code.
Homebrew LLVM ships clang-tidy on macOS (Apple Command Line Tools does not), but its driver bakes in a default sysroot path that often does not match the installed SDK on a fresh checkout — typical symptom is ``'algorithm' file not found`` because the libc include cascade (`<algorithm>` → `<wchar.h>` via libc++ `#include_next`) cannot resolve. Apple Clang escapes this by resolving the SDK at runtime via xcrun. `tests/lint/clang_tidy.py` now injects two `--extra-arg` flags on macOS so the hook works regardless of whether phase 1 was built with Apple Clang or Homebrew Clang: -isysroot $SDK # libc cascade resolves -isystem $SDK/usr/include/c++/v1 # lint sees same libc++ as build Apple SDK is located via `xcrun --show-sdk-path`, returning the version-stable symlink (`MacOSX.sdk`) so the patch survives SDK upgrades. Also organize macOS troubleshooting docs: - New ``docs/troubleshooting/macos-build.md`` — three-phase toolchain matrix (simpler install / test orch / sim kernel), Apple-vs-Homebrew Clang asymmetry, the `<algorithm>` cascade explanation, and the optional Homebrew-Clang phase 1 setup (with LDFLAGS pointing at Homebrew libc++ runtime, source-installs of nanobind/pybind11). - Move ``docs/macos-libomp-collision.md`` into ``docs/troubleshooting/`` and update all internal cross-references (conftest.py, ci.md, python-packaging.md, examples/workers/l3/*/main.py).
75f679f to
e78514f
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
doesn't match the installed SDK, causing
'algorithm' file not founderrors on fresh checkouts (the underlying issue is the libc include
cascade triggered by libc++ internals, not
<algorithm>itself).tests/lint/clang_tidy.pynow injects-isysroot $SDKand-isystem $SDK/usr/include/c++/v1on macOS via--extra-arg=.No-op on Linux. Works whether phase 1 was built with Apple Clang
or Homebrew Clang.
docs/troubleshooting/macos-build.mddocuments the three-phasebuild toolchain matrix, the Apple-vs-Homebrew Clang asymmetry
(xcrun runtime resolution vs baked default), the
<algorithm>cascadefailure mode, and an optional fully-Homebrew phase 1 setup
(LDFLAGS pointing at Homebrew libc++ runtime, source-installs of
nanobind/pybind11).
docs/macos-libomp-collision.md→docs/troubleshooting/macos-libomp-collision.mdso macOS-specifictroubleshooting docs live in one place; update all in-repo cross
references (
conftest.py,docs/ci.md,docs/python-packaging.md,examples/workers/l3/*/main.py).Why two flags
-isysroot $SDK<algorithm>→<wchar.h>via libc++#include_next) resolve. Without this clang-tidy cannot lint any C++ file.-isystem $SDK/usr/include/c++/v1xcrun --show-sdk-pathreturns the version-stable symlink(
MacOSX.sdk), so the patch survives SDK upgrades without code change.Testing
pre-commit run --all-files(clang-tidy and markdownlint pass)mixed_exampleandspmd_starvationsim ST testsstill pass
Notes
This PR is intentionally narrow: only the lint + docs changes. A
follow-up PR refactors the dep computation in
submit_task(
compute_task_fanin/register_task_outputs); discovering theclang-tidy issue was a side effect of trying to land that refactor
through pre-commit on macOS.