Skip to content

Commit 81ddd89

Browse files
committed
Fallback to glob filegroups when missing v2 merkle cache
1 parent ebe602b commit 81ddd89

File tree

4 files changed

+25
-4
lines changed

4 files changed

+25
-4
lines changed

MODULE.bazel

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ module(
1919
compatibility_level = 0,
2020
)
2121

22-
bazel_dep(name = "bazel_features", version = "1.36.0")
22+
bazel_dep(name = "bazel_features", version = "1.38.0")
2323
bazel_dep(name = "bazel_skylib", version = "1.5.0")
2424
bazel_dep(name = "aspect_bazel_lib", version = "2.0.0")
2525
bazel_dep(name = "rules_cc", version = "0.2.2")

toolchain/BUILD.llvm_repo.tpl

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,18 @@ filegroup(
9494
]),
9595
)
9696

97+
filegroup(
98+
name = "lib_legacy",
99+
srcs = glob([
100+
# Include the .dylib files in the linker sandbox even though they will
101+
# not be available at runtime to allow sanitizers to work locally.
102+
# Any library linked from the toolchain to be released should be linked statically.
103+
"lib/clang/{LLVM_VERSION}/lib/**",
104+
"lib/**/libc++*.a",
105+
"lib/**/libunwind.a",
106+
]),
107+
)
108+
97109
filegroup(
98110
name = "ar",
99111
srcs = ["bin/llvm-ar"],

toolchain/BUILD.toolchain.tpl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,12 @@ filegroup(
2929
visibility = ["//visibility:private"],
3030
)
3131

32+
filegroup(
33+
name = "internal-use-tools-legacy",
34+
srcs = glob(["%{tools_dir}/**"]),
35+
visibility = ["//visibility:private"],
36+
)
37+
3238
%{cc_toolchains}
3339

3440
# Convenience targets from the LLVM toolchain.

toolchain/internal/configure.bzl

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15+
load("@bazel_features//:features.bzl", "bazel_features")
1516
load("@bazel_skylib//lib:paths.bzl", "paths")
1617
load(
1718
"//toolchain:aliases.bzl",
@@ -329,7 +330,7 @@ def _cc_toolchain_str(
329330
# TODO: Are there other situations where we can continue?
330331
return ""
331332

332-
extra_files_str = repr(":internal-use-tools")
333+
extra_files_str = repr(":internal-use-tools" if bazel_features.rules.merkle_cache_v2 else ":internal-use-tools-legacy")
333334

334335
# C++ built-in include directories.
335336
# This contains both the includes shipped with the compiler as well as the sysroot (or host)
@@ -506,7 +507,7 @@ filegroup(name = "strip-files-{suffix}", srcs = [{extra_files_str}])
506507
template = template + """
507508
filegroup(
508509
name = "cxx_builtin_include_files-{suffix}",
509-
srcs = ["{llvm_dist_label_prefix}cxx_builtin_include"],
510+
srcs = ["{llvm_dist_label_prefix}{cxx_builtin_include_label}"],
510511
)
511512
512513
filegroup(
@@ -526,7 +527,7 @@ filegroup(
526527
"{llvm_dist_label_prefix}clang",
527528
"{llvm_dist_label_prefix}ld",
528529
"{llvm_dist_label_prefix}ar",
529-
"{llvm_dist_label_prefix}lib",
530+
"{llvm_dist_label_prefix}{lib_label}",
530531
":sysroot-components-{suffix}",
531532
],
532533
)
@@ -629,6 +630,8 @@ cc_toolchain(
629630
extra_unfiltered_compile_flags = _list_to_string(_dict_value(toolchain_info.extra_unfiltered_compile_flags_dict, target_pair)),
630631
extra_files_str = extra_files_str,
631632
cxx_builtin_include_directories = _list_to_string(filtered_cxx_builtin_include_directories),
633+
cxx_builtin_include_label = "cxx_builtin_include" if bazel_features.rules.merkle_cache_v2 else "include",
634+
lib_label = "lib" if bazel_features.rules.merkle_cache_v2 else "lib_legacy",
632635
extra_compiler_files = ("\"%s\"," % str(toolchain_info.extra_compiler_files)) if toolchain_info.extra_compiler_files else "",
633636
major_llvm_version = major_llvm_version,
634637
extra_exec_compatible_with_specific = toolchain_info.extra_exec_compatible_with.get(target_pair, []),

0 commit comments

Comments
 (0)