Skip to content

Support hermetic developer directories in the crosstool#616

Closed
AttilaTheFun wants to merge 1 commit into
bazelbuild:mainfrom
AttilaTheFun:hermetic-developer-dirs
Closed

Support hermetic developer directories in the crosstool#616
AttilaTheFun wants to merge 1 commit into
bazelbuild:mainfrom
AttilaTheFun:hermetic-developer-dirs

Conversation

@AttilaTheFun

@AttilaTheFun AttilaTheFun commented Jul 4, 2026

Copy link
Copy Markdown
Contributor

Two small changes needed by hermetic_apple_toolchains, which registers verbatim Xcode.app copies inside external repositories and drives the build with a path-valued --xcode_version (an absolute developer directory path, which Bazel uses directly as DEVELOPER_DIR).

  • configure_osx_toolchain gains an extra_include_dirs parameter so a wrapping repository rule can allow builtin includes from the external repository root, where the vendored Xcodes live. (Without this, headers resolved from the hermetic SDKs are flagged as undeclared inclusions, since they are outside the default /Applications and /Library include roots.)
  • cc_toolchain_config.bzl treats a path-valued Xcode version as the latest Xcode in its two inline >= feature checks (no_warn_duplicate_libraries, reproducible_linker_flag) instead of failing with an unparseable dotted version.

The path-as-version semantics in the second bullet are not new — this extends an existing, Apple-contributed convention to the last place that still hard-fails on it:

The new helper in cc_toolchain_config.bzl mirrors those implementations; the two inline comparisons were added later (for the Xcode 15 and Xcode 26 linker flags) and never picked up the convention. Without this, analysis fails with a Starlark error when comparing the path against apple_common.dotted_version("15.0").

- Allow callers of configure_osx_toolchain to pass extra builtin include
  directories, so toolchains and SDKs vendored into external repositories
  (hermetic developer directories) are not flagged as undeclared
  inclusions.
- Treat a path-valued Xcode version (an absolute developer directory
  path, as already supported by xcode_support.is_xcode_at_least_version
  and by Bazel's DEVELOPER_DIR handling) as the latest Xcode in the
  cc_toolchain_config feature checks instead of failing to compare it
  against a dotted version.
AttilaTheFun added a commit to AttilaTheFun/hermetic_apple_toolchains that referenced this pull request Jul 4, 2026
The macos-26 arm64 runner image ships Xcode 26.5 preinstalled; CI
registers it as a hermetic Xcode by path (rewriting the marked
machine-local block in MODULE.bazel), builds the example, checks the
app's DTXcodeBuild stamp against the registered Xcode, and runs it in
the runner's iOS 26.5 simulator, asserting on the app's log output.

Switch the apple_support override from local_path_override to a
git_override of the fork commit backing bazelbuild/apple_support#616 so
checkouts (and CI) build without a sibling apple_support checkout;
local development uses --override_module in the gitignored .bazelrc.user.

Claude-Session: https://claude.ai/code/session_01JRwE8au75o3HEuL2CdzUXW
repository_ctx.file(dest, content = repository_ctx.read(src))

def configure_osx_toolchain(repository_ctx):
def configure_osx_toolchain(repository_ctx, extra_include_dirs = []):

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.

this api isn't meant to be called externally and is being replaced by the rules based toolchain. can you use that one instead?

also i believe the value you're passing to this in your current rules is wrong and will ignore everything in external, which will break all header discovery bazelbuild/bazel#29613

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

oh let me see if this is even necessary with the rules based implementation. if not I can just drop it or else fix it another way

@AttilaTheFun

Copy link
Copy Markdown
Contributor Author

Closing in favor of the rules-based toolchain per the review — migrating to it removed the need for both changes here. The one remaining gap (include validation for vendored developer dirs) is addressed additively in the follow-up PR.

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