From 014c7346d6bfa6097250c5b61cee91a99cab2d9c Mon Sep 17 00:00:00 2001 From: Lucile Rose Nihlen Date: Mon, 8 Jun 2026 14:56:07 -0400 Subject: [PATCH] Canonicalize the path to clang resource directory (#7321) When building Carbon on Fedora, clang reports the resource directory as `/usr/bin/../lib/clang/22`. This fails to string match against `/usr/lib/clang/22` and so bazel reports an error. This PR canonicalizes the path returned by clang so that it will string match successfully. --- MODULE.bazel.lock | 2 +- bazel/cc_toolchains/clang_configuration.bzl | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/MODULE.bazel.lock b/MODULE.bazel.lock index fa5b066d59ab..59cae1cad7ca 100644 --- a/MODULE.bazel.lock +++ b/MODULE.bazel.lock @@ -307,7 +307,7 @@ "moduleExtensions": { "//bazel/cc_toolchains:clang_configuration.bzl%clang_toolchain_extension": { "general": { - "bzlTransitiveDigest": "H3RsK0MbgutDMSlPWTwZq4Vk1U5sjDtgJ5MXQxg7GLU=", + "bzlTransitiveDigest": "zlzuUB95ZT/0gx6Xy5Ercb4YiRyDEn9PzsoEcN6q2gk=", "usagesDigest": "lTxkeAFhR0iBEa3dg5hWvtd2HFCr5zCJx/fl27A+IKA=", "recordedFileInputs": {}, "recordedDirentsInputs": {}, diff --git a/bazel/cc_toolchains/clang_configuration.bzl b/bazel/cc_toolchains/clang_configuration.bzl index 1c3d685d28b1..958899ddb607 100644 --- a/bazel/cc_toolchains/clang_configuration.bzl +++ b/bazel/cc_toolchains/clang_configuration.bzl @@ -83,7 +83,11 @@ def _compute_clang_resource_dir(repository_ctx, clang): ).stdout # The only line printed is this path. - return output.splitlines()[0] + dir_path = repository_ctx.path(output.splitlines()[0]) + + # Canonicalize the path to help ensure string matching succeeds + # even with clang installs returning a non-canonical path. + return str(dir_path.realpath) def _compute_mac_os_sysroot(repository_ctx): """Runs `xcrun` to extract the correct sysroot."""