Skip to content

Let consumers extend the rules-based toolchain's include allowlist#617

Merged
keith merged 1 commit into
bazelbuild:mainfrom
AttilaTheFun:extra-include-directories
Jul 6, 2026
Merged

Let consumers extend the rules-based toolchain's include allowlist#617
keith merged 1 commit into
bazelbuild:mainfrom
AttilaTheFun:extra-include-directories

Conversation

@AttilaTheFun

Copy link
Copy Markdown
Contributor

Follow-up to the review feedback on #616 — migrating to the rules-based toolchain worked (thanks for the pointer, it removed almost everything we needed from that PR), with one remaining gap: include validation for SDK/toolchain headers that live outside the standard install locations.

This adds an extra_include_directories label_flag (default: an empty cc_args) appended to the toolchain's args. Consumers whose developer directories live elsewhere — for example verbatim Xcode.app copies vendored into external repositories (hermetic_apple_toolchains) — point the flag at a cc_args with allowlist_absolute_include_directories entries for those locations:

build --@apple_support//toolchain:extra_include_directories=//your:cc_args

Being analysis-time and additive, this lets the allowlist stay as narrow as the specific developer directories (avoiding the overly broad builtin include entries from the previous approach, which per bazelbuild/bazel#29613 can silently break dependency tracking for anything under the output base).

Verified with hermetic Xcode 26.5 and 27 beta copies in external repositories: builds, simulator runs, and rules_xcodeproj-generated projects all pass with the flag supplying the vendored developer dirs; without it, compiles of anything touching the SDK fail include validation.

Adds an extra_include_directories label_flag (default: an empty cc_args)
appended to the toolchain's args. Consumers whose SDKs and toolchains
live outside the standard install locations — for example hermetic
Xcode.app copies vendored into external repositories — can point the
flag at a cc_args with allowlist_absolute_include_directories entries
for those locations:

    --@apple_support//toolchain:extra_include_directories=//your:cc_args

This replaces the approach from bazelbuild#616 (which patched the legacy
autoconf's extra include dirs): the flag is analysis-time, additive, and
lets the allowlist be as narrow as the specific developer directories,
avoiding overly broad builtin include entries that can break dependency
tracking (bazelbuild/bazel#29613).
AttilaTheFun added a commit to AttilaTheFun/hermetic_apple_toolchains that referenced this pull request Jul 6, 2026
The extra_include_directories label_flag is now pending upstream as
bazelbuild/apple_support#617; pin the fork commit carrying it (upstream
main + that one change) instead of applying a local patch.
AttilaTheFun added a commit to AttilaTheFun/hermetic_apple_toolchains that referenced this pull request Jul 6, 2026
* Migrate to apple_support's rules-based CC toolchain

Replaces the forked legacy-crosstool changes (bazelbuild/apple_support
PR 616) per review feedback. The rules-based toolchain (enabled with
APPLE_SUPPORT_RULES_BASED_TOOLCHAIN=1) is driven by the xcode_config at
analysis time — a path-valued Xcode version flows straight into
DEVELOPER_DIR — and does no fetch-time compiler probing, so the
hermetic_apple_cc override repo is gone entirely. Its two version-gated
linker features are unconditional, so the path-valued version-check
change is moot.

apple_support is now stock upstream main (git_override, pinned) plus a
~15-line patch adding an extra_include_directories label_flag to the
toolchain, which the hub's new :xcode_include_directories cc_args plugs
into to allowlist the vendored developer directories for include
validation. The allowlist is deliberately narrow: covering the external
root (as the old fork did) silently breaks .d-file change detection for
every external repository's headers (bazel#29613).

Verified: example builds and simulator runs on both Xcodes (stamps
17F42/23F73 and 27A5209h/24A5370g), rules_xcodeproj generation, and a
headless xcodebuild of the generated project.

* Point the apple_support override at the upstream PR branch

The extra_include_directories label_flag is now pending upstream as
bazelbuild/apple_support#617; pin the fork commit carrying it (upstream
main + that one change) instead of applying a local patch.

@keith keith left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

technically users could pass any cc_args here which might not be ideal, but at least the naming is specific enough that if we break that somehow they shouldn't be surprised. I think an extra flag for this feels a bit bad but if we combined it with any other flag you might have conflicting use cases since the flags can only take 1 label at a time.

@keith keith merged commit 1a9b8c2 into bazelbuild:main Jul 6, 2026
25 checks passed
@AttilaTheFun AttilaTheFun deleted the extra-include-directories branch July 6, 2026 21:41
AttilaTheFun added a commit to AttilaTheFun/hermetic_apple_toolchains that referenced this pull request Jul 6, 2026
The extra_include_directories flag merged upstream
(bazelbuild/apple_support#617); pin bazelbuild/apple_support directly.
The git_override remains only until the toolchain ships in a tagged
release, after which a plain bazel_dep suffices.
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