From a7aba2d0317af14eccd7244ec72855ad21f35719 Mon Sep 17 00:00:00 2001 From: UebelAndre Date: Wed, 4 Dec 2024 14:09:00 -0800 Subject: [PATCH] Added bzlmod support to all extension rules. (#3037) Additional Changes: - The rules `rules_nodejs` for `rules_rust_wasm_bindgen` will no longer tested and will be dropped unless bzlmod support is added for the original `bazel_build_rules_nodejs` rules. - `rules_rust_bindgen` updated default clang version to 17.0.3 to match bzlmod available version. - `rules_rust_prost` updated protobuf version to `v28.3` Relates to: - https://github.com/bazelbuild/rules_rust/issues/2181 --- .bazelci/presubmit.yml | 4 + docs/BUILD.bazel | 7 - docs/src/rust_wasm_bindgen.md | 17 +- docs/src/rust_wasm_bindgen_rules_nodejs.md | 29 - extensions/bindgen/.bazelignore | 2 +- extensions/bindgen/.bazelrc | 5 +- extensions/bindgen/3rdparty/BUILD.zstd.bazel | 28 + extensions/bindgen/3rdparty/patches/README.md | 17 +- .../3rdparty/patches/llvm-project.cxx17.patch | 537 ------ ...ect.incompatible_disallow_empty_glob.patch | 1678 +++-------------- ...raw.incompatible_disallow_empty_glob.patch | 1025 ++++++++++ extensions/bindgen/BUILD.bazel | 19 +- extensions/bindgen/MODULE.bazel | 48 +- extensions/bindgen/extensions.bzl | 6 +- .../bindgen/private/internal_extensions.bzl | 26 + extensions/bindgen/private/llvm_utils.bzl | 103 + extensions/bindgen/repositories.bzl | 66 +- .../bindgen/transitive_repositories.bzl | 12 +- extensions/prost/.bazelignore | 2 +- extensions/prost/.bazelrc | 5 +- extensions/prost/MODULE.bazel | 32 +- extensions/prost/WORKSPACE.bazel | 5 + extensions/prost/extensions.bzl | 8 +- .../prost/private/internal_extensions.bzl | 26 + .../well_known_types/well_known_types_test.rs | 2 +- extensions/prost/repositories.bzl | 6 +- extensions/prost/transitive_repositories.bzl | 3 + extensions/protobuf/.bazelignore | 2 +- extensions/protobuf/.bazelrc | 5 +- .../protobuf/3rdparty/patches/README.md | 5 - ...ogle_protobuf-v3.10.0-bzl_visibility.patch | 14 - extensions/protobuf/MODULE.bazel | 31 +- extensions/protobuf/WORKSPACE.bazel | 5 + extensions/protobuf/extensions.bzl | 8 +- extensions/protobuf/private/BUILD.bazel | 0 .../protobuf/private/internal_extensions.bzl | 26 + extensions/protobuf/repositories.bzl | 13 +- .../protobuf/transitive_repositories.bzl | 3 + extensions/wasm_bindgen/.bazelignore | 6 +- extensions/wasm_bindgen/.bazelrc | 5 +- extensions/wasm_bindgen/MODULE.bazel | 37 +- extensions/wasm_bindgen/WORKSPACE.bazel | 14 - extensions/wasm_bindgen/defs.bzl | 17 +- extensions/wasm_bindgen/extensions.bzl | 8 +- .../private/internal_extensions.bzl | 26 + .../wasm_bindgen/rules_js/test/BUILD.bazel | 17 +- .../test/hello_world_wasm_test.js | 0 .../wasm_bindgen/rules_nodejs/BUILD.bazel | 3 +- .../rules_nodejs/test/BUILD.bazel | 68 - 49 files changed, 1804 insertions(+), 2227 deletions(-) delete mode 100644 docs/src/rust_wasm_bindgen_rules_nodejs.md create mode 100644 extensions/bindgen/3rdparty/BUILD.zstd.bazel delete mode 100644 extensions/bindgen/3rdparty/patches/llvm-project.cxx17.patch create mode 100644 extensions/bindgen/3rdparty/patches/llvm-raw.incompatible_disallow_empty_glob.patch create mode 100644 extensions/bindgen/private/internal_extensions.bzl create mode 100644 extensions/bindgen/private/llvm_utils.bzl create mode 100644 extensions/prost/private/internal_extensions.bzl delete mode 100644 extensions/protobuf/3rdparty/patches/com_google_protobuf-v3.10.0-bzl_visibility.patch create mode 100644 extensions/protobuf/private/BUILD.bazel create mode 100644 extensions/protobuf/private/internal_extensions.bzl create mode 100644 extensions/wasm_bindgen/private/internal_extensions.bzl rename extensions/wasm_bindgen/{ => rules_js}/test/hello_world_wasm_test.js (100%) delete mode 100644 extensions/wasm_bindgen/rules_nodejs/test/BUILD.bazel diff --git a/.bazelci/presubmit.yml b/.bazelci/presubmit.yml index b241e1af85..aecde57d75 100644 --- a/.bazelci/presubmit.yml +++ b/.bazelci/presubmit.yml @@ -972,7 +972,11 @@ tasks: build_targets: - "//..." test_targets: + - "--" - "//..." + # TODO: https://github.com/bazelbuild/rules_rust/issues/3039 + - "-//rules_js/test:hello_world_wasm_lib_test" + - "-//rules_js/test:hello_world_wasm_direct_test" extensions_wasm_bindgen_macos: platform: macos_arm64 name: Extensions wasm-bindgen diff --git a/docs/BUILD.bazel b/docs/BUILD.bazel index 896302f199..7eebe67ca5 100644 --- a/docs/BUILD.bazel +++ b/docs/BUILD.bazel @@ -220,13 +220,6 @@ stardoc( deps = ["@rules_rust_wasm_bindgen//rules_js:bzl_lib"], ) -stardoc( - name = "rust_wasm_bindgen_rules_nodejs", - out = "rust_wasm_bindgen_rules_nodejs.md", - input = "@rules_rust_wasm_bindgen//rules_nodejs:defs.bzl", - deps = ["@rules_rust_wasm_bindgen//rules_nodejs:bzl_lib"], -) - sh_binary( name = "update_docs", srcs = ["update_docs.sh"], diff --git a/docs/src/rust_wasm_bindgen.md b/docs/src/rust_wasm_bindgen.md index 7d33b7944f..0c0c29b265 100644 --- a/docs/src/rust_wasm_bindgen.md +++ b/docs/src/rust_wasm_bindgen.md @@ -4,6 +4,11 @@ Bazel rules for generating wasm modules for Javascript using [wasm-bindgen][wb]. +## Rules + +- [rust_wasm_bindgen](#rust_wasm_bindgen) +- [rust_wasm_bindgen_toolchain](#rust_wasm_bindgen_toolchain) + ## Setup To begin using the `wasm-bindgen` rules, users can load the necessary dependencies @@ -24,15 +29,15 @@ should avoid calling `rust_wasm_bindgen_register_toolchains` and instead use the [rust_wasm_bindgen_toolchain](#rust_wasm_bindgen_toolchain) rule to define their own toolchains to register in the workspace. -### Interfacing with Javascript rules +## Interfacing with Javascript rules While it's recommended for users to mantain their own , in the `@rules_rust_wasm_bindgen` package there exists interface sub-packages for various -Javascript Bazel rules. E.g. `build_bazel_rules_nodejs` or `aspect_rules_js`. The -rules defined there are a more convenient way to use `rust_wasm_bindgen` with the -associated javascript rules due to the inclusion of additional providers. Each -directory contains a `defs.bzl` file that defines the different variants of -`rust_wasm_bindgen`. (e.g. `nodejs_rust_wasm_bindgen` for the `rules_nodejs` submodule). +Javascript Bazel rules. E.g. `aspect_rules_js`. The rules defined there are a more +convenient way to use `rust_wasm_bindgen` with the associated javascript rules due +to the inclusion of additional providers. Each directory contains a `defs.bzl` file +that defines the different variants of `rust_wasm_bindgen`. (e.g. `js_rust_wasm_bindgen` +for the `rules_js` submodule). [wb]: https://github.com/rustwasm/wasm-bindgen diff --git a/docs/src/rust_wasm_bindgen_rules_nodejs.md b/docs/src/rust_wasm_bindgen_rules_nodejs.md deleted file mode 100644 index d27ca15e55..0000000000 --- a/docs/src/rust_wasm_bindgen_rules_nodejs.md +++ /dev/null @@ -1,29 +0,0 @@ - - -Rust WASM-bindgen rules for interfacing with bazelbuild/rules_nodejs - - - -## nodejs_rust_wasm_bindgen - -
-nodejs_rust_wasm_bindgen(name, bindgen_flags, target, target_arch, wasm_file)
-
- -Generates javascript and typescript bindings for a webassembly module using [wasm-bindgen][ws] that interface with [bazelbuild/rules_nodejs][bbnjs]. - -[ws]: https://rustwasm.github.io/docs/wasm-bindgen/ -[bbnjs]: https://github.com/bazelbuild/rules_nodejs - -**ATTRIBUTES** - - -| Name | Description | Type | Mandatory | Default | -| :------------- | :------------- | :------------- | :------------- | :------------- | -| name | A unique name for this target. | Name | required | | -| bindgen_flags | Flags to pass directly to the bindgen executable. See https://github.com/rustwasm/wasm-bindgen/ for details. | List of strings | optional | `[]` | -| target | The type of output to generate. See https://rustwasm.github.io/wasm-bindgen/reference/deployment.html for details. | String | optional | `"bundler"` | -| target_arch | The target architecture to use for the wasm-bindgen command line option. | String | optional | `"wasm32"` | -| wasm_file | The `.wasm` file or crate to generate bindings for. | Label | required | | - - diff --git a/extensions/bindgen/.bazelignore b/extensions/bindgen/.bazelignore index 8c29e7dd07..26abfdf00b 100644 --- a/extensions/bindgen/.bazelignore +++ b/extensions/bindgen/.bazelignore @@ -1,5 +1,5 @@ examples bazel-out bazel-testlogs -bazel-extensions +bazel-bindgen bazel-bin diff --git a/extensions/bindgen/.bazelrc b/extensions/bindgen/.bazelrc index 6b20ca4b70..f3e5a5d06f 100644 --- a/extensions/bindgen/.bazelrc +++ b/extensions/bindgen/.bazelrc @@ -60,9 +60,8 @@ build --incompatible_merge_fixed_and_default_shell_env ## Bzlmod ############################################################################### -# TODO: migrate all dependencies from WORKSPACE to MODULE.bazel -# https://github.com/bazelbuild/rules_rust/issues/2181 -common --noenable_bzlmod --enable_workspace +# A configuration for disabling bzlmod. +common:no-bzlmod --noenable_bzlmod --enable_workspace # Disable the bzlmod lockfile, so we don't accidentally commit MODULE.bazel.lock common --lockfile_mode=off diff --git a/extensions/bindgen/3rdparty/BUILD.zstd.bazel b/extensions/bindgen/3rdparty/BUILD.zstd.bazel new file mode 100644 index 0000000000..a80cea2f70 --- /dev/null +++ b/extensions/bindgen/3rdparty/BUILD.zstd.bazel @@ -0,0 +1,28 @@ +load("@rules_cc//cc:defs.bzl", "cc_library") + +package(default_visibility = ["//visibility:public"]) + +cc_library( + name = "zstd", + srcs = glob([ + "lib/common/*.c", + "lib/common/*.h", + "lib/compress/*.c", + "lib/compress/*.h", + "lib/decompress/*.c", + "lib/decompress/*.h", + "lib/decompress/*.S", + "lib/dictBuilder/*.c", + "lib/dictBuilder/*.h", + ]), + hdrs = [ + "lib/zdict.h", + "lib/zstd.h", + "lib/zstd_errors.h", + ], + defines = [ + "LLVM_ENABLE_ZSTD=1", + "ZSTD_MULTITHREAD", + ], + strip_include_prefix = "lib", +) diff --git a/extensions/bindgen/3rdparty/patches/README.md b/extensions/bindgen/3rdparty/patches/README.md index 296fbfda3a..a8cb5c4cdb 100644 --- a/extensions/bindgen/3rdparty/patches/README.md +++ b/extensions/bindgen/3rdparty/patches/README.md @@ -2,24 +2,11 @@ All patches pair with the versions of the referenced repositories defined in `@rules_rust_bindgen//:repositories.bzl`. -## [llvm-project.cxx17](./llvm-project.cxx17.patch) - -The llvm-project requires a compiler that builds with at least C++14 but there's no configuration -for this on the targets defined in the repo. This patch plumbs through flags for setting the C++ -version on targets to avoid any need for bazel configuration flags. If this patch causes issues -for users with their current toolchain or toolchain definitions then simply defining the `llvm-raw` -repository before loading `rust_bindgen_dependencies` should avoid this. - ## [llvm-project.incompatible_disallow_empty_glob](./llvm-project.incompatible_disallow_empty_glob.patch) Uses of `glob` are updated to have `allow_empty = True` added so the llvm-project repo is compatible with consumers building with [--incompatible_disallow_empty_glob](https://bazel.build/reference/command-line-reference#flag--incompatible_disallow_empty_glob). -Most of this patch is generated using the following regex and replace patterns. There are a handful -of additional modifications for more extravagant globs. +## [llvm-raw.incompatible_disallow_empty_glob](./llvm-raw.incompatible_disallow_empty_glob.patch) -| regex | replace | -| --- | --- | -| `glob\(([\[\w\d_\-\*\/\.\],=\n\s"]+)\) \+` | `glob($1, allow_empty = True) +` | -| `glob\(([\[\w\d_\-\*\/\.\],=\n\s"]+)\),` | `glob($1, allow_empty = True),` | -| `(,[\s\n]+), ` | `$1` | +Similar to the `llvm-project` variant but is used outside of bzlmod. diff --git a/extensions/bindgen/3rdparty/patches/llvm-project.cxx17.patch b/extensions/bindgen/3rdparty/patches/llvm-project.cxx17.patch deleted file mode 100644 index fba538489f..0000000000 --- a/extensions/bindgen/3rdparty/patches/llvm-project.cxx17.patch +++ /dev/null @@ -1,537 +0,0 @@ -diff --git a/utils/bazel/configure.bzl b/utils/bazel/configure.bzl -index 4c5ab8bd0972..44de2da1a136 100644 ---- a/utils/bazel/configure.bzl -+++ b/utils/bazel/configure.bzl -@@ -70,6 +70,11 @@ def _overlay_directories(repository_ctx): - )) - - def _llvm_configure_impl(repository_ctx): -+ # Force this repository rule to update if any of the overlay -+ # sources change. -+ for target in repository_ctx.attr._srcs: -+ repository_ctx.path(target) -+ - _overlay_directories(repository_ctx) - - # Create a starlark file with the requested LLVM targets. -@@ -86,6 +91,16 @@ llvm_configure = repository_rule( - configure = True, - attrs = { - "targets": attr.string_list(default = DEFAULT_TARGETS), -+ "_srcs": attr.label_list(default = [ -+ Label("//utils/bazel/llvm-project-overlay/clang:BUILD.bazel"), -+ Label("//utils/bazel/llvm-project-overlay/libunwind:BUILD.bazel"), -+ Label("//utils/bazel/llvm-project-overlay/llvm:binary_alias.bzl"), -+ Label("//utils/bazel/llvm-project-overlay/llvm:BUILD.bazel"), -+ Label("//utils/bazel/llvm-project-overlay/llvm:cc_plugin_library.bzl"), -+ Label("//utils/bazel/llvm-project-overlay/llvm:config.bzl"), -+ Label("//utils/bazel/llvm-project-overlay/llvm:tblgen.bzl"), -+ Label("//utils/bazel/llvm-project-overlay/llvm:template_rule.bzl"), -+ ]), - }, - ) - -diff --git a/utils/bazel/llvm-project-overlay/clang/BUILD.bazel b/utils/bazel/llvm-project-overlay/clang/BUILD.bazel -index a2b1e0f33073..0c1abe607b58 100644 ---- a/utils/bazel/llvm-project-overlay/clang/BUILD.bazel -+++ b/utils/bazel/llvm-project-overlay/clang/BUILD.bazel -@@ -5,6 +5,7 @@ - load("//llvm:tblgen.bzl", "gentbl") - load("//llvm:binary_alias.bzl", "binary_alias") - load("//llvm:cc_plugin_library.bzl", "cc_plugin_library") -+load("//llvm:config.bzl", "llvm_stdcxx_copts") - - package( - default_visibility = ["//visibility:public"], -@@ -28,7 +29,7 @@ cc_binary( - ]), - copts = [ - "$(STACK_FRAME_UNLIMITED)", -- ], -+ ] + llvm_stdcxx_copts, - stamp = 0, - deps = [ - "//llvm:Support", -@@ -391,8 +392,8 @@ cc_library( - cc_library( - name = "basic", - srcs = [ -- "include/clang/Basic/Version.inc", - "include/VCSVersion.inc", -+ "include/clang/Basic/Version.inc", - ] + glob([ - "lib/Basic/*.cpp", - "lib/Basic/*.c", -@@ -406,7 +407,7 @@ cc_library( - copts = [ - "-DHAVE_VCS_VERSION_INC", - "$(STACK_FRAME_UNLIMITED)", -- ], -+ ] + llvm_stdcxx_copts, - includes = ["include"], - textual_hdrs = [ - "include/clang/Basic/arm_fp16.inc", -@@ -471,6 +472,7 @@ cc_library( - hdrs = glob([ - "include/clang/Lex/*.h", - ]), -+ copts = llvm_stdcxx_copts, - includes = ["include"], - deps = [ - ":basic", -@@ -711,7 +713,7 @@ cc_library( - # headers such as `CXXABI.h`. - "-I$(GENDIR)/external/llvm-project/clang/lib/AST", - "-I$(GENDIR)/external/llvm-project/clang/lib/AST/Interp", -- ], -+ ] + llvm_stdcxx_copts, - textual_hdrs = [ - "include/clang/AST/AttrImpl.inc", - "include/clang/AST/AttrNodeTraverse.inc", -@@ -763,6 +765,7 @@ cc_library( - "include/clang/Index/*.h", - "include/clang-c/*.h", - ]), -+ copts = llvm_stdcxx_copts, - includes = ["include"], - deps = [ - ":ast", -@@ -786,6 +789,7 @@ cc_library( - hdrs = glob([ - "include/clang/Analysis/**/*.h", - ]), -+ copts = llvm_stdcxx_copts, - includes = ["include"], - textual_hdrs = glob([ - "include/clang/Analysis/**/*.def", -@@ -844,7 +848,7 @@ cc_library( - "include/clang/Sema/*.h", - "include/clang-c/*.h", - ]), -- copts = ["$(STACK_FRAME_UNLIMITED)"], -+ copts = ["$(STACK_FRAME_UNLIMITED)"] + llvm_stdcxx_copts, - includes = ["include"], - textual_hdrs = [ - "include/clang/Sema/AttrParsedAttrImpl.inc", -@@ -911,6 +915,7 @@ cc_library( - "include/clang/Parse/AttrParserStringSwitches.inc", - "include/clang/Parse/AttrSubMatchRulesParserStringSwitches.inc", - ] + glob(["include/clang/Parse/*.h"]), -+ copts = llvm_stdcxx_copts, - includes = ["include"], - deps = [ - ":ast", -@@ -932,6 +937,7 @@ cc_library( - "lib/ASTMatchers/*.h", - ]), - hdrs = glob(["include/clang/ASTMatchers/*.h"]), -+ copts = llvm_stdcxx_copts, - includes = ["include"], - deps = [ - ":ast", -@@ -948,7 +954,7 @@ cc_library( - "lib/ASTMatchers/Dynamic/*.h", - ]), - hdrs = glob(["include/clang/ASTMatchers/Dynamic/*.h"]), -- copts = ["$(STACK_FRAME_UNLIMITED)"], -+ copts = ["$(STACK_FRAME_UNLIMITED)"] + llvm_stdcxx_copts, - includes = ["include"], - deps = [ - ":ast", -@@ -966,6 +972,7 @@ cc_library( - "lib/Rewrite/*.h", - ]), - hdrs = glob(["include/clang/Rewrite/Core/*.h"]), -+ copts = llvm_stdcxx_copts, - includes = ["include"], - deps = [ - ":ast", -@@ -982,6 +989,7 @@ cc_library( - "lib/Testing/*.cpp", - ]), - hdrs = glob(["include/clang/Testing/*.h"]), -+ copts = llvm_stdcxx_copts, - includes = ["include"], - deps = [ - ":basic", -@@ -996,6 +1004,7 @@ cc_library( - "lib/Tooling/Core/*.h", - ]), - hdrs = glob(["include/clang/Tooling/Core/*.h"]), -+ copts = llvm_stdcxx_copts, - includes = ["include"], - deps = [ - ":ast", -@@ -1018,6 +1027,7 @@ cc_library( - hdrs = glob([ - "include/clang/Tooling/*.h", - ]), -+ copts = llvm_stdcxx_copts, - includes = ["include"], - deps = [ - ":ast", -@@ -1042,6 +1052,7 @@ cc_library( - hdrs = glob([ - "include/clang/Tooling/Inclusions/**/*.h", - ]), -+ copts = llvm_stdcxx_copts, - deps = [ - ":basic", - ":lex", -@@ -1061,6 +1072,7 @@ cc_library( - "include/clang/Tooling/Refactoring/**/*.h", - "include/clang/Tooling/Refactoring/**/*.def", - ]), -+ copts = llvm_stdcxx_copts, - deps = [ - ":ast", - ":ast_matchers", -@@ -1094,6 +1106,7 @@ cc_library( - name = "tooling_syntax", - srcs = glob(["lib/Tooling/Syntax/**/*.cpp"]), - hdrs = glob(["include/clang/Tooling/Syntax/**/*.h"]), -+ copts = llvm_stdcxx_copts, - deps = [ - ":ast", - ":basic", -@@ -1108,6 +1121,7 @@ cc_library( - name = "tooling_dependency_scanning", - srcs = glob(["lib/Tooling/DependencyScanning/**/*.cpp"]), - hdrs = glob(["include/clang/Tooling/DependencyScanning/**/*.h"]), -+ copts = llvm_stdcxx_copts, - deps = [ - ":basic", - ":codegen", -@@ -1123,6 +1137,7 @@ cc_library( - name = "transformer", - srcs = glob(["lib/Tooling/Transformer/**/*.cpp"]), - hdrs = glob(["include/clang/Tooling/Transformer/**/*.h"]), -+ copts = llvm_stdcxx_copts, - deps = [ - ":ast", - ":ast_matchers", -@@ -1138,6 +1153,7 @@ cc_library( - name = "ast-diff", - srcs = glob(["lib/Tooling/ASTDiff/*.cpp"]), - hdrs = glob(["include/clang/Tooling/ASTDiff/*.h"]), -+ copts = llvm_stdcxx_copts, - deps = [ - ":ast", - ":basic", -@@ -1150,6 +1166,7 @@ cc_library( - name = "crosstu", - srcs = glob(["lib/CrossTU/*.cpp"]), - hdrs = glob(["include/clang/CrossTU/*.h"]), -+ copts = llvm_stdcxx_copts, - deps = [ - ":ast", - ":basic", -@@ -1174,6 +1191,7 @@ cc_library( - ] + glob([ - "include/clang/Format/*.h", - ]), -+ copts = llvm_stdcxx_copts, - includes = ["include"], - deps = [ - ":basic", -@@ -1188,6 +1206,7 @@ cc_library( - name = "edit", - srcs = glob(["lib/Edit/*.cpp"]), - hdrs = glob(["include/clang/Edit/*.h"]), -+ copts = llvm_stdcxx_copts, - includes = ["include"], - deps = [ - ":ast", -@@ -1222,6 +1241,7 @@ cc_library( - hdrs = glob([ - "include/clang/StaticAnalyzer/Core/**/*.h", - ]), -+ copts = llvm_stdcxx_copts, - includes = ["include"], - textual_hdrs = glob([ - "include/clang/StaticAnalyzer/Core/**/*.def", -@@ -1268,7 +1288,7 @@ cc_library( - ] + glob([ - "include/clang/StaticAnalyzer/Checkers/**/*.h", - ]), -- copts = ["$(STACK_FRAME_UNLIMITED)"], -+ copts = ["$(STACK_FRAME_UNLIMITED)"] + llvm_stdcxx_copts, - includes = ["include"], - deps = [ - ":analysis", -@@ -1316,7 +1336,7 @@ cc_library( - hdrs = glob([ - "include/clang/Driver/*.h", - ]), -- copts = ["$(STACK_FRAME_UNLIMITED)"], -+ copts = ["$(STACK_FRAME_UNLIMITED)"] + llvm_stdcxx_copts, - includes = [ - "include", - # TODO: This is likely a layering issue, but files in Arch are currently -@@ -1479,7 +1499,7 @@ cc_library( - hdrs = glob([ - "include/clang/Frontend/*.h", - ]), -- copts = ["$(STACK_FRAME_UNLIMITED)"], -+ copts = ["$(STACK_FRAME_UNLIMITED)"] + llvm_stdcxx_copts, - data = [":builtin_headers_gen"], - includes = ["include"], - textual_hdrs = glob([ -@@ -1519,6 +1539,7 @@ cc_library( - "lib/Frontend/Rewrite/*.h", - ]), - hdrs = glob(["include/clang/Rewrite/Frontend/*.h"]), -+ copts = llvm_stdcxx_copts, - includes = ["include"], - deps = [ - ":ast", -@@ -1541,6 +1562,7 @@ cc_library( - "lib/Interpreter/*.h", - ]), - hdrs = glob(["include/clang/Interpreter/*.h"]), -+ copts = llvm_stdcxx_copts, - includes = ["include"], - deps = [ - ":analysis", -@@ -1573,7 +1595,7 @@ cc_library( - "lib/CodeGen/*.h", - ]), - hdrs = glob(["include/clang/CodeGen/*.h"]), -- copts = ["$(STACK_FRAME_UNLIMITED)"], -+ copts = ["$(STACK_FRAME_UNLIMITED)"] + llvm_stdcxx_copts, - includes = ["include"], - deps = [ - ":analysis", -@@ -1624,6 +1646,7 @@ cc_library( - "lib/StaticAnalyzer/Frontend/**/*.h", - ]), - hdrs = glob(["include/clang/StaticAnalyzer/Frontend/**/*.h"]), -+ copts = llvm_stdcxx_copts, - includes = ["include"], - deps = [ - ":analysis", -@@ -1678,6 +1701,7 @@ cc_library( - hdrs = glob([ - "include/clang/Serialization/*.h", - ]), -+ copts = llvm_stdcxx_copts, - includes = ["include"], - textual_hdrs = glob([ - "include/clang/Serialization/*.def", -@@ -1705,6 +1729,7 @@ cc_library( - "lib/FrontendTool/*.h", - ]), - hdrs = glob(["include/clang/FrontendTool/*.h"]), -+ copts = llvm_stdcxx_copts, - includes = ["include"], - deps = [ - ":arc_migrate", -@@ -1726,6 +1751,7 @@ cc_library( - "lib/ARCMigrate/*.h", - ]), - hdrs = glob(["include/clang/ARCMigrate/*.h"]), -+ copts = llvm_stdcxx_copts, - includes = ["include"], - deps = [ - ":analysis", -@@ -1752,6 +1778,7 @@ cc_library( - "tools/libclang/*.h", - ]), - hdrs = glob(["include/clang-c/*.h"]), -+ copts = llvm_stdcxx_copts, - defines = ["CINDEX_NO_EXPORTS"], - deps = [ - ":arc_migrate", -@@ -1783,7 +1810,7 @@ cc_plugin_library( - copts = select({ - "@bazel_tools//src/conditions:windows": ["-D_CINDEX_LIB_"], - "//conditions:default": [], -- }), -+ }) + llvm_stdcxx_copts, - strip_include_prefix = "include", - deps = [ - ":arc_migrate", -@@ -1912,7 +1939,7 @@ cc_library( - # Disable stack frame size checks in the driver because - # clang::ensureStackAddressSpace allocates a large array on the stack. - "$(STACK_FRAME_UNLIMITED)", -- ], -+ ] + llvm_stdcxx_copts, - deps = [ - ":analysis", - ":ast", -@@ -1947,6 +1974,7 @@ cc_library( - cc_binary( - name = "clang", - srcs = [], -+ copts = llvm_stdcxx_copts, - stamp = 0, - deps = [ - ":clang-driver", -diff --git a/utils/bazel/llvm-project-overlay/llvm/BUILD.bazel b/utils/bazel/llvm-project-overlay/llvm/BUILD.bazel -index 85d79a29b571..716d7f5d9645 100644 ---- a/utils/bazel/llvm-project-overlay/llvm/BUILD.bazel -+++ b/utils/bazel/llvm-project-overlay/llvm/BUILD.bazel -@@ -4,7 +4,7 @@ - - load(":template_rule.bzl", "template_rule") - load(":tblgen.bzl", "gentbl") --load(":config.bzl", "llvm_config_defines") -+load(":config.bzl", "llvm_config_defines", "llvm_stdcxx_copts") - load(":targets.bzl", "llvm_targets") - load(":enum_targets_gen.bzl", "enum_targets_gen") - load(":binary_alias.bzl", "binary_alias") -@@ -21,10 +21,12 @@ exports_files(["LICENSE.TXT"]) - # toolchain or the `.bazelrc` file. This is just a workaround until we have a - # widely available feature to enable unlimited stack frame instead of using - # this `Make` variable. --llvm_copts = [ -+llvm_c_only_opts = [ - "$(STACK_FRAME_UNLIMITED)", - ] - -+llvm_copts = llvm_c_only_opts + llvm_stdcxx_copts -+ - enum_targets_gen( - name = "targets_def_gen", - src = "include/llvm/Config/Targets.def.in", -@@ -167,10 +169,69 @@ genrule( - "echo -e '#undef HANDLE_EXTENSION' >> $@\n", - ) - -+# TODO: This separation is required to separate out C++ and C opts -+# https://github.com/bazelbuild/bazel/issues/16551 - cc_library( -- name = "Support", -+ name = "Support-c", - srcs = glob([ - "lib/Support/*.c", -+ ]), -+ hdrs = glob([ -+ "include/llvm/Support/**/*.h", -+ "include/llvm/ADT/*.h", -+ ]) + [ -+ "include/llvm-c/Core.h", -+ "include/llvm-c/DataTypes.h", -+ "include/llvm-c/Deprecated.h", -+ "include/llvm-c/DisassemblerTypes.h", -+ "include/llvm-c/Error.h", -+ "include/llvm-c/ErrorHandling.h", -+ "include/llvm-c/ExternC.h", -+ "include/llvm-c/Support.h", -+ "include/llvm-c/Types.h", -+ "include/llvm/ExecutionEngine/JITSymbol.h", -+ "include/llvm/Support/Extension.def", -+ "include/llvm/Support/VCSRevision.h", -+ ], -+ copts = llvm_c_only_opts, -+ includes = ["include"], -+ linkopts = select({ -+ "@bazel_tools//src/conditions:windows": [], -+ "@bazel_tools//src/conditions:freebsd": [ -+ "-pthread", -+ "-lexecinfo", -+ "-ldl", -+ "-lm", -+ ], -+ "//conditions:default": [ -+ "-pthread", -+ "-ldl", -+ "-lm", -+ ], -+ }), -+ textual_hdrs = glob([ -+ "include/llvm/Support/*.def", -+ "lib/Support/*.h", -+ "lib/Support/*.inc", -+ ]), -+ deps = [ -+ ":config", -+ ":Demangle", -+ # We unconditionally depend on the custom LLVM terminfo wrapper. This -+ # will be an empty library unless terminfo is enabled, in which case it -+ # will both provide the necessary dependencies and configuration -+ # defines. -+ "@llvm_terminfo//:terminfo", -+ # We unconditionally depend on the custom LLVM zlib wrapper. This will -+ # be an empty library unless zlib is enabled, in which case it will -+ # both provide the necessary dependencies and configuration defines. -+ "@llvm_zlib//:zlib", -+ ], -+) -+ -+cc_library( -+ name = "Support", -+ srcs = glob([ - "lib/Support/*.cpp", - "lib/Support/*.h", - "lib/Support/*.inc", -@@ -223,6 +284,7 @@ cc_library( - "include/llvm/Support/*.def", - ]), - deps = [ -+ ":Support-c", - ":config", - ":Demangle", - # We unconditionally depend on the custom LLVM terminfo wrapper. This -diff --git a/utils/bazel/llvm-project-overlay/llvm/cc_plugin_library.bzl b/utils/bazel/llvm-project-overlay/llvm/cc_plugin_library.bzl -index 2ebd39c630dc..e45bd8a1ce92 100644 ---- a/utils/bazel/llvm-project-overlay/llvm/cc_plugin_library.bzl -+++ b/utils/bazel/llvm-project-overlay/llvm/cc_plugin_library.bzl -@@ -16,6 +16,7 @@ configure generic aspects of all generated rules such as `testonly`. Lastly, - """ - - load("@rules_cc//cc:defs.bzl", "cc_binary", "cc_import", "cc_library") -+load(":config.bzl", "llvm_stdcxx_copts") - - def cc_plugin_library(name, srcs, hdrs, include_prefix = None, strip_include_prefix = None, alwayslink = False, features = [], tags = [], testonly = False, **kwargs): - # Neither the name of the plugin binary nor tags on whether it is built are -@@ -29,6 +30,7 @@ def cc_plugin_library(name, srcs, hdrs, include_prefix = None, strip_include_pre - dylib_name = name + ".dylib" - interface_output_name = name + "_interface_output" - import_name = name + "_import" -+ copts = kwargs.pop("copts", []) - for impl_name in [dll_name, dylib_name, so_name]: - cc_binary( - name = impl_name, -@@ -38,6 +40,7 @@ def cc_plugin_library(name, srcs, hdrs, include_prefix = None, strip_include_pre - features = features, - tags = ["manual"] + tags, - testonly = testonly, -+ copts = copts + llvm_stdcxx_copts, - **kwargs - ) - native.filegroup( -diff --git a/utils/bazel/llvm-project-overlay/llvm/config.bzl b/utils/bazel/llvm-project-overlay/llvm/config.bzl -index 2046b2645362..736844bfc2d0 100644 ---- a/utils/bazel/llvm-project-overlay/llvm/config.bzl -+++ b/utils/bazel/llvm-project-overlay/llvm/config.bzl -@@ -97,3 +97,8 @@ llvm_config_defines = os_defines + select({ - "__STDC_CONSTANT_MACROS", - "__STDC_FORMAT_MACROS", - ] -+ -+llvm_stdcxx_copts = select({ -+ "@platforms//os:windows": ["/std:c++17"], -+ "//conditions:default": ["-std=c++17"], -+}) -diff --git a/utils/bazel/llvm-project-overlay/llvm/tblgen.bzl b/utils/bazel/llvm-project-overlay/llvm/tblgen.bzl -index d43390918e39..e0482a6fd4fa 100644 ---- a/utils/bazel/llvm-project-overlay/llvm/tblgen.bzl -+++ b/utils/bazel/llvm-project-overlay/llvm/tblgen.bzl -@@ -12,6 +12,8 @@ TODO(chandlerc): Currently this expresses include-based dependencies as - correctly understood by the build system. - """ - -+load(":config.bzl", "llvm_stdcxx_copts") -+ - def gentbl( - name, - tblgen, -@@ -77,5 +79,6 @@ def gentbl( - # distinction between these two. - hdrs = [f for (_, f) in tbl_outs], - features = ["-parse_headers", "-header_modules"], -+ copts = llvm_stdcxx_copts, - **kwargs - ) diff --git a/extensions/bindgen/3rdparty/patches/llvm-project.incompatible_disallow_empty_glob.patch b/extensions/bindgen/3rdparty/patches/llvm-project.incompatible_disallow_empty_glob.patch index 001affa6a0..d534ec5f65 100644 --- a/extensions/bindgen/3rdparty/patches/llvm-project.incompatible_disallow_empty_glob.patch +++ b/extensions/bindgen/3rdparty/patches/llvm-project.incompatible_disallow_empty_glob.patch @@ -1,49 +1,8 @@ -diff --git a/utils/bazel/llvm-project-overlay/clang/BUILD.bazel b/utils/bazel/llvm-project-overlay/clang/BUILD.bazel -index 0c1abe607b58..a382a3bc3d69 100644 ---- a/utils/bazel/llvm-project-overlay/clang/BUILD.bazel -+++ b/utils/bazel/llvm-project-overlay/clang/BUILD.bazel -@@ -26,7 +26,7 @@ cc_binary( - srcs = glob([ - "utils/TableGen/*.cpp", - "utils/TableGen/*.h", -- ]), -+ ], allow_empty = True), - copts = [ - "$(STACK_FRAME_UNLIMITED)", - ] + llvm_stdcxx_copts, -@@ -68,7 +68,7 @@ gentbl( - ], - tblgen = ":clang-tblgen", - td_file = "include/clang/Basic/Diagnostic.td", -- td_srcs = glob(["include/clang/Basic/*.td"]), -+ td_srcs = glob(["include/clang/Basic/*.td"], allow_empty = True), - ) - - gentbl( -@@ -333,11 +333,11 @@ gentbl( - # Table definition files can be used for documentation: - filegroup( - name = "all_table_defs", -- srcs = glob(["include/**/*.td"]), -+ srcs = glob(["include/**/*.td"], allow_empty = True), - ) - - exports_files( -- glob(["include/**/*.td"]), -+ glob(["include/**/*.td"], allow_empty = True), - ) - - genrule( -@@ -384,7 +384,7 @@ cc_library( - name = "basic_internal_headers", - hdrs = glob([ - "lib/Basic/*.h", -- ]), -+ ], allow_empty = True), - features = ["-header_modules"], - strip_include_prefix = "lib/Basic", - ) -@@ -400,10 +400,10 @@ cc_library( +diff --git a/clang/BUILD.bazel b/clang/BUILD.bazel +index ec87a37e2..3cc9d21cb 100644 +--- a/clang/BUILD.bazel ++++ b/clang/BUILD.bazel +@@ -533,7 +533,7 @@ cc_library( "lib/Basic/*.h", "lib/Basic/Targets/*.cpp", "lib/Basic/Targets/*.h", @@ -51,96 +10,17 @@ index 0c1abe607b58..a382a3bc3d69 100644 + ], allow_empty = True), hdrs = glob([ "include/clang/Basic/*.h", -- ]), -+ ], allow_empty = True), - copts = [ - "-DHAVE_VCS_VERSION_INC", - "$(STACK_FRAME_UNLIMITED)", -@@ -435,7 +435,7 @@ cc_library( - "include/clang/Basic/DiagnosticIndexName.inc", - ] + glob([ - "include/clang/Basic/*.def", -- ]), -+ ], allow_empty = True), - deps = [ - ":basic_arm_cde_gen", - ":basic_arm_fp16_inc_gen", -@@ -468,10 +468,10 @@ cc_library( - srcs = glob([ - "lib/Lex/*.cpp", - "lib/Lex/*.h", -- ]), -+ ], allow_empty = True), - hdrs = glob([ - "include/clang/Lex/*.h", -- ]), -+ ], allow_empty = True), - copts = llvm_stdcxx_copts, - includes = ["include"], - deps = [ -@@ -694,13 +694,13 @@ cc_library( - "lib/AST/*.h", - "lib/AST/Interp/*.cpp", - "lib/AST/Interp/*.h", + ]), +@@ -944,7 +944,7 @@ cc_library( + "lib/Analysis/FlowSensitive/*.cpp", + "lib/Analysis/*.cpp", + "lib/Analysis/*.h", - ]) + [ + ], allow_empty = True) + [ - "lib/AST/AttrDocTable.inc", - "lib/AST/Interp/Opcodes.inc", + ":analysis_htmllogger_gen", ], hdrs = glob([ - "include/clang/AST/*.h", -- ]), -+ ], allow_empty = True), - copts = [ - # FIXME: This is necessary to allow "file relative" include paths from - # non-generated `srcs` to find generated `srcs` above. Bazel should -@@ -731,7 +731,7 @@ cc_library( - "include/clang/AST/StmtNodes.inc", - ] + glob([ - "include/clang/AST/*.def", -- ]), -+ ], allow_empty = True), - deps = [ - ":ast_attr_gen", - ":ast_comment_command_info_gen", -@@ -760,7 +760,7 @@ cc_library( - srcs = glob([ - "lib/Index/*.cpp", - "lib/Index/*.h", -- ]), -+ ], allow_empty = True), - hdrs = glob([ - "include/clang/Index/*.h", - "include/clang-c/*.h", -@@ -785,15 +785,15 @@ cc_library( - srcs = glob([ - "lib/Analysis/*.cpp", - "lib/Analysis/*.h", -- ]), -+ ], allow_empty = True), - hdrs = glob([ - "include/clang/Analysis/**/*.h", -- ]), -+ ], allow_empty = True), - copts = llvm_stdcxx_copts, - includes = ["include"], - textual_hdrs = glob([ - "include/clang/Analysis/**/*.def", -- ]), -+ ], allow_empty = True), - deps = [ - ":ast", - ":ast_matchers", -@@ -843,7 +843,7 @@ cc_library( - srcs = glob([ - "lib/Sema/*.cpp", - "lib/Sema/*.h", -- ]), -+ ], allow_empty = True), - hdrs = glob([ - "include/clang/Sema/*.h", - "include/clang-c/*.h", -@@ -910,11 +910,11 @@ cc_library( +@@ -1080,7 +1080,7 @@ cc_library( ] + glob([ "lib/Parse/*.cpp", "lib/Parse/*.h", @@ -149,89 +29,34 @@ index 0c1abe607b58..a382a3bc3d69 100644 hdrs = [ "include/clang/Parse/AttrParserStringSwitches.inc", "include/clang/Parse/AttrSubMatchRulesParserStringSwitches.inc", -- ] + glob(["include/clang/Parse/*.h"]), -+ ] + glob(["include/clang/Parse/*.h"], allow_empty = True), - copts = llvm_stdcxx_copts, - includes = ["include"], - deps = [ -@@ -935,8 +935,8 @@ cc_library( +@@ -1104,7 +1104,7 @@ cc_library( srcs = glob([ "lib/ASTMatchers/*.cpp", "lib/ASTMatchers/*.h", - ]), -- hdrs = glob(["include/clang/ASTMatchers/*.h"]), + ], allow_empty = True), -+ hdrs = glob(["include/clang/ASTMatchers/*.h"], allow_empty = True), - copts = llvm_stdcxx_copts, + hdrs = glob(["include/clang/ASTMatchers/*.h"]), includes = ["include"], deps = [ -@@ -952,8 +952,8 @@ cc_library( - srcs = glob([ - "lib/ASTMatchers/Dynamic/*.cpp", - "lib/ASTMatchers/Dynamic/*.h", -- ]), -- hdrs = glob(["include/clang/ASTMatchers/Dynamic/*.h"]), -+ ], allow_empty = True), -+ hdrs = glob(["include/clang/ASTMatchers/Dynamic/*.h"], allow_empty = True), - copts = ["$(STACK_FRAME_UNLIMITED)"] + llvm_stdcxx_copts, - includes = ["include"], - deps = [ -@@ -970,8 +970,8 @@ cc_library( +@@ -1138,7 +1138,7 @@ cc_library( srcs = glob([ "lib/Rewrite/*.cpp", "lib/Rewrite/*.h", - ]), -- hdrs = glob(["include/clang/Rewrite/Core/*.h"]), + ], allow_empty = True), -+ hdrs = glob(["include/clang/Rewrite/Core/*.h"], allow_empty = True), - copts = llvm_stdcxx_copts, + hdrs = glob(["include/clang/Rewrite/Core/*.h"]), includes = ["include"], deps = [ -@@ -987,8 +987,8 @@ cc_library( - name = "testing", - srcs = glob([ - "lib/Testing/*.cpp", -- ]), -- hdrs = glob(["include/clang/Testing/*.h"]), -+ ], allow_empty = True), -+ hdrs = glob(["include/clang/Testing/*.h"], allow_empty = True), - copts = llvm_stdcxx_copts, - includes = ["include"], - deps = [ -@@ -1002,8 +1002,8 @@ cc_library( +@@ -1172,7 +1172,7 @@ cc_library( srcs = glob([ "lib/Tooling/Core/*.cpp", "lib/Tooling/Core/*.h", - ]), -- hdrs = glob(["include/clang/Tooling/Core/*.h"]), -+ ], allow_empty = True), -+ hdrs = glob(["include/clang/Tooling/Core/*.h"], allow_empty = True), - copts = llvm_stdcxx_copts, - includes = ["include"], - deps = [ -@@ -1026,7 +1026,7 @@ cc_library( - ), - hdrs = glob([ - "include/clang/Tooling/*.h", -- ]), + ], allow_empty = True), - copts = llvm_stdcxx_copts, + hdrs = glob(["include/clang/Tooling/Core/*.h"]), includes = ["include"], deps = [ -@@ -1048,10 +1048,10 @@ cc_library( - name = "tooling_inclusions", - srcs = glob([ - "lib/Tooling/Inclusions/**/*.cpp", -- ]), -+ ], allow_empty = True), - hdrs = glob([ - "include/clang/Tooling/Inclusions/**/*.h", -- ]), -+ ], allow_empty = True), - copts = llvm_stdcxx_copts, - deps = [ - ":basic", -@@ -1067,11 +1067,11 @@ cc_library( +@@ -1237,11 +1237,11 @@ cc_library( srcs = glob([ "lib/Tooling/Refactoring/**/*.cpp", "lib/Tooling/Refactoring/**/*.h", @@ -241,169 +66,19 @@ index 0c1abe607b58..a382a3bc3d69 100644 "include/clang/Tooling/Refactoring/**/*.h", "include/clang/Tooling/Refactoring/**/*.def", - ]), -+ ], allow_empty = True), - copts = llvm_stdcxx_copts, - deps = [ - ":ast", -@@ -1104,8 +1104,8 @@ gentbl( - - cc_library( - name = "tooling_syntax", -- srcs = glob(["lib/Tooling/Syntax/**/*.cpp"]), -- hdrs = glob(["include/clang/Tooling/Syntax/**/*.h"]), -+ srcs = glob(["lib/Tooling/Syntax/**/*.cpp"], allow_empty = True), -+ hdrs = glob(["include/clang/Tooling/Syntax/**/*.h"], allow_empty = True), - copts = llvm_stdcxx_copts, - deps = [ - ":ast", -@@ -1119,8 +1119,8 @@ cc_library( - - cc_library( - name = "tooling_dependency_scanning", -- srcs = glob(["lib/Tooling/DependencyScanning/**/*.cpp"]), -- hdrs = glob(["include/clang/Tooling/DependencyScanning/**/*.h"]), -+ srcs = glob(["lib/Tooling/DependencyScanning/**/*.cpp"], allow_empty = True), -+ hdrs = glob(["include/clang/Tooling/DependencyScanning/**/*.h"], allow_empty = True), - copts = llvm_stdcxx_copts, - deps = [ - ":basic", -@@ -1135,8 +1135,8 @@ cc_library( - - cc_library( - name = "transformer", -- srcs = glob(["lib/Tooling/Transformer/**/*.cpp"]), -- hdrs = glob(["include/clang/Tooling/Transformer/**/*.h"]), -+ srcs = glob(["lib/Tooling/Transformer/**/*.cpp"], allow_empty = True), -+ hdrs = glob(["include/clang/Tooling/Transformer/**/*.h"], allow_empty = True), - copts = llvm_stdcxx_copts, - deps = [ - ":ast", -@@ -1151,8 +1151,8 @@ cc_library( - - cc_library( - name = "ast-diff", -- srcs = glob(["lib/Tooling/ASTDiff/*.cpp"]), -- hdrs = glob(["include/clang/Tooling/ASTDiff/*.h"]), -+ srcs = glob(["lib/Tooling/ASTDiff/*.cpp"], allow_empty = True), -+ hdrs = glob(["include/clang/Tooling/ASTDiff/*.h"], allow_empty = True), - copts = llvm_stdcxx_copts, - deps = [ - ":ast", -@@ -1164,8 +1164,8 @@ cc_library( - - cc_library( - name = "crosstu", -- srcs = glob(["lib/CrossTU/*.cpp"]), -- hdrs = glob(["include/clang/CrossTU/*.h"]), -+ srcs = glob(["lib/CrossTU/*.cpp"], allow_empty = True), -+ hdrs = glob(["include/clang/CrossTU/*.h"], allow_empty = True), - copts = llvm_stdcxx_copts, - deps = [ - ":ast", -@@ -1184,13 +1184,13 @@ cc_library( - "lib/Format/*.cpp", - "lib/Format/*.h", - ], -- ), -+ allow_empty = True), - hdrs = [ - "lib/Format/FormatTokenLexer.h", - "lib/Format/Macros.h", - ] + glob([ - "include/clang/Format/*.h", -- ]), -+ ], allow_empty = True), - copts = llvm_stdcxx_copts, - includes = ["include"], - deps = [ -@@ -1204,8 +1204,8 @@ cc_library( - - cc_library( - name = "edit", -- srcs = glob(["lib/Edit/*.cpp"]), -- hdrs = glob(["include/clang/Edit/*.h"]), -+ srcs = glob(["lib/Edit/*.cpp"], allow_empty = True), -+ hdrs = glob(["include/clang/Edit/*.h"], allow_empty = True), - copts = llvm_stdcxx_copts, - includes = ["include"], - deps = [ -@@ -1237,15 +1237,15 @@ cc_library( - srcs = glob([ - "lib/StaticAnalyzer/Core/**/*.cpp", - "lib/StaticAnalyzer/Core/**/*.h", -- ]), -+ ], allow_empty = True), - hdrs = glob([ - "include/clang/StaticAnalyzer/Core/**/*.h", -- ]), -+ ], allow_empty = True), - copts = llvm_stdcxx_copts, - includes = ["include"], - textual_hdrs = glob([ - "include/clang/StaticAnalyzer/Core/**/*.def", -- ]), + ], allow_empty = True), deps = [ - ":analysis", ":ast", -@@ -1282,12 +1282,12 @@ cc_library( - srcs = glob([ - "lib/StaticAnalyzer/Checkers/**/*.cpp", - "lib/StaticAnalyzer/Checkers/**/*.h", -- ]), -+ ], allow_empty = True), - hdrs = [ - "include/clang/StaticAnalyzer/Checkers/Checkers.inc", - ] + glob([ - "include/clang/StaticAnalyzer/Checkers/**/*.h", -- ]), -+ ], allow_empty = True), - copts = ["$(STACK_FRAME_UNLIMITED)"] + llvm_stdcxx_copts, - includes = ["include"], - deps = [ -@@ -1332,10 +1332,10 @@ cc_library( + ":ast_matchers", +@@ -1500,6 +1500,7 @@ cc_library( exclude = [ "lib/Driver/ToolChains/MSVCSetupApi.h", ], -- ), -+ allow_empty = True), ++ allow_empty = True, + ), hdrs = glob([ "include/clang/Driver/*.h", -- ]), -+ ], allow_empty = True), - copts = ["$(STACK_FRAME_UNLIMITED)"] + llvm_stdcxx_copts, - includes = [ - "include", -@@ -1349,7 +1349,7 @@ cc_library( - }), - textual_hdrs = glob([ - "include/clang/Driver/*.def", -- ]), -+ ], allow_empty = True), - deps = [ - ":ast", - ":basic", -@@ -1466,7 +1466,7 @@ gentbl( - # We generate the set of builtin headers under a special subdirectory in the - # 'bin' section of the bazel output so that they can be used as data - # dependencies. It requires listing explicitly all the generated inputs here. --builtin_headers = glob(["lib/Headers/**/*.h"]) + [ -+builtin_headers = glob(["lib/Headers/**/*.h"], allow_empty = True) + [ - "lib/Headers/arm_cde.h", - "lib/Headers/arm_fp16.h", - "lib/Headers/arm_mve.h", -@@ -1495,16 +1495,16 @@ cc_library( - srcs = glob([ - "lib/Frontend/*.cpp", - "lib/Frontend/*.h", -- ]), -+ ], allow_empty = True), - hdrs = glob([ - "include/clang/Frontend/*.h", -- ]), -+ ], allow_empty = True), - copts = ["$(STACK_FRAME_UNLIMITED)"] + llvm_stdcxx_copts, - data = [":builtin_headers_gen"], +@@ -1716,7 +1717,7 @@ cc_library( includes = ["include"], textual_hdrs = glob([ "include/clang/Frontend/*.def", @@ -412,110 +87,25 @@ index 0c1abe607b58..a382a3bc3d69 100644 deps = [ ":ast", ":basic", -@@ -1537,8 +1537,8 @@ cc_library( +@@ -1752,7 +1753,7 @@ cc_library( srcs = glob([ "lib/Frontend/Rewrite/*.cpp", "lib/Frontend/Rewrite/*.h", - ]), -- hdrs = glob(["include/clang/Rewrite/Frontend/*.h"]), -+ ], allow_empty = True), -+ hdrs = glob(["include/clang/Rewrite/Frontend/*.h"], allow_empty = True), - copts = llvm_stdcxx_copts, - includes = ["include"], - deps = [ -@@ -1560,8 +1560,8 @@ cc_library( - srcs = glob([ - "lib/Interpreter/*.cpp", - "lib/Interpreter/*.h", -- ]), -- hdrs = glob(["include/clang/Interpreter/*.h"]), -+ ], allow_empty = True), -+ hdrs = glob(["include/clang/Interpreter/*.h"], allow_empty = True), - copts = llvm_stdcxx_copts, - includes = ["include"], - deps = [ -@@ -1593,8 +1593,8 @@ cc_library( - srcs = glob([ - "lib/CodeGen/*.cpp", - "lib/CodeGen/*.h", -- ]), -- hdrs = glob(["include/clang/CodeGen/*.h"]), -+ ], allow_empty = True), -+ hdrs = glob(["include/clang/CodeGen/*.h"], allow_empty = True), - copts = ["$(STACK_FRAME_UNLIMITED)"] + llvm_stdcxx_copts, - includes = ["include"], - deps = [ -@@ -1644,8 +1644,8 @@ cc_library( - srcs = glob([ - "lib/StaticAnalyzer/Frontend/**/*.cpp", - "lib/StaticAnalyzer/Frontend/**/*.h", -- ]), -- hdrs = glob(["include/clang/StaticAnalyzer/Frontend/**/*.h"]), -+ ], allow_empty = True), -+ hdrs = glob(["include/clang/StaticAnalyzer/Frontend/**/*.h"], allow_empty = True), - copts = llvm_stdcxx_copts, - includes = ["include"], - deps = [ -@@ -1697,15 +1697,15 @@ cc_library( - ] + glob([ - "lib/Serialization/*.cpp", - "lib/Serialization/*.h", -- ]), + ], allow_empty = True), - hdrs = glob([ - "include/clang/Serialization/*.h", -- ]), -+ ], allow_empty = True), - copts = llvm_stdcxx_copts, + hdrs = glob(["include/clang/Rewrite/Frontend/*.h"]), includes = ["include"], - textual_hdrs = glob([ - "include/clang/Serialization/*.def", -- ]), -+ ], allow_empty = True), deps = [ - ":ast", - ":basic", -@@ -1727,8 +1727,8 @@ cc_library( +@@ -1967,7 +1968,7 @@ cc_library( srcs = glob([ "lib/FrontendTool/*.cpp", "lib/FrontendTool/*.h", - ]), -- hdrs = glob(["include/clang/FrontendTool/*.h"]), -+ ], allow_empty = True), -+ hdrs = glob(["include/clang/FrontendTool/*.h"], allow_empty = True), - copts = llvm_stdcxx_copts, - includes = ["include"], - deps = [ -@@ -1749,8 +1749,8 @@ cc_library( - srcs = glob([ - "lib/ARCMigrate/*.cpp", - "lib/ARCMigrate/*.h", -- ]), -- hdrs = glob(["include/clang/ARCMigrate/*.h"]), + ], allow_empty = True), -+ hdrs = glob(["include/clang/ARCMigrate/*.h"], allow_empty = True), - copts = llvm_stdcxx_copts, + hdrs = glob(["include/clang/FrontendTool/*.h"]), includes = ["include"], deps = [ -@@ -1776,7 +1776,7 @@ cc_library( - srcs = glob([ - "tools/libclang/*.cpp", - "tools/libclang/*.h", -- ]), -+ ], allow_empty = True), - hdrs = glob(["include/clang-c/*.h"]), - copts = llvm_stdcxx_copts, - defines = ["CINDEX_NO_EXPORTS"], -@@ -1805,7 +1805,7 @@ cc_plugin_library( - srcs = glob([ - "tools/libclang/*.cpp", - "tools/libclang/*.h", -- ]), -+ ], allow_empty = True), - hdrs = glob(["include/clang-c/*.h"]), - copts = select({ - "@bazel_tools//src/conditions:windows": ["-D_CINDEX_LIB_"], -@@ -1914,7 +1914,7 @@ cc_binary( +@@ -2155,7 +2156,7 @@ cc_binary( srcs = glob([ "tools/clang-import-test/*.cpp", "tools/clang-import-test/*.h", @@ -524,38 +114,29 @@ index 0c1abe607b58..a382a3bc3d69 100644 stamp = 0, deps = [ ":ast", -@@ -1934,7 +1934,7 @@ cc_library( +@@ -2185,7 +2186,7 @@ cc_library( srcs = glob([ "tools/driver/*.cpp", "tools/driver/*.h", -- ]), -+ ], allow_empty = True), +- ]) + ["clang-driver.cpp"], ++ ], allow_empty = True) + ["clang-driver.cpp"], copts = [ # Disable stack frame size checks in the driver because # clang::ensureStackAddressSpace allocates a large array on the stack. -@@ -1986,7 +1986,7 @@ cc_binary( +@@ -2500,7 +2501,7 @@ cc_library( srcs = glob([ - "tools/diagtool/*.cpp", - "tools/diagtool/*.h", + "lib/ExtractAPI/**/*.cpp", + "lib/ExtractAPI/**/*.h", - ]), + ], allow_empty = True), - stamp = 0, + hdrs = glob(["include/clang/ExtractAPI/**/*.h"]), + includes = ["include"], deps = [ - ":basic", -diff --git a/utils/bazel/llvm-project-overlay/llvm/BUILD.bazel b/utils/bazel/llvm-project-overlay/llvm/BUILD.bazel -index 716d7f5d9645..1e3e7a8ff0e7 100644 ---- a/utils/bazel/llvm-project-overlay/llvm/BUILD.bazel -+++ b/utils/bazel/llvm-project-overlay/llvm/BUILD.bazel -@@ -39,7 +39,7 @@ enum_targets_gen( - llvm_target_asm_printers = [ - t - for t in llvm_targets -- if glob(["lib/Target/{}/*AsmPrinter.cpp".format(t)]) -+ if glob(["lib/Target/{}/*AsmPrinter.cpp".format(t)], allow_empty = True) - ] - - enum_targets_gen( -@@ -54,7 +54,7 @@ enum_targets_gen( +diff --git a/llvm/BUILD.bazel b/llvm/BUILD.bazel +index 836d4049e..ffbdee993 100644 +--- a/llvm/BUILD.bazel ++++ b/llvm/BUILD.bazel +@@ -66,7 +66,7 @@ enum_targets_gen( llvm_target_asm_parsers = [ t for t in llvm_targets @@ -564,7 +145,7 @@ index 716d7f5d9645..1e3e7a8ff0e7 100644 ] enum_targets_gen( -@@ -69,7 +69,7 @@ enum_targets_gen( +@@ -81,7 +81,7 @@ enum_targets_gen( llvm_target_disassemblers = [ t for t in llvm_targets @@ -573,7 +154,7 @@ index 716d7f5d9645..1e3e7a8ff0e7 100644 ] enum_targets_gen( -@@ -84,7 +84,7 @@ enum_targets_gen( +@@ -96,7 +96,7 @@ enum_targets_gen( llvm_target_mcas = [ t for t in llvm_targets @@ -582,42 +163,26 @@ index 716d7f5d9645..1e3e7a8ff0e7 100644 ] enum_targets_gen( -@@ -149,8 +149,8 @@ cc_library( +@@ -111,7 +111,7 @@ enum_targets_gen( + llvm_target_exegesis = [ + t + for t in llvm_targets +- if glob(["tools/llvm-exegesis/lib/{}/CMakeLists.txt".format(t)]) ++ if glob(["tools/llvm-exegesis/lib/{}/CMakeLists.txt".format(t)], allow_empty = True) + ] + + enum_targets_gen( +@@ -169,7 +169,7 @@ cc_library( srcs = glob([ "lib/Demangle/*.cpp", "lib/Demangle/*.h", - ]), -- hdrs = glob(["include/llvm/Demangle/*.h"]), -+ ], allow_empty = True), -+ hdrs = glob(["include/llvm/Demangle/*.h"], allow_empty = True), - copts = llvm_copts, - deps = [":config"], - ) -@@ -175,11 +175,11 @@ cc_library( - name = "Support-c", - srcs = glob([ - "lib/Support/*.c", -- ]), + ], allow_empty = True), hdrs = glob([ - "include/llvm/Support/**/*.h", - "include/llvm/ADT/*.h", -- ]) + [ -+ ], allow_empty = True) + [ - "include/llvm-c/Core.h", - "include/llvm-c/DataTypes.h", - "include/llvm-c/Deprecated.h", -@@ -213,7 +213,7 @@ cc_library( - "include/llvm/Support/*.def", - "lib/Support/*.h", - "lib/Support/*.inc", -- ]), -+ ], allow_empty = True), - deps = [ - ":config", - ":Demangle", -@@ -241,16 +241,16 @@ cc_library( - "@bazel_tools//src/conditions:windows": glob([ + "include/llvm/Demangle/*.h", + "include/llvm/Demangle/*.def", +@@ -205,7 +205,7 @@ cc_library( + "@platforms//os:windows": glob([ "lib/Support/Windows/*.h", "lib/Support/Windows/*.inc", - ]), @@ -625,80 +190,25 @@ index 716d7f5d9645..1e3e7a8ff0e7 100644 "//conditions:default": glob([ "lib/Support/Unix/*.h", "lib/Support/Unix/*.inc", -- ]), -+ ], allow_empty = True), - }), - hdrs = glob([ - "include/llvm/Support/**/*.h", - "include/llvm/ADT/*.h", -- ]) + [ -+ ], allow_empty = True) + [ - "include/llvm-c/Core.h", - "include/llvm-c/DataTypes.h", - "include/llvm-c/Deprecated.h", -@@ -282,7 +282,7 @@ cc_library( - }), - textual_hdrs = glob([ - "include/llvm/Support/*.def", -- ]), -+ ], allow_empty = True), - deps = [ - ":Support-c", - ":config", -@@ -306,8 +306,8 @@ cc_library( - srcs = glob([ - "lib/FileCheck/*.cpp", - "lib/FileCheck/*.h", -- ]), -- hdrs = glob(["include/llvm/FileCheck/*.h"]), -+ ], allow_empty = True), -+ hdrs = glob(["include/llvm/FileCheck/*.h"], allow_empty = True), - copts = llvm_copts, - deps = [":Support"], - ) -@@ -317,8 +317,8 @@ cc_library( +@@ -314,7 +314,7 @@ cc_library( srcs = glob([ "lib/LineEditor/*.cpp", "lib/LineEditor/*.h", - ]), -- hdrs = glob(["include/llvm/LineEditor/*.h"]), + ], allow_empty = True), -+ hdrs = glob(["include/llvm/LineEditor/*.h"], allow_empty = True), + hdrs = glob(["include/llvm/LineEditor/*.h"]), copts = llvm_copts, deps = [ - ":Support", -@@ -331,8 +331,8 @@ cc_library( +@@ -328,7 +328,7 @@ cc_library( srcs = glob([ "lib/Option/*.cpp", "lib/Option/*.h", - ]), -- hdrs = glob(["include/llvm/Option/*.h"]), -+ ], allow_empty = True), -+ hdrs = glob(["include/llvm/Option/*.h"], allow_empty = True), - copts = llvm_copts, - deps = [ - ":Support", -@@ -345,8 +345,8 @@ cc_library( - srcs = glob([ - "lib/TableGen/*.cpp", - "lib/TableGen/*.h", -- ]), -- hdrs = glob(["include/llvm/TableGen/*.h"]), + ], allow_empty = True), -+ hdrs = glob(["include/llvm/TableGen/*.h"], allow_empty = True), + hdrs = glob(["include/llvm/Option/*.h"]), copts = llvm_copts, deps = [ - ":Support", -@@ -365,7 +365,7 @@ cc_library( - exclude = [ - "include/llvm/LinkAllPasses.h", - ], -- ) + [ -+ allow_empty = True) + [ - "include/llvm/IR/Value.def", - "include/llvm-c/Comdat.h", - "include/llvm-c/DebugInfo.h", -@@ -379,16 +379,16 @@ cc_library( +@@ -376,7 +376,7 @@ cc_library( "lib/BinaryFormat/*.cpp", "lib/BinaryFormat/*.def", "lib/BinaryFormat/*.h", @@ -706,39 +216,26 @@ index 716d7f5d9645..1e3e7a8ff0e7 100644 + ], allow_empty = True), hdrs = glob([ "include/llvm/BinaryFormat/*.h", -- ]), -+ ], allow_empty = True), - copts = llvm_copts, - includes = ["include"], - textual_hdrs = glob([ - "include/llvm/BinaryFormat/*.def", - "include/llvm/BinaryFormat/ELFRelocs/*.def", -- ]), -+ ], allow_empty = True), - deps = [ - ":Support", - ], -@@ -396,7 +396,7 @@ cc_library( - - cc_library( - name = "DebugInfo", -- hdrs = glob(["include/llvm/DebugInfo/*.h"]), -+ hdrs = glob(["include/llvm/DebugInfo/*.h"], allow_empty = True), - copts = llvm_copts, - deps = [ - ":Object", -@@ -409,8 +409,8 @@ cc_library( + ]), +@@ -408,7 +408,7 @@ cc_library( srcs = glob([ "lib/DebugInfo/MSF/*.cpp", "lib/DebugInfo/MSF/*.h", - ]), -- hdrs = glob(["include/llvm/DebugInfo/MSF/*.h"]), + ], allow_empty = True), -+ hdrs = glob(["include/llvm/DebugInfo/MSF/*.h"], allow_empty = True), + hdrs = glob(["include/llvm/DebugInfo/MSF/*.h"]), copts = llvm_copts, deps = [":Support"], - ) -@@ -420,14 +420,14 @@ cc_library( +@@ -419,7 +419,7 @@ cc_library( + srcs = glob([ + "lib/DebugInfo/BTF/*.cpp", + "lib/DebugInfo/BTF/*.h", +- ]), ++ ], allow_empty = True), + hdrs = glob(["include/llvm/DebugInfo/BTF/*.h"]) + [ + "include/llvm/DebugInfo/BTF/BTF.def", + ], +@@ -436,7 +436,7 @@ cc_library( srcs = glob([ "lib/DebugInfo/CodeView/*.cpp", "lib/DebugInfo/CodeView/*.h", @@ -746,17 +243,8 @@ index 716d7f5d9645..1e3e7a8ff0e7 100644 + ], allow_empty = True), hdrs = glob([ "include/llvm/DebugInfo/CodeView/*.h", -- ]), -+ ], allow_empty = True), - copts = llvm_copts, - textual_hdrs = glob([ - "include/llvm/DebugInfo/CodeView/*.def", -- ]), -+ ], allow_empty = True), - deps = [ - ":BinaryFormat", - ":DebugInfoMSF", -@@ -442,11 +442,11 @@ cc_library( + ]), +@@ -481,7 +481,7 @@ cc_library( "lib/DebugInfo/PDB/*.h", "lib/DebugInfo/PDB/Native/*.cpp", "lib/DebugInfo/PDB/Native/*.h", @@ -765,25 +253,7 @@ index 716d7f5d9645..1e3e7a8ff0e7 100644 hdrs = glob([ "include/llvm/DebugInfo/PDB/*.h", "include/llvm/DebugInfo/PDB/Native/*.h", -- ]), -+ ], allow_empty = True), - copts = llvm_copts, - deps = [ - ":BinaryFormat", -@@ -463,10 +463,10 @@ cc_library( - name = "Debuginfod", - srcs = glob([ - "lib/Debuginfod/*.cpp", -- ]), -+ ], allow_empty = True), - hdrs = glob([ - "include/llvm/Debuginfod/*.h", -- ]), -+ ], allow_empty = True), - copts = llvm_copts, - deps = [ - ":Support", -@@ -478,12 +478,12 @@ cc_library( +@@ -522,12 +522,12 @@ cc_library( srcs = glob([ "lib/MC/*.cpp", "lib/MC/*.h", @@ -798,182 +268,87 @@ index 716d7f5d9645..1e3e7a8ff0e7 100644 copts = llvm_copts, deps = [ ":BinaryFormat", -@@ -499,8 +499,8 @@ cc_library( +@@ -544,7 +544,7 @@ cc_library( srcs = glob([ "lib/DebugInfo/DWARF/*.cpp", "lib/DebugInfo/DWARF/*.h", - ]), -- hdrs = glob(["include/llvm/DebugInfo/DWARF/*.h"]), + ], allow_empty = True), -+ hdrs = glob(["include/llvm/DebugInfo/DWARF/*.h"], allow_empty = True), + hdrs = glob(["include/llvm/DebugInfo/DWARF/*.h"]), copts = llvm_copts, deps = [ - ":BinaryFormat", -@@ -516,8 +516,8 @@ cc_library( +@@ -562,7 +562,7 @@ cc_library( srcs = glob([ - "lib/DebugInfo/Symbolize/*.cpp", - "lib/DebugInfo/Symbolize/*.h", + "lib/DebugInfo/GSYM/*.cpp", + "lib/DebugInfo/GSYM/*.h", - ]), -- hdrs = glob(["include/llvm/DebugInfo/Symbolize/*.h"]), + ], allow_empty = True), -+ hdrs = glob(["include/llvm/DebugInfo/Symbolize/*.h"], allow_empty = True), + hdrs = glob(["include/llvm/DebugInfo/GSYM/*.h"]), copts = llvm_copts, deps = [ - ":BinaryFormat", -@@ -553,7 +553,7 @@ cc_library( - hdrs = glob([ - "utils/TableGen/*.h", - "utils/TableGen/GlobalISel/*.h", -- ]), -+ ], allow_empty = True), - copts = llvm_copts, - features = ["-header_modules"], - strip_include_prefix = "utils/TableGen", -@@ -581,7 +581,7 @@ gentbl( - td_srcs = glob([ - "include/llvm/CodeGen/*.td", - "include/llvm/IR/Intrinsics*.td", +@@ -579,7 +579,7 @@ cc_library( + srcs = glob([ + "lib/DebugInfo/Symbolize/*.cpp", + "lib/DebugInfo/Symbolize/*.h", - ]), + ], allow_empty = True), - ) - - gentbl( -@@ -592,7 +592,7 @@ gentbl( - td_srcs = glob([ - "include/llvm/CodeGen/*.td", - "include/llvm/IR/Intrinsics*.td", + hdrs = glob([ + "include/llvm/DebugInfo/Symbolize/*.h", + "include/llvm/Debuginfod/*.h", +@@ -664,7 +664,7 @@ cc_binary( + # regular dependency. + "include/llvm/MC/*.h", + "include/llvm/TargetParser/SubtargetFeature.h", - ]), + ], allow_empty = True), - ) - - # Note that the intrinsics are not currently set up so they can be pruned for -@@ -672,7 +672,7 @@ llvm_target_intrinsics_list = [ - td_srcs = glob([ - "include/llvm/CodeGen/*.td", - "include/llvm/IR/*.td", -- ]), -+ ], allow_empty = True), - ), - ] for target in llvm_target_intrinsics_list] - -@@ -692,7 +692,7 @@ cc_library( + copts = llvm_copts, + stamp = 0, + deps = [ +@@ -812,7 +812,7 @@ cc_library( srcs = glob([ "lib/Bitstream/Reader/*.cpp", "lib/Bitstream/Reader/*.h", - ]), + ], allow_empty = True), hdrs = [ + "include/llvm/Bitstream/BitCodeEnums.h", "include/llvm/Bitstream/BitCodes.h", - "include/llvm/Bitstream/BitstreamReader.h", -@@ -707,7 +707,7 @@ cc_library( +@@ -828,7 +828,7 @@ cc_library( name = "BitstreamWriter", srcs = glob([ "lib/Bitstream/Writer/*.h", - ]), + ], allow_empty = True), hdrs = [ + "include/llvm/Bitstream/BitCodeEnums.h", "include/llvm/Bitstream/BitCodes.h", - "include/llvm/Bitstream/BitstreamWriter.h", -@@ -726,13 +726,13 @@ cc_library( +@@ -848,6 +848,7 @@ cc_library( "lib/Remarks/*.h", ], exclude = ["lib/Remarks/RemarkLinker.cpp"], -- ), -+ allow_empty = True), - hdrs = glob( - [ - "include/llvm/Remarks/*.h", - ], - exclude = ["include/llvm/Remarks/RemarkLinker.h"], -- ) + [ -+ allow_empty = True) + [ - "include/llvm-c/Remarks.h", - ], - copts = llvm_copts, -@@ -767,7 +767,7 @@ cc_library( - srcs = glob([ - "lib/IR/*.cpp", - "lib/IR/*.h", -- ]), -+ ], allow_empty = True), ++ allow_empty = True, + ), hdrs = glob( [ - "include/llvm/*.h", -@@ -776,12 +776,12 @@ cc_library( - exclude = [ - "include/llvm/LinkAllPasses.h", - ], -- ) + [ -+ allow_empty = True) + [ - "include/llvm-c/Comdat.h", - "include/llvm-c/DebugInfo.h", - ] + [":llvm_intrinsics_headers"], - copts = llvm_copts, -- textual_hdrs = glob(["include/llvm/IR/*.def"]), -+ textual_hdrs = glob(["include/llvm/IR/*.def"], allow_empty = True), - deps = [ - ":BinaryFormat", - ":Remarks", -@@ -798,7 +798,7 @@ cc_library( - srcs = glob([ - "lib/Bitcode/Reader/*.cpp", - "lib/Bitcode/Reader/*.h", -- ]), -+ ], allow_empty = True), - hdrs = [ - "include/llvm-c/BitReader.h", - "include/llvm/Bitcode/BitcodeAnalyzer.h", -@@ -820,8 +820,8 @@ cc_library( +@@ -947,7 +948,7 @@ cc_library( srcs = glob([ "lib/MC/MCParser/*.cpp", "lib/MC/MCParser/*.h", - ]), -- hdrs = glob(["include/llvm/MC/MCParser/*.h"]), -+ ], allow_empty = True), -+ hdrs = glob(["include/llvm/MC/MCParser/*.h"], allow_empty = True), - copts = llvm_copts, - deps = [ - ":BinaryFormat", -@@ -835,12 +835,12 @@ cc_library( - name = "TextAPI", - srcs = glob([ - "lib/TextAPI/**/*.cpp", -- ]), -+ ], allow_empty = True), - hdrs = glob([ - "include/llvm/TextAPI/**/*.h", - "include/llvm/TextAPI/**/*.def", - "lib/TextAPI/**/*.h", -- ]), + ], allow_empty = True), + hdrs = glob(["include/llvm/MC/MCParser/*.h"]), copts = llvm_copts, deps = [ - ":BinaryFormat", -@@ -853,10 +853,10 @@ cc_library( - srcs = glob([ - "lib/Object/*.cpp", - "lib/Object/*.h", -- ]), -+ ], allow_empty = True), - hdrs = glob([ - "include/llvm/Object/*.h", -- ]) + [ -+ ], allow_empty = True) + [ - "include/llvm-c/Object.h", - ], - copts = llvm_copts, -@@ -877,8 +877,8 @@ cc_library( +@@ -1032,7 +1033,7 @@ cc_library( srcs = glob([ "lib/ObjectYAML/*.cpp", "lib/ObjectYAML/*.h", - ]), -- hdrs = glob(["include/llvm/ObjectYAML/*.h"]), + ], allow_empty = True), -+ hdrs = glob(["include/llvm/ObjectYAML/*.h"], allow_empty = True), + hdrs = glob(["include/llvm/ObjectYAML/*.h"]), copts = llvm_copts, deps = [ - ":BinaryFormat", -@@ -893,11 +893,11 @@ cc_library( +@@ -1050,7 +1051,7 @@ cc_library( srcs = glob([ "lib/ProfileData/*.cpp", "lib/ProfileData/*.h", @@ -982,56 +357,24 @@ index 716d7f5d9645..1e3e7a8ff0e7 100644 hdrs = glob([ "include/llvm/ProfileData/*.h", "include/llvm/ProfileData/*.inc", -- ]), -+ ], allow_empty = True), - copts = llvm_copts, - deps = [ - ":Core", -@@ -912,8 +912,8 @@ cc_library( +@@ -1074,7 +1075,7 @@ cc_library( srcs = glob([ "lib/ProfileData/Coverage/*.cpp", "lib/ProfileData/Coverage/*.h", - ]), -- hdrs = glob(["include/llvm/ProfileData/Coverage/*.h"]), + ], allow_empty = True), -+ hdrs = glob(["include/llvm/ProfileData/Coverage/*.h"], allow_empty = True), + hdrs = glob(["include/llvm/ProfileData/Coverage/*.h"]), copts = llvm_copts, deps = [ - ":Object", -@@ -930,20 +930,20 @@ cc_library( +@@ -1093,6 +1094,7 @@ cc_library( "lib/Analysis/*.h", "lib/Analysis/*.def", ], -- ), -+ allow_empty = True), ++ allow_empty = True, + ), hdrs = glob( [ - "include/llvm/Analysis/*.h", - "include/llvm/Analysis/Utils/*.h", - ], -- ) + [ -+ allow_empty = True) + [ - "include/llvm-c/Analysis.h", - "include/llvm-c/Initialization.h", - ], - copts = llvm_copts, - textual_hdrs = glob([ - "include/llvm/Analysis/*.def", -- ]), -+ ], allow_empty = True), - deps = [ - ":BinaryFormat", - ":Core", -@@ -959,7 +959,7 @@ cc_library( - srcs = glob([ - "lib/Bitcode/Writer/*.cpp", - "lib/Bitcode/Writer/*.h", -- ]), -+ ], allow_empty = True), - hdrs = [ - "include/llvm-c/BitWriter.h", - "include/llvm/Bitcode/BitcodeCommon.h", -@@ -984,10 +984,10 @@ cc_library( +@@ -1149,7 +1151,7 @@ cc_library( srcs = glob([ "lib/Target/*.cpp", "lib/Target/*.h", @@ -1039,122 +382,63 @@ index 716d7f5d9645..1e3e7a8ff0e7 100644 + ], allow_empty = True), hdrs = glob([ "include/llvm/Target/*.h", -- ]) + [ -+ ], allow_empty = True) + [ - "include/llvm-c/Target.h", - "include/llvm-c/TargetMachine.h", - ], -@@ -1007,8 +1007,8 @@ cc_library( + ]) + [ +@@ -1185,15 +1187,15 @@ cc_library( + srcs = glob([ + "lib/TargetParser/*.cpp", + "lib/TargetParser/*.h", +- ]) + select({ ++ ], allow_empty = True) + select({ + "@platforms//os:windows": glob([ + "lib/TargetParser/Windows/*.h", + "lib/TargetParser/Windows/*.inc", +- ]), ++ ], allow_empty = True), + "//conditions:default": glob([ + "lib/TargetParser/Unix/*.h", + "lib/TargetParser/Unix/*.inc", +- ]), ++ ], allow_empty = True), + }), + hdrs = glob([ + "include/llvm/TargetParser/*.h", +@@ -1216,7 +1218,7 @@ cc_library( srcs = glob([ "lib/DWP/*.cpp", "lib/DWP/*.h", - ]), -- hdrs = glob(["include/llvm/DWP/*.h"]), + ], allow_empty = True), -+ hdrs = glob(["include/llvm/DWP/*.h"], allow_empty = True), + hdrs = glob(["include/llvm/DWP/*.h"]), copts = llvm_copts, deps = [ - ":DebugInfoDWARF", -@@ -1024,8 +1024,8 @@ cc_library( +@@ -1233,7 +1235,7 @@ cc_library( srcs = glob([ "lib/Transforms/Utils/*.cpp", "lib/Transforms/Utils/*.h", - ]), -- hdrs = glob(["include/llvm/Transforms/Utils/*.h"]) + [ + ], allow_empty = True), -+ hdrs = glob(["include/llvm/Transforms/Utils/*.h"], allow_empty = True) + [ + hdrs = glob(["include/llvm/Transforms/Utils/*.h"]) + [ "include/llvm/Transforms/Utils.h", - "include/llvm-c/Transforms/Utils.h", - ], -@@ -1053,7 +1053,7 @@ gentbl( - td_srcs = glob([ - "include/llvm/CodeGen/*.td", - "include/llvm/IR/Intrinsics*.td", -- ]) + [ -+ ], allow_empty = True) + [ - "lib/Target/AMDGPU/InstCombineTables.td", - "include/llvm/TableGen/SearchableTable.td", - ], -@@ -1064,8 +1064,8 @@ cc_library( - srcs = glob([ - "lib/Transforms/InstCombine/*.cpp", - "lib/Transforms/InstCombine/*.h", -- ]), -- hdrs = glob(["include/llvm/Transforms/InstCombine/*.h"]) + [ -+ ], allow_empty = True), -+ hdrs = glob(["include/llvm/Transforms/InstCombine/*.h"], allow_empty = True) + [ - "include/llvm-c/Transforms/InstCombine.h", - ], - copts = llvm_copts, -@@ -1085,7 +1085,7 @@ cc_library( - srcs = glob([ - "lib/Transforms/AggressiveInstCombine/*.cpp", - "lib/Transforms/AggressiveInstCombine/*.h", -- ]), -+ ], allow_empty = True), - hdrs = [ - "include/llvm-c/Transforms/AggressiveInstCombine.h", - "include/llvm/Transforms/AggressiveInstCombine/AggressiveInstCombine.h", -@@ -1105,8 +1105,8 @@ cc_library( - "lib/Transforms/Instrumentation/*.cpp", - "lib/Transforms/Instrumentation/*.h", - "lib/Transforms/Instrumentation/*.inc", -- ]), -- hdrs = glob(["include/llvm/Transforms/Instrumentation/*.h"]) + [ -+ ], allow_empty = True), -+ hdrs = glob(["include/llvm/Transforms/Instrumentation/*.h"], allow_empty = True) + [ - "include/llvm/Transforms/Instrumentation.h", ], - copts = llvm_copts, -@@ -1127,7 +1127,7 @@ cc_library( - srcs = glob([ - "lib/Transforms/ObjCARC/*.cpp", - "lib/Transforms/ObjCARC/*.h", -- ]), -+ ], allow_empty = True), - hdrs = ["include/llvm/Transforms/ObjCARC.h"], - copts = llvm_copts, - deps = [ -@@ -1145,8 +1145,8 @@ cc_library( +@@ -1354,7 +1356,7 @@ cc_library( srcs = glob([ "lib/Transforms/Scalar/*.cpp", "lib/Transforms/Scalar/*.h", - ]), -- hdrs = glob(["include/llvm/Transforms/Scalar/*.h"]) + [ + ], allow_empty = True), -+ hdrs = glob(["include/llvm/Transforms/Scalar/*.h"], allow_empty = True) + [ - "include/llvm-c/Transforms/Scalar.h", + hdrs = glob(["include/llvm/Transforms/Scalar/*.h"]) + [ "include/llvm/Transforms/Scalar.h", ], -@@ -1169,10 +1169,10 @@ cc_library( - srcs = glob([ - "lib/Transforms/Vectorize/*.cpp", - "lib/Transforms/Vectorize/*.h", -- ]), -+ ], allow_empty = True), - hdrs = glob([ - "include/llvm/Transforms/Vectorize/*.h", -- ]) + [ -+ ], allow_empty = True) + [ - "include/llvm-c/Transforms/Vectorize.h", - "include/llvm/Transforms/Vectorize.h", - ], -@@ -1192,7 +1192,7 @@ filegroup( +@@ -1399,7 +1401,7 @@ cc_library( + name = "FrontendDebug", srcs = glob([ - "include/llvm/Frontend/OpenMP/*.td", - "include/llvm/Frontend/Directive/*.td", -- ]), -+ ], allow_empty = True), - ) - - gentbl( -@@ -1221,19 +1221,19 @@ cc_library( - name = "FrontendOpenMP", - srcs = glob([ - "lib/Frontend/OpenMP/*.cpp", + "lib/Frontend/Debug/*.cpp", - ]), + ], allow_empty = True), hdrs = glob([ + "include/llvm/Frontend/Debug/*.h", + ]), +@@ -1463,7 +1465,7 @@ cc_library( "include/llvm/Frontend/OpenMP/*.h", "include/llvm/Frontend/OpenMP/OMP/*.h", "include/llvm/Frontend/*.h", @@ -1163,30 +447,7 @@ index 716d7f5d9645..1e3e7a8ff0e7 100644 "include/llvm/Frontend/OpenMP/OMP.h.inc", "include/llvm/Frontend/OpenMP/OMP.inc", ], - copts = llvm_copts, - textual_hdrs = glob([ - "include/llvm/Frontend/OpenMP/*.def", -- ]), -+ ], allow_empty = True), - deps = [ - ":Analysis", - ":Core", -@@ -1248,7 +1248,7 @@ filegroup( - srcs = glob([ - "include/llvm/Frontend/OpenACC/*.td", - "include/llvm/Frontend/Directive/*.td", -- ]), -+ ], allow_empty = True), - ) - - gentbl( -@@ -1277,12 +1277,12 @@ cc_library( - name = "FrontendOpenACC", - srcs = glob([ - "lib/Frontend/OpenACC/*.cpp", -- ]) + [ -+ ], allow_empty = True) + [ - "include/llvm/Frontend/OpenACC/ACC.inc", +@@ -1523,7 +1525,7 @@ cc_library( ], hdrs = glob([ "include/llvm/Frontend/OpenACC/*.h", @@ -1195,44 +456,34 @@ index 716d7f5d9645..1e3e7a8ff0e7 100644 copts = llvm_copts, deps = [ ":Analysis", -@@ -1297,8 +1297,8 @@ cc_library( +@@ -1538,7 +1540,7 @@ cc_library( srcs = glob([ "lib/AsmParser/*.cpp", "lib/AsmParser/*.h", - ]), -- hdrs = glob(["include/llvm/AsmParser/*.h"]), + ], allow_empty = True), -+ hdrs = glob(["include/llvm/AsmParser/*.h"], allow_empty = True), + hdrs = glob(["include/llvm/AsmParser/*.h"]), copts = llvm_copts, deps = [ - ":BinaryFormat", -@@ -1312,10 +1312,10 @@ cc_library( +@@ -1554,7 +1556,7 @@ cc_library( srcs = glob([ - "lib/IRReader/*.cpp", - "lib/IRReader/*.h", + "lib/IRPrinter/*.cpp", + "lib/IRPrinter/*.h", - ]), + ], allow_empty = True), hdrs = glob([ - "include/llvm/IRReader/*.h", -- ]) + [ -+ ], allow_empty = True) + [ - "include/llvm-c/IRReader.h", - ], - copts = llvm_copts, -@@ -1333,10 +1333,10 @@ cc_library( + "include/llvm/IRPrinter/*.h", + ]), +@@ -1571,7 +1573,7 @@ cc_library( srcs = glob([ - "lib/Linker/*.cpp", - "lib/Linker/*.h", + "lib/IRReader/*.cpp", + "lib/IRReader/*.h", - ]), + ], allow_empty = True), hdrs = glob([ - "include/llvm/Linker/*.h", -- ]) + [ -+ ], allow_empty = True) + [ - "include/llvm-c/Linker.h", - ], - copts = llvm_copts, -@@ -1353,10 +1353,10 @@ cc_library( + "include/llvm/IRReader/*.h", + ]) + [ +@@ -1614,7 +1616,7 @@ cc_library( srcs = glob([ "lib/Transforms/IPO/*.cpp", "lib/Transforms/IPO/*.h", @@ -1240,12 +491,8 @@ index 716d7f5d9645..1e3e7a8ff0e7 100644 + ], allow_empty = True), hdrs = glob([ "include/llvm/Transforms/IPO/*.h", -- ]) + [ -+ ], allow_empty = True) + [ - "include/llvm-c/Transforms/IPO.h", - "include/llvm-c/Transforms/PassManagerBuilder.h", - "include/llvm/Transforms/IPO.h", -@@ -1391,7 +1391,7 @@ cc_library( + ]) + [ +@@ -1652,7 +1654,7 @@ cc_library( srcs = glob([ "lib/Transforms/CFGuard/*.cpp", "lib/Transforms/CFGuard/*.h", @@ -1254,88 +501,16 @@ index 716d7f5d9645..1e3e7a8ff0e7 100644 hdrs = ["include/llvm/Transforms/CFGuard.h"], copts = llvm_copts, deps = [ -@@ -1405,7 +1405,7 @@ cc_library( - srcs = glob([ - "lib/Transforms/Coroutines/*.cpp", - "lib/Transforms/Coroutines/*.h", -- ]), -+ ], allow_empty = True), - hdrs = [ - "include/llvm-c/Transforms/Coroutines.h", - "include/llvm/Transforms/Coroutines.h", -@@ -1445,7 +1445,7 @@ cc_library( - cc_library( - name = "asm_printer_defs", - copts = llvm_copts, -- textual_hdrs = glob(["lib/CodeGen/AsmPrinter/*.def"]), -+ textual_hdrs = glob(["lib/CodeGen/AsmPrinter/*.def"], allow_empty = True), - ) - - cc_library( -@@ -1457,19 +1457,19 @@ cc_library( - "lib/CodeGen/SelectionDAG/*.cpp", - "lib/CodeGen/SelectionDAG/*.h", - ], -- ), -+ allow_empty = True), - hdrs = [ - "include/llvm/LinkAllPasses.h", - ] + glob( - [ - "include/llvm/CodeGen/**/*.h", - ], -- ), -+ allow_empty = True), - copts = llvm_copts, +@@ -1744,7 +1746,7 @@ cc_library( textual_hdrs = glob([ "include/llvm/CodeGen/**/*.def", "include/llvm/CodeGen/**/*.inc", - ]), + ], allow_empty = True), deps = [ + ":AggressiveInstCombine", ":Analysis", - ":AsmParser", -@@ -1498,10 +1498,10 @@ cc_library( - srcs = glob([ - "lib/MC/MCDisassembler/*.cpp", - "lib/MC/MCDisassembler/*.h", -- ]), -+ ], allow_empty = True), - hdrs = glob([ - "include/llvm/MC/MCDisassembler/*.h", -- ]) + [ -+ ], allow_empty = True) + [ - "include/llvm-c/Disassembler.h", - ], - copts = llvm_copts, -@@ -1818,7 +1818,7 @@ filegroup( - "include/llvm/TableGen/*.td", - "include/llvm/Target/*.td", - "include/llvm/Target/GlobalISel/*.td", -- ]), -+ ], allow_empty = True), - ) - - gentbl( -@@ -1836,7 +1836,7 @@ gentbl( - ":common_target_td_sources", - ] + glob([ - "lib/Target/AMDGPU/*.td", -- ]), -+ ], allow_empty = True), - ) - - gentbl( -@@ -1858,7 +1858,7 @@ gentbl( - ":common_target_td_sources", - ] + glob([ - "lib/Target/AMDGPU/*.td", -- ]), -+ ], allow_empty = True), - ) - - [[ -@@ -1880,7 +1880,7 @@ gentbl( +@@ -2200,7 +2202,7 @@ gentbl( ] + glob([ "lib/Target/" + target["name"] + "/*.td", "lib/Target/" + target["name"] + "/GISel/*.td", @@ -1344,7 +519,7 @@ index 716d7f5d9645..1e3e7a8ff0e7 100644 deps = target.get("tbl_deps", []), )], [cc_library( -@@ -1914,7 +1914,7 @@ gentbl( +@@ -2235,7 +2237,7 @@ gentbl( # library. This mixture is likely incompatible with header modules. "lib/Target/" + target["name"] + "/MCTargetDesc/*.h", "lib/Target/" + target["name"] + "/Utils/*.h", @@ -1353,16 +528,16 @@ index 716d7f5d9645..1e3e7a8ff0e7 100644 hdrs = glob([ "lib/Target/" + target["name"] + "/MCTargetDesc/*.h", "lib/Target/" + target["name"] + "/Utils/*.h", -@@ -1938,7 +1938,7 @@ gentbl( - # distinction between these two. +@@ -2260,7 +2262,7 @@ gentbl( "lib/Target/" + target["name"] + "/*.def", "lib/Target/" + target["name"] + "/*.inc", + "lib/Target/" + target["name"] + "/MCTargetDesc/*.def", - ]), + ], allow_empty = True), copts = llvm_copts, features = [ "-parse_headers", -@@ -1967,14 +1967,14 @@ gentbl( +@@ -2292,7 +2294,7 @@ gentbl( "lib/Target/" + target["name"] + "/GISel/*.h", "lib/Target/" + target["name"] + "/*.cpp", "lib/Target/" + target["name"] + "/*.h", @@ -1370,7 +545,8 @@ index 716d7f5d9645..1e3e7a8ff0e7 100644 + ], allow_empty = True), hdrs = ["lib/Target/" + target["name"] + "/" + target["short_name"] + ".h"], copts = llvm_copts, - strip_include_prefix = "lib/Target/" + target["name"], + features = ["-layering_check"], +@@ -2300,7 +2302,7 @@ gentbl( textual_hdrs = glob([ "lib/Target/" + target["name"] + "/*.def", "lib/Target/" + target["name"] + "/*.inc", @@ -1379,7 +555,7 @@ index 716d7f5d9645..1e3e7a8ff0e7 100644 deps = [ ":Analysis", ":BinaryFormat", -@@ -2001,7 +2001,7 @@ gentbl( +@@ -2328,7 +2330,7 @@ gentbl( srcs = glob([ "lib/Target/" + target["name"] + "/AsmParser/*.cpp", "lib/Target/" + target["name"] + "/AsmParser/*.h", @@ -1388,7 +564,7 @@ index 716d7f5d9645..1e3e7a8ff0e7 100644 copts = llvm_copts, deps = [ ":BinaryFormat", -@@ -2031,7 +2031,7 @@ gentbl( +@@ -2361,7 +2363,7 @@ gentbl( # distinction between these two. hdrs = glob([ "lib/Target/" + target["name"] + "/Disassembler/*.h", @@ -1397,25 +573,25 @@ index 716d7f5d9645..1e3e7a8ff0e7 100644 features = [ "-parse_headers", "-header_modules", -@@ -2044,7 +2044,7 @@ gentbl( +@@ -2374,7 +2376,7 @@ gentbl( "lib/Target/" + target["name"] + "/Disassembler/*.cpp", "lib/Target/" + target["name"] + "/Disassembler/*.c", "lib/Target/" + target["name"] + "/Disassembler/*.h", - ]), + ], allow_empty = True), copts = llvm_copts, + features = ["-layering_check"], deps = [ - ":CodeGen", -@@ -2065,7 +2065,7 @@ gentbl( +@@ -2396,7 +2398,7 @@ gentbl( "lib/Target/" + target["name"] + "/MCA/*.cpp", "lib/Target/" + target["name"] + "/MCA/*.c", "lib/Target/" + target["name"] + "/MCA/*.h", - ]), + ], allow_empty = True), copts = llvm_copts, + features = ["-layering_check"], deps = [ - ":MC", -@@ -2126,10 +2126,10 @@ cc_library( +@@ -2459,10 +2461,10 @@ cc_library( srcs = glob([ "lib/Analysis/ML/*.cpp", "lib/Analysis/ML/*.h", @@ -1428,18 +604,16 @@ index 716d7f5d9645..1e3e7a8ff0e7 100644 copts = llvm_copts, deps = [ ":Analysis", -@@ -2143,8 +2143,8 @@ cc_library( +@@ -2476,7 +2478,7 @@ cc_library( srcs = glob([ "lib/Passes/*.cpp", "lib/Passes/*.h", - ]), -- hdrs = glob(["include/llvm/Passes/*.h"]) + ["include/llvm-c/Transforms/PassBuilder.h"], + ], allow_empty = True), -+ hdrs = glob(["include/llvm/Passes/*.h"], allow_empty = True) + ["include/llvm-c/Transforms/PassBuilder.h"], + hdrs = glob(["include/llvm/Passes/*.h"]) + ["include/llvm-c/Transforms/PassBuilder.h"], copts = llvm_copts, deps = [ - ":Analysis", -@@ -2166,11 +2166,11 @@ cc_library( +@@ -2507,7 +2509,7 @@ cc_library( srcs = glob([ "lib/LTO/*.cpp", "lib/LTO/*.h", @@ -1448,12 +622,7 @@ index 716d7f5d9645..1e3e7a8ff0e7 100644 hdrs = glob([ "include/llvm/LTO/*.h", "include/llvm/LTO/legacy/*.h", -- ]) + [ -+ ], allow_empty = True) + [ - "include/llvm-c/lto.h", - ], - copts = llvm_copts, -@@ -2203,7 +2203,7 @@ cc_library( +@@ -2551,7 +2553,7 @@ cc_library( "lib/ExecutionEngine/RuntimeDyld/*.h", "lib/ExecutionEngine/RuntimeDyld/Targets/*.cpp", "lib/ExecutionEngine/RuntimeDyld/Targets/*.h", @@ -1462,49 +631,7 @@ index 716d7f5d9645..1e3e7a8ff0e7 100644 hdrs = glob( [ "include/llvm/ExecutionEngine/*.h", -@@ -2212,7 +2212,7 @@ cc_library( - "include/llvm/ExecutionEngine/MCJIT*.h", - "include/llvm/ExecutionEngine/OProfileWrapper.h", - ], -- ) + [ -+ allow_empty = True) + [ - "include/llvm-c/ExecutionEngine.h", - ], - copts = llvm_copts, -@@ -2237,7 +2237,7 @@ cc_library( - srcs = glob([ - "lib/ExecutionEngine/Interpreter/*.cpp", - "lib/ExecutionEngine/Interpreter/*.h", -- ]), -+ ], allow_empty = True), - hdrs = ["include/llvm/ExecutionEngine/Interpreter.h"], - copts = llvm_copts, - deps = [ -@@ -2255,10 +2255,10 @@ cc_library( - srcs = glob([ - "lib/ExecutionEngine/JITLink/*.cpp", - "lib/ExecutionEngine/JITLink/*.h", -- ]), -+ ], allow_empty = True), - hdrs = glob([ - "include/llvm/ExecutionEngine/JITLink/*.h", -- ]), -+ ], allow_empty = True), - copts = llvm_copts, - deps = [ - ":ExecutionEngine", -@@ -2274,8 +2274,8 @@ cc_library( - srcs = glob([ - "lib/ExecutionEngine/MCJIT/*.cpp", - "lib/ExecutionEngine/MCJIT/*.h", -- ]), -- hdrs = glob(["include/llvm/ExecutionEngine/MCJIT*.h"]), -+ ], allow_empty = True), -+ hdrs = glob(["include/llvm/ExecutionEngine/MCJIT*.h"], allow_empty = True), - copts = llvm_copts, - deps = [ - ":CodeGen", -@@ -2294,11 +2294,11 @@ cc_library( +@@ -2660,11 +2662,11 @@ cc_library( srcs = glob([ "lib/ExecutionEngine/Orc/*.cpp", "lib/ExecutionEngine/Orc/*.h", @@ -1518,44 +645,16 @@ index 716d7f5d9645..1e3e7a8ff0e7 100644 "include/llvm-c/LLJIT.h", "include/llvm-c/Orc.h", "include/llvm-c/OrcEE.h", -@@ -2325,10 +2325,10 @@ cc_library( - name = "OrcShared", - srcs = glob([ - "lib/ExecutionEngine/Orc/Shared/*.cpp", -- ]), -+ ], allow_empty = True), - hdrs = glob([ - "include/llvm/ExecutionEngine/Orc/Shared/*.h", -- ]), -+ ], allow_empty = True), - copts = llvm_copts, - deps = [ - ":BinaryFormat", -@@ -2350,10 +2350,10 @@ cc_library( - srcs = glob([ - "lib/ExecutionEngine/Orc/TargetProcess/*.cpp", - "lib/ExecutionEngine/Orc/TargetProcess/*.h", -- ]), -+ ], allow_empty = True), - hdrs = glob([ - "include/llvm/ExecutionEngine/Orc/TargetProcess/*.h", -- ]), -+ ], allow_empty = True), - copts = llvm_copts, - deps = [ - ":BinaryFormat", -@@ -2376,8 +2376,8 @@ cc_library( +@@ -2767,7 +2769,7 @@ cc_library( srcs = glob([ "lib/DWARFLinker/*.cpp", "lib/DWARFLinker/*.h", - ]), -- hdrs = glob(["include/llvm/DWARFLinker/*.h"]), + ], allow_empty = True), -+ hdrs = glob(["include/llvm/DWARFLinker/*.h"], allow_empty = True), + hdrs = glob(["include/llvm/DWARFLinker/*.h"]), copts = llvm_copts, deps = [ - ":CodeGen", -@@ -2442,10 +2442,10 @@ cc_library( +@@ -2860,7 +2862,7 @@ cc_library( srcs = glob([ "lib/InterfaceStub/*.cpp", "lib/InterfaceStub/*.h", @@ -1563,25 +662,8 @@ index 716d7f5d9645..1e3e7a8ff0e7 100644 + ], allow_empty = True), hdrs = glob([ "include/llvm/InterfaceStub/*.h", -- ]), -+ ], allow_empty = True), - copts = llvm_copts, - deps = [ - ":Object", -@@ -2458,10 +2458,10 @@ cc_library( - name = "WindowsManifest", - srcs = glob([ - "lib/WindowsManifest/*.cpp", -- ]), -+ ], allow_empty = True), - hdrs = glob([ - "include/llvm/WindowsManifest/*.h", -- ]), -+ ], allow_empty = True), - copts = llvm_copts, - linkopts = [ - # Libxml2 is required to process Windows manifests. Without this, -@@ -2499,10 +2499,10 @@ cc_library( + ]), +@@ -2911,7 +2913,7 @@ cc_library( srcs = glob([ "lib/MCA/**/*.cpp", "lib/MCA/**/*.h", @@ -1589,32 +671,35 @@ index 716d7f5d9645..1e3e7a8ff0e7 100644 + ], allow_empty = True), hdrs = glob([ "include/llvm/MCA/**/*.h", + ]), +@@ -2929,7 +2931,7 @@ cc_library( + hdrs = glob([ + "tools/llvm-mca/*.h", + "tools/llvm-mca/Views/*.h", - ]), + ], allow_empty = True), - copts = llvm_copts, - deps = [ - ":MC", -@@ -2526,8 +2526,8 @@ cc_library( + strip_include_prefix = "tools/llvm-mca", + ) + +@@ -2938,7 +2940,7 @@ cc_library( srcs = glob([ "lib/XRay/*.cpp", "lib/XRay/*.h", - ]), -- hdrs = glob(["include/llvm/XRay/*.h"]), + ], allow_empty = True), -+ hdrs = glob(["include/llvm/XRay/*.h"], allow_empty = True), + hdrs = glob(["include/llvm/XRay/*.h"]), copts = llvm_copts, deps = [ - ":Object", -@@ -2594,7 +2594,7 @@ cc_binary( - srcs = glob([ - "tools/dsymutil/*.cpp", - "tools/dsymutil/*.h", +@@ -3008,7 +3010,7 @@ cc_library( + ] + [ + "tools/llvm-exegesis/lib/{}/*.h".format(t) + for t in llvm_target_exegesis - ]), + ], allow_empty = True), + hdrs = glob(["tools/llvm-exegesis/lib/*.h"]), copts = llvm_copts, - stamp = 0, - deps = [ -@@ -2620,7 +2620,7 @@ cc_binary( + features = [ +@@ -3095,7 +3097,7 @@ cc_binary( srcs = glob([ "tools/llc/*.cpp", "tools/llc/*.h", @@ -1623,25 +708,16 @@ index 716d7f5d9645..1e3e7a8ff0e7 100644 copts = llvm_copts, stamp = 0, deps = [ -@@ -2644,7 +2644,7 @@ cc_binary( - srcs = glob([ - "tools/lli/*.cpp", - "tools/lli/*.h", -- ]), -+ ], allow_empty = True), - copts = llvm_copts, - # ll scripts rely on symbols from dependent - # libraries being resolvable. -@@ -2689,7 +2689,7 @@ cc_binary( +@@ -3180,7 +3182,7 @@ cc_binary( srcs = glob([ "tools/llvm-ar/*.cpp", "tools/llvm-ar/*.h", -- ]), -+ ], allow_empty = True), +- ]) + ["llvm-ar-driver.cpp"], ++ ], allow_empty = True) + ["llvm-ar-driver.cpp"], copts = llvm_copts, stamp = 0, deps = [ -@@ -2725,7 +2725,7 @@ cc_binary( +@@ -3218,7 +3220,7 @@ cc_binary( srcs = glob([ "tools/llvm-as/*.cpp", "tools/llvm-as/*.h", @@ -1650,7 +726,7 @@ index 716d7f5d9645..1e3e7a8ff0e7 100644 copts = llvm_copts, stamp = 0, deps = [ -@@ -2742,7 +2742,7 @@ cc_binary( +@@ -3235,7 +3237,7 @@ cc_binary( srcs = glob([ "tools/llvm-bcanalyzer/*.cpp", "tools/llvm-bcanalyzer/*.h", @@ -1659,34 +735,7 @@ index 716d7f5d9645..1e3e7a8ff0e7 100644 copts = llvm_copts, stamp = 0, deps = [ -@@ -2755,7 +2755,7 @@ cc_binary( - name = "llvm-cat", - srcs = glob([ - "tools/llvm-cat/*.cpp", -- ]), -+ ], allow_empty = True), - copts = llvm_copts, - stamp = 0, - deps = [ -@@ -2773,7 +2773,7 @@ cc_binary( - "tools/llvm-cfi-verify/*.cpp", - "tools/llvm-cfi-verify/lib/*.cpp", - "tools/llvm-cfi-verify/lib/*.h", -- ]), -+ ], allow_empty = True), - copts = llvm_copts, - stamp = 0, - deps = [ -@@ -2796,7 +2796,7 @@ cc_binary( - srcs = glob([ - "tools/llvm-cov/*.cpp", - "tools/llvm-cov/*.h", -- ]), -+ ], allow_empty = True), - copts = llvm_copts, - stamp = 0, - deps = [ -@@ -2825,7 +2825,7 @@ cc_binary( +@@ -3322,7 +3324,7 @@ cc_binary( srcs = glob([ "tools/llvm-cvtres/*.cpp", "tools/llvm-cvtres/*.h", @@ -1695,16 +744,7 @@ index 716d7f5d9645..1e3e7a8ff0e7 100644 copts = llvm_copts, stamp = 0, deps = [ -@@ -2841,7 +2841,7 @@ cc_binary( - srcs = glob([ - "tools/llvm-cxxdump/*.cpp", - "tools/llvm-cxxdump/*.h", -- ]), -+ ], allow_empty = True), - copts = llvm_copts, - stamp = 0, - deps = [ -@@ -2857,7 +2857,7 @@ cc_binary( +@@ -3356,7 +3358,7 @@ cc_binary( srcs = glob([ "tools/llvm-cxxmap/*.cpp", "tools/llvm-cxxmap/*.h", @@ -1713,34 +753,34 @@ index 716d7f5d9645..1e3e7a8ff0e7 100644 copts = llvm_copts, stamp = 0, deps = [ -@@ -2882,7 +2882,7 @@ cc_binary( +@@ -3391,7 +3393,7 @@ cc_binary( srcs = glob([ "tools/llvm-cxxfilt/*.cpp", "tools/llvm-cxxfilt/*.h", -- ]), -+ ], allow_empty = True), +- ]) + ["llvm-cxxfilt-driver.cpp"], ++ ], allow_empty = True) + ["llvm-cxxfilt-driver.cpp"], copts = llvm_copts, stamp = 0, deps = [ -@@ -2898,7 +2898,7 @@ cc_binary( +@@ -3424,7 +3426,7 @@ cc_binary( srcs = glob([ - "tools/llvm-dis/*.cpp", - "tools/llvm-dis/*.h", + "tools/llvm-debuginfod-find/*.cpp", + "tools/llvm-debuginfod-find/*.h", - ]), + ], allow_empty = True), copts = llvm_copts, stamp = 0, deps = [ -@@ -2914,7 +2914,7 @@ cc_binary( +@@ -3441,7 +3443,7 @@ cc_binary( srcs = glob([ - "tools/llvm-dwarfdump/*.cpp", - "tools/llvm-dwarfdump/*.h", + "tools/llvm-dis/*.cpp", + "tools/llvm-dis/*.h", - ]), + ], allow_empty = True), copts = llvm_copts, stamp = 0, deps = [ -@@ -2933,7 +2933,7 @@ cc_binary( +@@ -3527,7 +3529,7 @@ cc_binary( srcs = glob([ "tools/llvm-dwp/*.cpp", "tools/llvm-dwp/*.h", @@ -1749,7 +789,7 @@ index 716d7f5d9645..1e3e7a8ff0e7 100644 copts = llvm_copts, stamp = 0, deps = [ -@@ -2974,7 +2974,7 @@ cc_binary( +@@ -3567,7 +3569,7 @@ cc_binary( srcs = glob([ "tools/llvm-extract/*.cpp", "tools/llvm-extract/*.h", @@ -1758,34 +798,16 @@ index 716d7f5d9645..1e3e7a8ff0e7 100644 copts = llvm_copts, stamp = 0, deps = [ -@@ -2993,7 +2993,7 @@ cc_binary( - srcs = glob([ - "tools/llvm-ifs/*.cpp", - "tools/llvm-ifs/*.h", -- ]), -+ ], allow_empty = True), - copts = llvm_copts, - stamp = 0, - deps = [ -@@ -3009,7 +3009,7 @@ cc_binary( - srcs = glob([ - "tools/llvm-jitlink/*.cpp", - "tools/llvm-jitlink/*.h", -- ]), -+ ], allow_empty = True), - copts = llvm_copts, - # Make symbols from the standard library dynamically resolvable. - linkopts = select({ -@@ -3048,7 +3048,7 @@ cc_binary( +@@ -3609,7 +3611,7 @@ cc_binary( srcs = glob([ - "tools/llvm-libtool-darwin/*.cpp", - "tools/llvm-libtool-darwin/*.h", -- ]), -+ ], allow_empty = True), + "tools/llvm-gsymutil/*.cpp", + "tools/llvm-gsymutil/*.h", +- ]) + ["llvm-gsymutil-driver.cpp"], ++ ], allow_empty = True) + ["llvm-gsymutil-driver.cpp"], copts = llvm_copts, stamp = 0, deps = [ -@@ -3063,7 +3063,7 @@ cc_binary( +@@ -3751,7 +3753,7 @@ cc_binary( srcs = glob([ "tools/llvm-link/*.cpp", "tools/llvm-link/*.h", @@ -1794,7 +816,7 @@ index 716d7f5d9645..1e3e7a8ff0e7 100644 copts = llvm_copts, stamp = 0, deps = [ -@@ -3112,7 +3112,7 @@ cc_binary( +@@ -3816,7 +3818,7 @@ cc_binary( srcs = glob([ "tools/llvm-lto/*.cpp", "tools/llvm-lto/*.h", @@ -1803,7 +825,7 @@ index 716d7f5d9645..1e3e7a8ff0e7 100644 copts = llvm_copts, stamp = 0, deps = [ -@@ -3134,7 +3134,7 @@ cc_binary( +@@ -3839,7 +3841,7 @@ cc_binary( srcs = glob([ "tools/llvm-lto2/*.cpp", "tools/llvm-lto2/*.h", @@ -1812,61 +834,25 @@ index 716d7f5d9645..1e3e7a8ff0e7 100644 copts = llvm_copts, stamp = 0, deps = [ -@@ -3153,7 +3153,7 @@ cc_binary( - srcs = glob([ - "tools/llvm-mc/*.cpp", - "tools/llvm-mc/*.h", -- ]), -+ ], allow_empty = True), - copts = llvm_copts, - stamp = 0, - deps = [ -@@ -3175,7 +3175,7 @@ cc_binary( - "tools/llvm-mca/*.h", - "tools/llvm-mca/Views/*.cpp", - "tools/llvm-mca/Views/*.h", -- ]), -+ ], allow_empty = True), - copts = llvm_copts, - stamp = 0, - deps = [ -@@ -3208,7 +3208,7 @@ cc_binary( - srcs = glob([ - "tools/llvm-ml/*.cpp", - "tools/llvm-ml/*.h", -- ]), -+ ], allow_empty = True), - copts = llvm_copts, - stamp = 0, - deps = [ -@@ -3227,7 +3227,7 @@ cc_binary( - name = "llvm-modextract", - srcs = glob([ - "tools/llvm-modextract/*.cpp", -- ]), -+ ], allow_empty = True), - copts = llvm_copts, - stamp = 0, - deps = [ -@@ -3255,7 +3255,7 @@ cc_binary( +@@ -3976,7 +3978,7 @@ cc_binary( srcs = glob([ "tools/llvm-mt/*.cpp", "tools/llvm-mt/*.h", -- ]), -+ ], allow_empty = True), +- ]) + ["llvm-mt-driver.cpp"], ++ ], allow_empty = True) + ["llvm-mt-driver.cpp"], copts = llvm_copts, stamp = 0, - tags = [ -@@ -3287,7 +3287,7 @@ cc_binary( + deps = [ +@@ -4013,7 +4015,7 @@ cc_binary( srcs = glob([ "tools/llvm-nm/*.cpp", "tools/llvm-nm/*.h", -- ]), -+ ], allow_empty = True), +- ]) + ["llvm-nm-driver.cpp"], ++ ], allow_empty = True) + ["llvm-nm-driver.cpp"], copts = llvm_copts, stamp = 0, deps = [ -@@ -3369,7 +3369,7 @@ cc_binary( +@@ -4096,7 +4098,7 @@ cc_binary( srcs = glob([ "tools/llvm-stress/*.cpp", "tools/llvm-stress/*.h", @@ -1875,79 +861,25 @@ index 716d7f5d9645..1e3e7a8ff0e7 100644 copts = llvm_copts, stamp = 0, deps = [ -@@ -3425,7 +3425,7 @@ cc_binary( - srcs = glob([ - "tools/llvm-objdump/*.cpp", - "tools/llvm-objdump/*.h", -- ]), -+ ], allow_empty = True), - copts = llvm_copts, - stamp = 0, - deps = [ -@@ -3482,7 +3482,7 @@ cc_binary( - name = "llvm-opt-report", - srcs = glob([ - "tools/llvm-opt-report/*.cpp", -- ]), -+ ], allow_empty = True), - copts = llvm_copts, - stamp = 0, - deps = [ -@@ -3498,7 +3498,7 @@ cc_binary( - srcs = glob([ - "tools/llvm-pdbutil/*.cpp", - "tools/llvm-pdbutil/*.h", -- ]), -+ ], allow_empty = True), - copts = llvm_copts, - stamp = 0, - deps = [ -@@ -3518,7 +3518,7 @@ cc_binary( +@@ -4264,7 +4266,7 @@ cc_binary( srcs = glob([ "tools/llvm-profdata/*.cpp", "tools/llvm-profdata/*.h", -- ]), -+ ], allow_empty = True), - copts = llvm_copts, - stamp = 0, - deps = [ -@@ -3533,7 +3533,7 @@ cc_binary( - srcs = glob([ - "tools/llvm-profgen/*.cpp", - "tools/llvm-profgen/*.h", -- ]), -+ ], allow_empty = True), - copts = llvm_copts, - stamp = 0, - deps = [ -@@ -3578,7 +3578,7 @@ cc_binary( - srcs = glob([ - "tools/llvm-rc/*.cpp", - "tools/llvm-rc/*.h", -- ]), -+ ], allow_empty = True), +- ]) + ["llvm-profdata-driver.cpp"], ++ ], allow_empty = True) + ["llvm-profdata-driver.cpp"], copts = llvm_copts, stamp = 0, deps = [ -@@ -3613,7 +3613,7 @@ cc_binary( +@@ -4448,7 +4450,7 @@ cc_binary( srcs = glob([ - "tools/llvm-readobj/*.cpp", - "tools/llvm-readobj/*.h", + "tools/llvm-remark-size-diff/**/*.cpp", + "tools/llvm-remark-size-diff/**/*.h", - ]), + ], allow_empty = True), copts = llvm_copts, + includes = ["tools/llvm-reark-size-diff"], stamp = 0, - deps = [ -@@ -3641,7 +3641,7 @@ cc_binary( - srcs = glob([ - "tools/llvm-reduce/**/*.cpp", - "tools/llvm-reduce/**/*.h", -- ]), -+ ], allow_empty = True), - copts = llvm_copts, - includes = ["tools/llvm-reduce"], - stamp = 0, -@@ -3658,7 +3658,7 @@ cc_binary( +@@ -4466,7 +4468,7 @@ cc_binary( srcs = glob([ "tools/llvm-rtdyld/*.cpp", "tools/llvm-rtdyld/*.h", @@ -1956,16 +888,16 @@ index 716d7f5d9645..1e3e7a8ff0e7 100644 copts = llvm_copts, stamp = 0, deps = [ -@@ -3691,7 +3691,7 @@ cc_binary( +@@ -4508,7 +4510,7 @@ cc_binary( srcs = glob([ "tools/llvm-size/*.cpp", "tools/llvm-size/*.h", -- ]), -+ ], allow_empty = True), +- ]) + ["llvm-size-driver.cpp"], ++ ], allow_empty = True) + ["llvm-size-driver.cpp"], copts = llvm_copts, stamp = 0, deps = [ -@@ -3707,7 +3707,7 @@ cc_binary( +@@ -4524,7 +4526,7 @@ cc_binary( srcs = glob([ "tools/llvm-split/*.cpp", "tools/llvm-split/*.h", @@ -1974,7 +906,7 @@ index 716d7f5d9645..1e3e7a8ff0e7 100644 copts = llvm_copts, stamp = 0, deps = [ -@@ -3736,7 +3736,7 @@ cc_binary( +@@ -4554,7 +4556,7 @@ cc_binary( srcs = glob([ "tools/llvm-strings/*.cpp", "tools/llvm-strings/*.h", @@ -1983,7 +915,7 @@ index 716d7f5d9645..1e3e7a8ff0e7 100644 copts = llvm_copts, stamp = 0, deps = [ -@@ -3764,7 +3764,7 @@ cc_binary( +@@ -4582,7 +4584,7 @@ cc_binary( srcs = glob([ "tools/llvm-symbolizer/*.cpp", "tools/llvm-symbolizer/*.h", @@ -1992,7 +924,7 @@ index 716d7f5d9645..1e3e7a8ff0e7 100644 copts = llvm_copts, stamp = 0, deps = [ -@@ -3789,7 +3789,7 @@ cc_binary( +@@ -4608,7 +4610,7 @@ cc_binary( srcs = glob([ "tools/llvm-undname/*.cpp", "tools/llvm-undname/*.h", @@ -2001,7 +933,7 @@ index 716d7f5d9645..1e3e7a8ff0e7 100644 copts = llvm_copts, stamp = 0, deps = [ -@@ -3804,7 +3804,7 @@ cc_binary( +@@ -4623,7 +4625,7 @@ cc_binary( "tools/llvm-xray/*.cpp", "tools/llvm-xray/*.cc", "tools/llvm-xray/*.h", @@ -2010,16 +942,7 @@ index 716d7f5d9645..1e3e7a8ff0e7 100644 copts = llvm_copts, stamp = 0, deps = [ -@@ -3821,7 +3821,7 @@ cc_binary( - srcs = glob([ - "tools/opt/*.cpp", - "tools/opt/*.h", -- ]), -+ ], allow_empty = True), - copts = llvm_copts, - linkopts = select({ - "@bazel_tools//src/conditions:windows": [], -@@ -3854,7 +3854,7 @@ cc_binary( +@@ -4679,7 +4681,7 @@ cc_binary( srcs = glob([ "tools/sancov/*.cpp", "tools/sancov/*.h", @@ -2028,7 +951,7 @@ index 716d7f5d9645..1e3e7a8ff0e7 100644 copts = llvm_copts, stamp = 0, deps = [ -@@ -3875,7 +3875,7 @@ cc_binary( +@@ -4700,7 +4702,7 @@ cc_binary( srcs = glob([ "tools/sanstats/*.cpp", "tools/sanstats/*.h", @@ -2037,78 +960,34 @@ index 716d7f5d9645..1e3e7a8ff0e7 100644 copts = llvm_copts, stamp = 0, deps = [ -@@ -3890,7 +3890,7 @@ cc_binary( +@@ -4715,7 +4717,7 @@ cc_binary( srcs = glob([ - "tools/split-file/*.cpp", - "tools/split-file/*.h", + "utils/split-file/*.cpp", + "utils/split-file/*.h", - ]), + ], allow_empty = True), copts = llvm_copts, stamp = 0, deps = [ -@@ -3904,8 +3904,8 @@ cc_binary( - cc_library( - name = "FuzzMutate", - testonly = True, -- srcs = glob(["lib/FuzzMutate/*.cpp"]), -- hdrs = glob(["include/llvm/FuzzMutate/*.h"]), -+ srcs = glob(["lib/FuzzMutate/*.cpp"], allow_empty = True), -+ hdrs = glob(["include/llvm/FuzzMutate/*.h"], allow_empty = True), - copts = llvm_copts, - includes = ["include"], - deps = [ -@@ -3921,8 +3921,8 @@ cc_library( - cc_library( - name = "Diff", - testonly = True, -- srcs = glob(["tools/llvm-diff/lib/*.cpp"]), -- hdrs = glob(["tools/llvm-diff/lib/*.h"]), -+ srcs = glob(["tools/llvm-diff/lib/*.cpp"], allow_empty = True), -+ hdrs = glob(["tools/llvm-diff/lib/*.h"], allow_empty = True), - deps = [ - ":Core", - ":Support", -@@ -4023,7 +4023,7 @@ cc_library( - py_binary( - name = "lit", - testonly = True, -- srcs = ["utils/lit/lit.py"] + glob(["utils/lit/lit/**/*.py"]), -+ srcs = ["utils/lit/lit.py"] + glob(["utils/lit/lit/**/*.py"], allow_empty = True), - ) - - cc_library( -@@ -4032,10 +4032,10 @@ cc_library( +@@ -4781,7 +4783,7 @@ cc_library( srcs = glob([ "lib/Testing/Support/*.cpp", "lib/Testing/Support/*.h", - ]), + ], allow_empty = True), - hdrs = glob([ - "include/llvm/Testing/Support/*.h", -- ]), -+ ], allow_empty = True), + hdrs = glob(["include/llvm/Testing/Support/*.h"]), copts = llvm_copts, deps = [ - ":Support", -@@ -4054,7 +4054,7 @@ cc_binary( +@@ -4810,7 +4812,7 @@ cc_binary( srcs = glob([ "utils/FileCheck/*.cpp", "utils/FileCheck/*.h", - ]), -+ ], allow_empty = True), - copts = llvm_copts, - stamp = 0, - deps = [":FileCheckLib"], -@@ -4065,7 +4065,7 @@ cc_binary( - srcs = glob([ - "tools/bugpoint/*.cpp", - "tools/bugpoint/*.h", -- ]), + ], allow_empty = True), copts = llvm_copts, stamp = 0, deps = [ -@@ -4093,7 +4093,7 @@ cc_binary( +@@ -4856,7 +4858,7 @@ cc_binary( srcs = glob([ "utils/count/*.c", "utils/count/*.h", @@ -2117,7 +996,7 @@ index 716d7f5d9645..1e3e7a8ff0e7 100644 stamp = 0, ) -@@ -4103,7 +4103,7 @@ cc_binary( +@@ -4866,7 +4868,7 @@ cc_binary( srcs = glob([ "tools/lli/ChildTarget/*.cpp", "tools/lli/ChildTarget/*.h", @@ -2126,7 +1005,7 @@ index 716d7f5d9645..1e3e7a8ff0e7 100644 copts = llvm_copts, # The tests load code into this binary that expect to see symbols # from libstdc++ such as __cxa_begin_catch and _ZTIi. The latter -@@ -4164,7 +4164,7 @@ cc_binary( +@@ -4933,7 +4935,7 @@ cc_binary( srcs = glob([ "tools/llvm-diff/*.cpp", "tools/llvm-diff/*.h", @@ -2135,7 +1014,7 @@ index 716d7f5d9645..1e3e7a8ff0e7 100644 copts = llvm_copts, stamp = 0, deps = [ -@@ -4181,7 +4181,7 @@ cc_binary( +@@ -4951,7 +4953,7 @@ cc_binary( srcs = glob([ "tools/llvm-isel-fuzzer/*.cpp", "tools/llvm-isel-fuzzer/*.h", @@ -2144,7 +1023,7 @@ index 716d7f5d9645..1e3e7a8ff0e7 100644 copts = llvm_copts, stamp = 0, deps = [ -@@ -4225,7 +4225,7 @@ cc_binary( +@@ -4997,7 +4999,7 @@ cc_binary( srcs = glob([ "utils/not/*.cpp", "utils/not/*.h", @@ -2153,7 +1032,7 @@ index 716d7f5d9645..1e3e7a8ff0e7 100644 copts = llvm_copts, stamp = 0, deps = [":Support"], -@@ -4287,7 +4287,7 @@ cc_binary( +@@ -5061,7 +5063,7 @@ cc_binary( srcs = glob([ "tools/llvm-tli-checker/*.cpp", "tools/llvm-tli-checker/*.h", @@ -2162,16 +1041,7 @@ index 716d7f5d9645..1e3e7a8ff0e7 100644 copts = llvm_copts, stamp = 0, deps = [ -@@ -4314,7 +4314,7 @@ cc_binary( - srcs = glob([ - "tools/obj2yaml/*.cpp", - "tools/obj2yaml/*.h", -- ]), -+ ], allow_empty = True), - copts = llvm_copts, - stamp = 0, - deps = [ -@@ -4332,7 +4332,7 @@ cc_binary( +@@ -5108,7 +5110,7 @@ cc_binary( srcs = glob([ "tools/verify-uselistorder/*.cpp", "tools/verify-uselistorder/*.h", @@ -2180,7 +1050,7 @@ index 716d7f5d9645..1e3e7a8ff0e7 100644 copts = llvm_copts, stamp = 0, deps = [ -@@ -4351,7 +4351,7 @@ cc_binary( +@@ -5128,7 +5130,7 @@ cc_binary( srcs = glob([ "tools/yaml2obj/*.cpp", "tools/yaml2obj/*.h", diff --git a/extensions/bindgen/3rdparty/patches/llvm-raw.incompatible_disallow_empty_glob.patch b/extensions/bindgen/3rdparty/patches/llvm-raw.incompatible_disallow_empty_glob.patch new file mode 100644 index 0000000000..224dbbe748 --- /dev/null +++ b/extensions/bindgen/3rdparty/patches/llvm-raw.incompatible_disallow_empty_glob.patch @@ -0,0 +1,1025 @@ +diff --git a/utils/bazel/llvm-project-overlay/clang/BUILD.bazel b/utils/bazel/llvm-project-overlay/clang/BUILD.bazel +index 037719a51..476efdde8 100644 +--- a/utils/bazel/llvm-project-overlay/clang/BUILD.bazel ++++ b/utils/bazel/llvm-project-overlay/clang/BUILD.bazel +@@ -533,7 +533,7 @@ cc_library( + "lib/Basic/*.h", + "lib/Basic/Targets/*.cpp", + "lib/Basic/Targets/*.h", +- ]), ++ ], allow_empty = True), + hdrs = glob([ + "include/clang/Basic/*.h", + ]), +@@ -944,7 +944,7 @@ cc_library( + "lib/Analysis/FlowSensitive/*.cpp", + "lib/Analysis/*.cpp", + "lib/Analysis/*.h", +- ]) + [ ++ ], allow_empty = True) + [ + ":analysis_htmllogger_gen", + ], + hdrs = glob([ +@@ -1080,7 +1080,7 @@ cc_library( + ] + glob([ + "lib/Parse/*.cpp", + "lib/Parse/*.h", +- ]), ++ ], allow_empty = True), + hdrs = [ + "include/clang/Parse/AttrParserStringSwitches.inc", + "include/clang/Parse/AttrSubMatchRulesParserStringSwitches.inc", +@@ -1104,7 +1104,7 @@ cc_library( + srcs = glob([ + "lib/ASTMatchers/*.cpp", + "lib/ASTMatchers/*.h", +- ]), ++ ], allow_empty = True), + hdrs = glob(["include/clang/ASTMatchers/*.h"]), + includes = ["include"], + deps = [ +@@ -1138,7 +1138,7 @@ cc_library( + srcs = glob([ + "lib/Rewrite/*.cpp", + "lib/Rewrite/*.h", +- ]), ++ ], allow_empty = True), + hdrs = glob(["include/clang/Rewrite/Core/*.h"]), + includes = ["include"], + deps = [ +@@ -1172,7 +1172,7 @@ cc_library( + srcs = glob([ + "lib/Tooling/Core/*.cpp", + "lib/Tooling/Core/*.h", +- ]), ++ ], allow_empty = True), + hdrs = glob(["include/clang/Tooling/Core/*.h"]), + includes = ["include"], + deps = [ +@@ -1237,11 +1237,11 @@ cc_library( + srcs = glob([ + "lib/Tooling/Refactoring/**/*.cpp", + "lib/Tooling/Refactoring/**/*.h", +- ]), ++ ], allow_empty = True), + hdrs = glob([ + "include/clang/Tooling/Refactoring/**/*.h", + "include/clang/Tooling/Refactoring/**/*.def", +- ]), ++ ], allow_empty = True), + deps = [ + ":ast", + ":ast_matchers", +@@ -1500,6 +1500,7 @@ cc_library( + exclude = [ + "lib/Driver/ToolChains/MSVCSetupApi.h", + ], ++ allow_empty = True, + ), + hdrs = glob([ + "include/clang/Driver/*.h", +@@ -1716,7 +1717,7 @@ cc_library( + includes = ["include"], + textual_hdrs = glob([ + "include/clang/Frontend/*.def", +- ]), ++ ], allow_empty = True), + deps = [ + ":ast", + ":basic", +@@ -1752,7 +1753,7 @@ cc_library( + srcs = glob([ + "lib/Frontend/Rewrite/*.cpp", + "lib/Frontend/Rewrite/*.h", +- ]), ++ ], allow_empty = True), + hdrs = glob(["include/clang/Rewrite/Frontend/*.h"]), + includes = ["include"], + deps = [ +@@ -1967,7 +1968,7 @@ cc_library( + srcs = glob([ + "lib/FrontendTool/*.cpp", + "lib/FrontendTool/*.h", +- ]), ++ ], allow_empty = True), + hdrs = glob(["include/clang/FrontendTool/*.h"]), + includes = ["include"], + deps = [ +@@ -2155,7 +2156,7 @@ cc_binary( + srcs = glob([ + "tools/clang-import-test/*.cpp", + "tools/clang-import-test/*.h", +- ]), ++ ], allow_empty = True), + stamp = 0, + deps = [ + ":ast", +@@ -2185,7 +2186,7 @@ cc_library( + srcs = glob([ + "tools/driver/*.cpp", + "tools/driver/*.h", +- ]) + ["clang-driver.cpp"], ++ ], allow_empty = True) + ["clang-driver.cpp"], + copts = [ + # Disable stack frame size checks in the driver because + # clang::ensureStackAddressSpace allocates a large array on the stack. +@@ -2500,7 +2501,7 @@ cc_library( + srcs = glob([ + "lib/ExtractAPI/**/*.cpp", + "lib/ExtractAPI/**/*.h", +- ]), ++ ], allow_empty = True), + hdrs = glob(["include/clang/ExtractAPI/**/*.h"]), + includes = ["include"], + deps = [ +diff --git a/utils/bazel/llvm-project-overlay/llvm/BUILD.bazel b/utils/bazel/llvm-project-overlay/llvm/BUILD.bazel +index a7e9398ea..703103cc9 100644 +--- a/utils/bazel/llvm-project-overlay/llvm/BUILD.bazel ++++ b/utils/bazel/llvm-project-overlay/llvm/BUILD.bazel +@@ -96,7 +96,7 @@ enum_targets_gen( + llvm_target_mcas = [ + t + for t in llvm_targets +- if glob(["lib/Target/{}/MCA/CMakeLists.txt".format(t)]) ++ if glob(["lib/Target/{}/MCA/CMakeLists.txt".format(t)], allow_empty = True) + ] + + enum_targets_gen( +@@ -169,7 +169,7 @@ cc_library( + srcs = glob([ + "lib/Demangle/*.cpp", + "lib/Demangle/*.h", +- ]), ++ ], allow_empty = True), + hdrs = glob([ + "include/llvm/Demangle/*.h", + "include/llvm/Demangle/*.def", +@@ -205,7 +205,7 @@ cc_library( + "@platforms//os:windows": glob([ + "lib/Support/Windows/*.h", + "lib/Support/Windows/*.inc", +- ]), ++ ], allow_empty = True), + "//conditions:default": glob([ + "lib/Support/Unix/*.h", + "lib/Support/Unix/*.inc", +@@ -314,7 +314,7 @@ cc_library( + srcs = glob([ + "lib/LineEditor/*.cpp", + "lib/LineEditor/*.h", +- ]), ++ ], allow_empty = True), + hdrs = glob(["include/llvm/LineEditor/*.h"]), + copts = llvm_copts, + deps = [ +@@ -328,7 +328,7 @@ cc_library( + srcs = glob([ + "lib/Option/*.cpp", + "lib/Option/*.h", +- ]), ++ ], allow_empty = True), + hdrs = glob(["include/llvm/Option/*.h"]), + copts = llvm_copts, + deps = [ +@@ -376,7 +376,7 @@ cc_library( + "lib/BinaryFormat/*.cpp", + "lib/BinaryFormat/*.def", + "lib/BinaryFormat/*.h", +- ]), ++ ], allow_empty = True), + hdrs = glob([ + "include/llvm/BinaryFormat/*.h", + ]), +@@ -408,7 +408,7 @@ cc_library( + srcs = glob([ + "lib/DebugInfo/MSF/*.cpp", + "lib/DebugInfo/MSF/*.h", +- ]), ++ ], allow_empty = True), + hdrs = glob(["include/llvm/DebugInfo/MSF/*.h"]), + copts = llvm_copts, + deps = [":Support"], +@@ -419,7 +419,7 @@ cc_library( + srcs = glob([ + "lib/DebugInfo/BTF/*.cpp", + "lib/DebugInfo/BTF/*.h", +- ]), ++ ], allow_empty = True), + hdrs = glob(["include/llvm/DebugInfo/BTF/*.h"]) + [ + "include/llvm/DebugInfo/BTF/BTF.def", + ], +@@ -436,7 +436,7 @@ cc_library( + srcs = glob([ + "lib/DebugInfo/CodeView/*.cpp", + "lib/DebugInfo/CodeView/*.h", +- ]), ++ ], allow_empty = True), + hdrs = glob([ + "include/llvm/DebugInfo/CodeView/*.h", + ]), +@@ -481,7 +481,7 @@ cc_library( + "lib/DebugInfo/PDB/*.h", + "lib/DebugInfo/PDB/Native/*.cpp", + "lib/DebugInfo/PDB/Native/*.h", +- ]), ++ ], allow_empty = True), + hdrs = glob([ + "include/llvm/DebugInfo/PDB/*.h", + "include/llvm/DebugInfo/PDB/Native/*.h", +@@ -522,12 +522,12 @@ cc_library( + srcs = glob([ + "lib/MC/*.cpp", + "lib/MC/*.h", +- ]), ++ ], allow_empty = True), + hdrs = glob([ + "include/llvm/MC/*.h", + "include/llvm/MC/*.def", + "include/llvm/MC/*.inc", +- ]), ++ ], allow_empty = True), + copts = llvm_copts, + deps = [ + ":BinaryFormat", +@@ -544,7 +544,7 @@ cc_library( + srcs = glob([ + "lib/DebugInfo/DWARF/*.cpp", + "lib/DebugInfo/DWARF/*.h", +- ]), ++ ], allow_empty = True), + hdrs = glob(["include/llvm/DebugInfo/DWARF/*.h"]), + copts = llvm_copts, + deps = [ +@@ -562,7 +562,7 @@ cc_library( + srcs = glob([ + "lib/DebugInfo/GSYM/*.cpp", + "lib/DebugInfo/GSYM/*.h", +- ]), ++ ], allow_empty = True), + hdrs = glob(["include/llvm/DebugInfo/GSYM/*.h"]), + copts = llvm_copts, + deps = [ +@@ -579,7 +579,7 @@ cc_library( + srcs = glob([ + "lib/DebugInfo/Symbolize/*.cpp", + "lib/DebugInfo/Symbolize/*.h", +- ]), ++ ], allow_empty = True), + hdrs = glob([ + "include/llvm/DebugInfo/Symbolize/*.h", + "include/llvm/Debuginfod/*.h", +@@ -664,7 +664,7 @@ cc_binary( + # regular dependency. + "include/llvm/MC/*.h", + "include/llvm/TargetParser/SubtargetFeature.h", +- ]), ++ ], allow_empty = True), + copts = llvm_copts, + stamp = 0, + deps = [ +@@ -812,7 +812,7 @@ cc_library( + srcs = glob([ + "lib/Bitstream/Reader/*.cpp", + "lib/Bitstream/Reader/*.h", +- ]), ++ ], allow_empty = True), + hdrs = [ + "include/llvm/Bitstream/BitCodeEnums.h", + "include/llvm/Bitstream/BitCodes.h", +@@ -828,7 +828,7 @@ cc_library( + name = "BitstreamWriter", + srcs = glob([ + "lib/Bitstream/Writer/*.h", +- ]), ++ ], allow_empty = True), + hdrs = [ + "include/llvm/Bitstream/BitCodeEnums.h", + "include/llvm/Bitstream/BitCodes.h", +@@ -848,6 +848,7 @@ cc_library( + "lib/Remarks/*.h", + ], + exclude = ["lib/Remarks/RemarkLinker.cpp"], ++ allow_empty = True, + ), + hdrs = glob( + [ +@@ -947,7 +948,7 @@ cc_library( + srcs = glob([ + "lib/MC/MCParser/*.cpp", + "lib/MC/MCParser/*.h", +- ]), ++ ], allow_empty = True), + hdrs = glob(["include/llvm/MC/MCParser/*.h"]), + copts = llvm_copts, + deps = [ +@@ -1032,7 +1033,7 @@ cc_library( + srcs = glob([ + "lib/ObjectYAML/*.cpp", + "lib/ObjectYAML/*.h", +- ]), ++ ], allow_empty = True), + hdrs = glob(["include/llvm/ObjectYAML/*.h"]), + copts = llvm_copts, + deps = [ +@@ -1050,7 +1051,7 @@ cc_library( + srcs = glob([ + "lib/ProfileData/*.cpp", + "lib/ProfileData/*.h", +- ]), ++ ], allow_empty = True), + hdrs = glob([ + "include/llvm/ProfileData/*.h", + "include/llvm/ProfileData/*.inc", +@@ -1074,7 +1075,7 @@ cc_library( + srcs = glob([ + "lib/ProfileData/Coverage/*.cpp", + "lib/ProfileData/Coverage/*.h", +- ]), ++ ], allow_empty = True), + hdrs = glob(["include/llvm/ProfileData/Coverage/*.h"]), + copts = llvm_copts, + deps = [ +@@ -1093,6 +1094,7 @@ cc_library( + "lib/Analysis/*.h", + "lib/Analysis/*.def", + ], ++ allow_empty = True, + ), + hdrs = glob( + [ +@@ -1149,7 +1151,7 @@ cc_library( + srcs = glob([ + "lib/Target/*.cpp", + "lib/Target/*.h", +- ]), ++ ], allow_empty = True), + hdrs = glob([ + "include/llvm/Target/*.h", + ]) + [ +@@ -1185,15 +1187,15 @@ cc_library( + srcs = glob([ + "lib/TargetParser/*.cpp", + "lib/TargetParser/*.h", +- ]) + select({ ++ ], allow_empty = True) + select({ + "@platforms//os:windows": glob([ + "lib/TargetParser/Windows/*.h", + "lib/TargetParser/Windows/*.inc", +- ]), ++ ], allow_empty = True), + "//conditions:default": glob([ + "lib/TargetParser/Unix/*.h", + "lib/TargetParser/Unix/*.inc", +- ]), ++ ], allow_empty = True), + }), + hdrs = glob([ + "include/llvm/TargetParser/*.h", +@@ -1216,7 +1218,7 @@ cc_library( + srcs = glob([ + "lib/DWP/*.cpp", + "lib/DWP/*.h", +- ]), ++ ], allow_empty = True), + hdrs = glob(["include/llvm/DWP/*.h"]), + copts = llvm_copts, + deps = [ +@@ -1233,7 +1235,7 @@ cc_library( + srcs = glob([ + "lib/Transforms/Utils/*.cpp", + "lib/Transforms/Utils/*.h", +- ]), ++ ], allow_empty = True), + hdrs = glob(["include/llvm/Transforms/Utils/*.h"]) + [ + "include/llvm/Transforms/Utils.h", + ], +@@ -1354,7 +1356,7 @@ cc_library( + srcs = glob([ + "lib/Transforms/Scalar/*.cpp", + "lib/Transforms/Scalar/*.h", +- ]), ++ ], allow_empty = True), + hdrs = glob(["include/llvm/Transforms/Scalar/*.h"]) + [ + "include/llvm/Transforms/Scalar.h", + ], +@@ -1399,7 +1401,7 @@ cc_library( + name = "FrontendDebug", + srcs = glob([ + "lib/Frontend/Debug/*.cpp", +- ]), ++ ], allow_empty = True), + hdrs = glob([ + "include/llvm/Frontend/Debug/*.h", + ]), +@@ -1463,7 +1465,7 @@ cc_library( + "include/llvm/Frontend/OpenMP/*.h", + "include/llvm/Frontend/OpenMP/OMP/*.h", + "include/llvm/Frontend/*.h", +- ]) + [ ++ ], allow_empty = True) + [ + "include/llvm/Frontend/OpenMP/OMP.h.inc", + "include/llvm/Frontend/OpenMP/OMP.inc", + ], +@@ -1523,7 +1525,7 @@ cc_library( + ], + hdrs = glob([ + "include/llvm/Frontend/OpenACC/*.h", +- ]) + ["include/llvm/Frontend/OpenACC/ACC.h.inc"], ++ ], allow_empty = True) + ["include/llvm/Frontend/OpenACC/ACC.h.inc"], + copts = llvm_copts, + deps = [ + ":Analysis", +@@ -1538,7 +1540,7 @@ cc_library( + srcs = glob([ + "lib/AsmParser/*.cpp", + "lib/AsmParser/*.h", +- ]), ++ ], allow_empty = True), + hdrs = glob(["include/llvm/AsmParser/*.h"]), + copts = llvm_copts, + deps = [ +@@ -1554,7 +1556,7 @@ cc_library( + srcs = glob([ + "lib/IRPrinter/*.cpp", + "lib/IRPrinter/*.h", +- ]), ++ ], allow_empty = True), + hdrs = glob([ + "include/llvm/IRPrinter/*.h", + ]), +@@ -1571,7 +1573,7 @@ cc_library( + srcs = glob([ + "lib/IRReader/*.cpp", + "lib/IRReader/*.h", +- ]), ++ ], allow_empty = True), + hdrs = glob([ + "include/llvm/IRReader/*.h", + ]) + [ +@@ -1614,7 +1616,7 @@ cc_library( + srcs = glob([ + "lib/Transforms/IPO/*.cpp", + "lib/Transforms/IPO/*.h", +- ]), ++ ], allow_empty = True), + hdrs = glob([ + "include/llvm/Transforms/IPO/*.h", + ]) + [ +@@ -1652,7 +1654,7 @@ cc_library( + srcs = glob([ + "lib/Transforms/CFGuard/*.cpp", + "lib/Transforms/CFGuard/*.h", +- ]), ++ ], allow_empty = True), + hdrs = ["include/llvm/Transforms/CFGuard.h"], + copts = llvm_copts, + deps = [ +@@ -1744,7 +1746,7 @@ cc_library( + textual_hdrs = glob([ + "include/llvm/CodeGen/**/*.def", + "include/llvm/CodeGen/**/*.inc", +- ]), ++ ], allow_empty = True), + deps = [ + ":AggressiveInstCombine", + ":Analysis", +@@ -2200,7 +2202,7 @@ gentbl( + ] + glob([ + "lib/Target/" + target["name"] + "/*.td", + "lib/Target/" + target["name"] + "/GISel/*.td", +- ]), ++ ], allow_empty = True), + deps = target.get("tbl_deps", []), + )], + [cc_library( +@@ -2235,7 +2237,7 @@ gentbl( + # library. This mixture is likely incompatible with header modules. + "lib/Target/" + target["name"] + "/MCTargetDesc/*.h", + "lib/Target/" + target["name"] + "/Utils/*.h", +- ]), ++ ], allow_empty = True), + hdrs = glob([ + "lib/Target/" + target["name"] + "/MCTargetDesc/*.h", + "lib/Target/" + target["name"] + "/Utils/*.h", +@@ -2260,7 +2262,7 @@ gentbl( + "lib/Target/" + target["name"] + "/*.def", + "lib/Target/" + target["name"] + "/*.inc", + "lib/Target/" + target["name"] + "/MCTargetDesc/*.def", +- ]), ++ ], allow_empty = True), + copts = llvm_copts, + features = [ + "-parse_headers", +@@ -2292,7 +2294,7 @@ gentbl( + "lib/Target/" + target["name"] + "/GISel/*.h", + "lib/Target/" + target["name"] + "/*.cpp", + "lib/Target/" + target["name"] + "/*.h", +- ]), ++ ], allow_empty = True), + hdrs = ["lib/Target/" + target["name"] + "/" + target["short_name"] + ".h"], + copts = llvm_copts, + features = ["-layering_check"], +@@ -2300,7 +2302,7 @@ gentbl( + textual_hdrs = glob([ + "lib/Target/" + target["name"] + "/*.def", + "lib/Target/" + target["name"] + "/*.inc", +- ]), ++ ], allow_empty = True), + deps = [ + ":Analysis", + ":BinaryFormat", +@@ -2328,7 +2330,7 @@ gentbl( + srcs = glob([ + "lib/Target/" + target["name"] + "/AsmParser/*.cpp", + "lib/Target/" + target["name"] + "/AsmParser/*.h", +- ]), ++ ], allow_empty = True), + copts = llvm_copts, + deps = [ + ":BinaryFormat", +@@ -2374,7 +2376,7 @@ gentbl( + "lib/Target/" + target["name"] + "/Disassembler/*.cpp", + "lib/Target/" + target["name"] + "/Disassembler/*.c", + "lib/Target/" + target["name"] + "/Disassembler/*.h", +- ]), ++ ], allow_empty = True), + copts = llvm_copts, + features = ["-layering_check"], + deps = [ +@@ -2396,7 +2398,7 @@ gentbl( + "lib/Target/" + target["name"] + "/MCA/*.cpp", + "lib/Target/" + target["name"] + "/MCA/*.c", + "lib/Target/" + target["name"] + "/MCA/*.h", +- ]), ++ ], allow_empty = True), + copts = llvm_copts, + features = ["-layering_check"], + deps = [ +@@ -2459,10 +2461,10 @@ cc_library( + srcs = glob([ + "lib/Analysis/ML/*.cpp", + "lib/Analysis/ML/*.h", +- ]), ++ ], allow_empty = True), + hdrs = glob([ + "include/llvm/Analysis/ML/*.h", +- ]), ++ ], allow_empty = True), + copts = llvm_copts, + deps = [ + ":Analysis", +@@ -2476,7 +2478,7 @@ cc_library( + srcs = glob([ + "lib/Passes/*.cpp", + "lib/Passes/*.h", +- ]), ++ ], allow_empty = True), + hdrs = glob(["include/llvm/Passes/*.h"]) + ["include/llvm-c/Transforms/PassBuilder.h"], + copts = llvm_copts, + deps = [ +@@ -2507,7 +2509,7 @@ cc_library( + srcs = glob([ + "lib/LTO/*.cpp", + "lib/LTO/*.h", +- ]), ++ ], allow_empty = True), + hdrs = glob([ + "include/llvm/LTO/*.h", + "include/llvm/LTO/legacy/*.h", +@@ -2551,7 +2553,7 @@ cc_library( + "lib/ExecutionEngine/RuntimeDyld/*.h", + "lib/ExecutionEngine/RuntimeDyld/Targets/*.cpp", + "lib/ExecutionEngine/RuntimeDyld/Targets/*.h", +- ]), ++ ], allow_empty = True), + hdrs = glob( + [ + "include/llvm/ExecutionEngine/*.h", +@@ -2660,11 +2662,11 @@ cc_library( + srcs = glob([ + "lib/ExecutionEngine/Orc/*.cpp", + "lib/ExecutionEngine/Orc/*.h", +- ]), ++ ], allow_empty = True), + hdrs = glob([ + "include/llvm/ExecutionEngine/Orc/*.h", + "include/llvm/ExecutionEngine/Orc/RPC/*.h", +- ]) + [ ++ ], allow_empty = True) + [ + "include/llvm-c/LLJIT.h", + "include/llvm-c/Orc.h", + "include/llvm-c/OrcEE.h", +@@ -2767,7 +2769,7 @@ cc_library( + srcs = glob([ + "lib/DWARFLinker/*.cpp", + "lib/DWARFLinker/*.h", +- ]), ++ ], allow_empty = True), + hdrs = glob(["include/llvm/DWARFLinker/*.h"]), + copts = llvm_copts, + deps = [ +@@ -2860,7 +2862,7 @@ cc_library( + srcs = glob([ + "lib/InterfaceStub/*.cpp", + "lib/InterfaceStub/*.h", +- ]), ++ ], allow_empty = True), + hdrs = glob([ + "include/llvm/InterfaceStub/*.h", + ]), +@@ -2911,7 +2913,7 @@ cc_library( + srcs = glob([ + "lib/MCA/**/*.cpp", + "lib/MCA/**/*.h", +- ]), ++ ], allow_empty = True), + hdrs = glob([ + "include/llvm/MCA/**/*.h", + ]), +@@ -2929,7 +2931,7 @@ cc_library( + hdrs = glob([ + "tools/llvm-mca/*.h", + "tools/llvm-mca/Views/*.h", +- ]), ++ ], allow_empty = True), + strip_include_prefix = "tools/llvm-mca", + ) + +@@ -2938,7 +2940,7 @@ cc_library( + srcs = glob([ + "lib/XRay/*.cpp", + "lib/XRay/*.h", +- ]), ++ ], allow_empty = True), + hdrs = glob(["include/llvm/XRay/*.h"]), + copts = llvm_copts, + deps = [ +@@ -3008,7 +3010,7 @@ cc_library( + ] + [ + "tools/llvm-exegesis/lib/{}/*.h".format(t) + for t in llvm_target_exegesis +- ]), ++ ], allow_empty = True), + hdrs = glob(["tools/llvm-exegesis/lib/*.h"]), + copts = llvm_copts, + features = [ +@@ -3095,7 +3097,7 @@ cc_binary( + srcs = glob([ + "tools/llc/*.cpp", + "tools/llc/*.h", +- ]), ++ ], allow_empty = True), + copts = llvm_copts, + stamp = 0, + deps = [ +@@ -3180,7 +3182,7 @@ cc_binary( + srcs = glob([ + "tools/llvm-ar/*.cpp", + "tools/llvm-ar/*.h", +- ]) + ["llvm-ar-driver.cpp"], ++ ], allow_empty = True) + ["llvm-ar-driver.cpp"], + copts = llvm_copts, + stamp = 0, + deps = [ +@@ -3218,7 +3220,7 @@ cc_binary( + srcs = glob([ + "tools/llvm-as/*.cpp", + "tools/llvm-as/*.h", +- ]), ++ ], allow_empty = True), + copts = llvm_copts, + stamp = 0, + deps = [ +@@ -3235,7 +3237,7 @@ cc_binary( + srcs = glob([ + "tools/llvm-bcanalyzer/*.cpp", + "tools/llvm-bcanalyzer/*.h", +- ]), ++ ], allow_empty = True), + copts = llvm_copts, + stamp = 0, + deps = [ +@@ -3322,7 +3324,7 @@ cc_binary( + srcs = glob([ + "tools/llvm-cvtres/*.cpp", + "tools/llvm-cvtres/*.h", +- ]), ++ ], allow_empty = True), + copts = llvm_copts, + stamp = 0, + deps = [ +@@ -3356,7 +3358,7 @@ cc_binary( + srcs = glob([ + "tools/llvm-cxxmap/*.cpp", + "tools/llvm-cxxmap/*.h", +- ]), ++ ], allow_empty = True), + copts = llvm_copts, + stamp = 0, + deps = [ +@@ -3391,7 +3393,7 @@ cc_binary( + srcs = glob([ + "tools/llvm-cxxfilt/*.cpp", + "tools/llvm-cxxfilt/*.h", +- ]) + ["llvm-cxxfilt-driver.cpp"], ++ ], allow_empty = True) + ["llvm-cxxfilt-driver.cpp"], + copts = llvm_copts, + stamp = 0, + deps = [ +@@ -3424,7 +3426,7 @@ cc_binary( + srcs = glob([ + "tools/llvm-debuginfod-find/*.cpp", + "tools/llvm-debuginfod-find/*.h", +- ]), ++ ], allow_empty = True), + copts = llvm_copts, + stamp = 0, + deps = [ +@@ -3441,7 +3443,7 @@ cc_binary( + srcs = glob([ + "tools/llvm-dis/*.cpp", + "tools/llvm-dis/*.h", +- ]), ++ ], allow_empty = True), + copts = llvm_copts, + stamp = 0, + deps = [ +@@ -3527,7 +3529,7 @@ cc_binary( + srcs = glob([ + "tools/llvm-dwp/*.cpp", + "tools/llvm-dwp/*.h", +- ]), ++ ], allow_empty = True), + copts = llvm_copts, + stamp = 0, + deps = [ +@@ -3567,7 +3569,7 @@ cc_binary( + srcs = glob([ + "tools/llvm-extract/*.cpp", + "tools/llvm-extract/*.h", +- ]), ++ ], allow_empty = True), + copts = llvm_copts, + stamp = 0, + deps = [ +@@ -3609,7 +3611,7 @@ cc_binary( + srcs = glob([ + "tools/llvm-gsymutil/*.cpp", + "tools/llvm-gsymutil/*.h", +- ]) + ["llvm-gsymutil-driver.cpp"], ++ ], allow_empty = True) + ["llvm-gsymutil-driver.cpp"], + copts = llvm_copts, + stamp = 0, + deps = [ +@@ -3751,7 +3753,7 @@ cc_binary( + srcs = glob([ + "tools/llvm-link/*.cpp", + "tools/llvm-link/*.h", +- ]), ++ ], allow_empty = True), + copts = llvm_copts, + stamp = 0, + deps = [ +@@ -3816,7 +3818,7 @@ cc_binary( + srcs = glob([ + "tools/llvm-lto/*.cpp", + "tools/llvm-lto/*.h", +- ]), ++ ], allow_empty = True), + copts = llvm_copts, + stamp = 0, + deps = [ +@@ -3839,7 +3841,7 @@ cc_binary( + srcs = glob([ + "tools/llvm-lto2/*.cpp", + "tools/llvm-lto2/*.h", +- ]), ++ ], allow_empty = True), + copts = llvm_copts, + stamp = 0, + deps = [ +@@ -3976,7 +3978,7 @@ cc_binary( + srcs = glob([ + "tools/llvm-mt/*.cpp", + "tools/llvm-mt/*.h", +- ]) + ["llvm-mt-driver.cpp"], ++ ], allow_empty = True) + ["llvm-mt-driver.cpp"], + copts = llvm_copts, + stamp = 0, + deps = [ +@@ -4013,7 +4015,7 @@ cc_binary( + srcs = glob([ + "tools/llvm-nm/*.cpp", + "tools/llvm-nm/*.h", +- ]) + ["llvm-nm-driver.cpp"], ++ ], allow_empty = True) + ["llvm-nm-driver.cpp"], + copts = llvm_copts, + stamp = 0, + deps = [ +@@ -4096,7 +4098,7 @@ cc_binary( + srcs = glob([ + "tools/llvm-stress/*.cpp", + "tools/llvm-stress/*.h", +- ]), ++ ], allow_empty = True), + copts = llvm_copts, + stamp = 0, + deps = [ +@@ -4264,7 +4266,7 @@ cc_binary( + srcs = glob([ + "tools/llvm-profdata/*.cpp", + "tools/llvm-profdata/*.h", +- ]) + ["llvm-profdata-driver.cpp"], ++ ], allow_empty = True) + ["llvm-profdata-driver.cpp"], + copts = llvm_copts, + stamp = 0, + deps = [ +@@ -4448,7 +4450,7 @@ cc_binary( + srcs = glob([ + "tools/llvm-remark-size-diff/**/*.cpp", + "tools/llvm-remark-size-diff/**/*.h", +- ]), ++ ], allow_empty = True), + copts = llvm_copts, + includes = ["tools/llvm-reark-size-diff"], + stamp = 0, +@@ -4466,7 +4468,7 @@ cc_binary( + srcs = glob([ + "tools/llvm-rtdyld/*.cpp", + "tools/llvm-rtdyld/*.h", +- ]), ++ ], allow_empty = True), + copts = llvm_copts, + stamp = 0, + deps = [ +@@ -4508,7 +4510,7 @@ cc_binary( + srcs = glob([ + "tools/llvm-size/*.cpp", + "tools/llvm-size/*.h", +- ]) + ["llvm-size-driver.cpp"], ++ ], allow_empty = True) + ["llvm-size-driver.cpp"], + copts = llvm_copts, + stamp = 0, + deps = [ +@@ -4524,7 +4526,7 @@ cc_binary( + srcs = glob([ + "tools/llvm-split/*.cpp", + "tools/llvm-split/*.h", +- ]), ++ ], allow_empty = True), + copts = llvm_copts, + stamp = 0, + deps = [ +@@ -4554,7 +4556,7 @@ cc_binary( + srcs = glob([ + "tools/llvm-strings/*.cpp", + "tools/llvm-strings/*.h", +- ]), ++ ], allow_empty = True), + copts = llvm_copts, + stamp = 0, + deps = [ +@@ -4582,7 +4584,7 @@ cc_binary( + srcs = glob([ + "tools/llvm-symbolizer/*.cpp", + "tools/llvm-symbolizer/*.h", +- ]), ++ ], allow_empty = True), + copts = llvm_copts, + stamp = 0, + deps = [ +@@ -4608,7 +4610,7 @@ cc_binary( + srcs = glob([ + "tools/llvm-undname/*.cpp", + "tools/llvm-undname/*.h", +- ]), ++ ], allow_empty = True), + copts = llvm_copts, + stamp = 0, + deps = [ +@@ -4623,7 +4625,7 @@ cc_binary( + "tools/llvm-xray/*.cpp", + "tools/llvm-xray/*.cc", + "tools/llvm-xray/*.h", +- ]), ++ ], allow_empty = True), + copts = llvm_copts, + stamp = 0, + deps = [ +@@ -4679,7 +4681,7 @@ cc_binary( + srcs = glob([ + "tools/sancov/*.cpp", + "tools/sancov/*.h", +- ]), ++ ], allow_empty = True), + copts = llvm_copts, + stamp = 0, + deps = [ +@@ -4700,7 +4702,7 @@ cc_binary( + srcs = glob([ + "tools/sanstats/*.cpp", + "tools/sanstats/*.h", +- ]), ++ ], allow_empty = True), + copts = llvm_copts, + stamp = 0, + deps = [ +@@ -4715,7 +4717,7 @@ cc_binary( + srcs = glob([ + "utils/split-file/*.cpp", + "utils/split-file/*.h", +- ]), ++ ], allow_empty = True), + copts = llvm_copts, + stamp = 0, + deps = [ +@@ -4781,7 +4783,7 @@ cc_library( + srcs = glob([ + "lib/Testing/Support/*.cpp", + "lib/Testing/Support/*.h", +- ]), ++ ], allow_empty = True), + hdrs = glob(["include/llvm/Testing/Support/*.h"]), + copts = llvm_copts, + deps = [ +@@ -4810,7 +4812,7 @@ cc_binary( + srcs = glob([ + "utils/FileCheck/*.cpp", + "utils/FileCheck/*.h", +- ]), ++ ], allow_empty = True), + copts = llvm_copts, + stamp = 0, + deps = [ +@@ -4856,7 +4858,7 @@ cc_binary( + srcs = glob([ + "utils/count/*.c", + "utils/count/*.h", +- ]), ++ ], allow_empty = True), + stamp = 0, + ) + +@@ -4866,7 +4868,7 @@ cc_binary( + srcs = glob([ + "tools/lli/ChildTarget/*.cpp", + "tools/lli/ChildTarget/*.h", +- ]), ++ ], allow_empty = True), + copts = llvm_copts, + # The tests load code into this binary that expect to see symbols + # from libstdc++ such as __cxa_begin_catch and _ZTIi. The latter +@@ -4933,7 +4935,7 @@ cc_binary( + srcs = glob([ + "tools/llvm-diff/*.cpp", + "tools/llvm-diff/*.h", +- ]), ++ ], allow_empty = True), + copts = llvm_copts, + stamp = 0, + deps = [ +@@ -4951,7 +4953,7 @@ cc_binary( + srcs = glob([ + "tools/llvm-isel-fuzzer/*.cpp", + "tools/llvm-isel-fuzzer/*.h", +- ]), ++ ], allow_empty = True), + copts = llvm_copts, + stamp = 0, + deps = [ +@@ -4997,7 +4999,7 @@ cc_binary( + srcs = glob([ + "utils/not/*.cpp", + "utils/not/*.h", +- ]), ++ ], allow_empty = True), + copts = llvm_copts, + stamp = 0, + deps = [":Support"], +@@ -5061,7 +5063,7 @@ cc_binary( + srcs = glob([ + "tools/llvm-tli-checker/*.cpp", + "tools/llvm-tli-checker/*.h", +- ]), ++ ], allow_empty = True), + copts = llvm_copts, + stamp = 0, + deps = [ +@@ -5108,7 +5110,7 @@ cc_binary( + srcs = glob([ + "tools/verify-uselistorder/*.cpp", + "tools/verify-uselistorder/*.h", +- ]), ++ ], allow_empty = True), + copts = llvm_copts, + stamp = 0, + deps = [ +@@ -5128,7 +5130,7 @@ cc_binary( + srcs = glob([ + "tools/yaml2obj/*.cpp", + "tools/yaml2obj/*.h", +- ]), ++ ], allow_empty = True), + copts = llvm_copts, + stamp = 0, + deps = [ diff --git a/extensions/bindgen/BUILD.bazel b/extensions/bindgen/BUILD.bazel index b3cccb2ee5..b2a958a507 100644 --- a/extensions/bindgen/BUILD.bazel +++ b/extensions/bindgen/BUILD.bazel @@ -1,5 +1,10 @@ load("@bazel_skylib//:bzl_library.bzl", "bzl_library") load("//:defs.bzl", "rust_bindgen_toolchain") +load( + "//private:llvm_utils.bzl", + "cc_stdcc17_transitioned_binary", + "cc_stdcc17_transitioned_library", +) package(default_visibility = ["//visibility:public"]) @@ -20,11 +25,21 @@ bzl_library( ], ) +cc_stdcc17_transitioned_binary( + name = "clang", + target = "@llvm-project//clang:clang", +) + +cc_stdcc17_transitioned_library( + name = "libclang", + target = "@llvm-project//clang:libclang", +) + rust_bindgen_toolchain( name = "default_bindgen_toolchain_impl", bindgen = "//3rdparty:bindgen", - clang = "@llvm-project//clang:clang", - libclang = "@llvm-project//clang:libclang", + clang = ":clang", + libclang = ":libclang", ) toolchain( diff --git a/extensions/bindgen/MODULE.bazel b/extensions/bindgen/MODULE.bazel index 87470c9be8..d8cc3ad6a4 100644 --- a/extensions/bindgen/MODULE.bazel +++ b/extensions/bindgen/MODULE.bazel @@ -16,20 +16,33 @@ local_path_override( bazel_dep( name = "bazel_skylib", - version = "1.5.0", + version = "1.7.1", +) +bazel_dep( + name = "platforms", + version = "0.0.10", ) bazel_dep( name = "rules_cc", - version = "0.0.9", + version = "0.0.17", +) +bazel_dep( + name = "llvm-project", + version = "17.0.3", +) +single_version_override( + module_name = "llvm-project", + patch_strip = 1, + patches = [ + "@//3rdparty/patches:llvm-project.incompatible_disallow_empty_glob.patch", + ], ) -rust_ext_bindgen = use_extension("//:extensions.bzl", "rust_ext_bindgen") +rust_ext = use_extension("//:extensions.bzl", "rust_ext") use_repo( - rust_ext_bindgen, - "llvm-raw", - "rules_rust_bindgen_deps", + rust_ext, + "rules_rust_bindgen__bindgen-cli-0.70.1", "rules_rust_bindgen_deps__bindgen-0.70.1", - "rules_rust_bindgen_deps__bindgen-cli-0.70.1", "rules_rust_bindgen_deps__clang-sys-1.8.1", "rules_rust_bindgen_deps__clap-4.5.17", "rules_rust_bindgen_deps__clap_complete-4.5.26", @@ -39,3 +52,24 @@ use_repo( register_toolchains( "//:default_bindgen_toolchain", ) + +bazel_dep( + name = "rules_testing", + version = "0.7.0", + dev_dependency = True, +) +bazel_dep( + name = "bazel_ci_rules", + version = "1.0.0", + dev_dependency = True, +) + +rust_ext_dev = use_extension( + "//private:internal_extensions.bzl", + "rust_ext_dev", + dev_dependency = True, +) +use_repo( + rust_ext_dev, + "buildkite_config", +) diff --git a/extensions/bindgen/extensions.bzl b/extensions/bindgen/extensions.bzl index b480a597ee..48d12a32e4 100644 --- a/extensions/bindgen/extensions.bzl +++ b/extensions/bindgen/extensions.bzl @@ -2,7 +2,7 @@ load("//:repositories.bzl", "rust_bindgen_dependencies") -def _rust_ext_bindgen_impl(module_ctx): +def _rust_ext_impl(module_ctx): # This should contain the subset of WORKSPACE.bazel that defines # repositories. direct_deps = [] @@ -17,7 +17,7 @@ def _rust_ext_bindgen_impl(module_ctx): root_module_direct_dev_deps = [], ) -rust_ext_bindgen = module_extension( +rust_ext = module_extension( doc = "Dependencies for the rules_rust_bindgen extension.", - implementation = _rust_ext_bindgen_impl, + implementation = _rust_ext_impl, ) diff --git a/extensions/bindgen/private/internal_extensions.bzl b/extensions/bindgen/private/internal_extensions.bzl new file mode 100644 index 0000000000..8a3c0e3add --- /dev/null +++ b/extensions/bindgen/private/internal_extensions.bzl @@ -0,0 +1,26 @@ +"""Bzlmod internal extensions""" + +load("@bazel_ci_rules//:rbe_repo.bzl", "rbe_preconfig") + +def _rust_ext_dev_impl(module_ctx): + deps = [] + + rbe_preconfig( + name = "buildkite_config", + toolchain = "ubuntu1804-bazel-java11", + ) + + deps.append(struct(repo = "buildkite_config")) + + # is_dev_dep is ignored here. It's not relevant for internal_deps, as dev + # dependencies are only relevant for module extensions that can be used + # by other MODULES. + return module_ctx.extension_metadata( + root_module_direct_deps = [], + root_module_direct_dev_deps = [repo.repo for repo in deps], + ) + +rust_ext_dev = module_extension( + doc = "Development dependencies for the rules_rust_bindgen extension.", + implementation = _rust_ext_dev_impl, +) diff --git a/extensions/bindgen/private/llvm_utils.bzl b/extensions/bindgen/private/llvm_utils.bzl new file mode 100644 index 0000000000..3df256c671 --- /dev/null +++ b/extensions/bindgen/private/llvm_utils.bzl @@ -0,0 +1,103 @@ +"""Utilities for llvm targets""" + +load("@rules_cc//cc:defs.bzl", "CcInfo") + +def _cc_stdcc17_transition_impl(settings, attr): + # clang --cxxopt=-std=c++17 --host_cxxopt=-std=c++17 + # msvc --cxxopt=/std:c++17 --host_cxxopt=/std:c++17 + host_opt = settings["//command_line_option:host_cxxopt"] + tgt_opt = settings["//command_line_option:cxxopt"] + + host_opt.extend(attr.cxxopts) + tgt_opt.extend(attr.cxxopts) + + return { + "//command_line_option:cxxopt": tgt_opt, + "//command_line_option:host_cxxopt": host_opt, + } + +_cc_stdcc17_transition = transition( + implementation = _cc_stdcc17_transition_impl, + inputs = [ + "//command_line_option:host_cxxopt", + "//command_line_option:cxxopt", + ], + outputs = [ + "//command_line_option:host_cxxopt", + "//command_line_option:cxxopt", + ], +) + +_CXX_OPTS = select({ + "@platforms//os:windows": ["/std:c++17"], + "//conditions:default": ["-std=c++17"], +}) + +_COMMON_ATTRS = { + "cxxopts": attr.string_list( + doc = "Flags to inject into `--host_cxxopt` and `--cxxopt` command line flags.", + mandatory = True, + ), + "target": attr.label( + doc = "The target to transition.", + mandatory = True, + ), +} + +def _cc_stdcc17_transitioned_target_impl(ctx): + providers = [] + + if CcInfo in ctx.attr.target: + providers.append(ctx.attr.target[CcInfo]) + + if DefaultInfo in ctx.attr.target: + info = ctx.attr.target[DefaultInfo] + kwargs = { + "files": info.files, + "runfiles": info.default_runfiles, + } + + if info.files_to_run and info.files_to_run.executable: + exe = info.files_to_run.executable + kwargs["executable"] = ctx.actions.declare_file("{}.{}".format(ctx.label.name, exe.extension).rstrip(".")) + ctx.actions.symlink( + output = kwargs["executable"], + target_file = exe, + is_executable = True, + ) + + providers.append(DefaultInfo(**kwargs)) + + if OutputGroupInfo in ctx.attr.target: + providers.append(ctx.attr.target[OutputGroupInfo]) + + return providers + +_cc_stdcc17_transitioned_library = rule( + doc = "A rule to transition a C++ library to build with stdc++17.", + implementation = _cc_stdcc17_transitioned_target_impl, + cfg = _cc_stdcc17_transition, + attrs = _COMMON_ATTRS, +) + +_cc_stdcc17_transitioned_binary = rule( + doc = "A rule to transition a C++ binary to build with stdc++17.", + implementation = _cc_stdcc17_transitioned_target_impl, + cfg = _cc_stdcc17_transition, + attrs = _COMMON_ATTRS, + executable = True, +) + +def cc_stdcc17_transitioned_library(name, **kwargs): + _cc_stdcc17_transitioned_library( + name = name, + cxxopts = _CXX_OPTS, + **kwargs + ) + +def cc_stdcc17_transitioned_binary(name, **kwargs): + _cc_stdcc17_transitioned_binary( + name = name, + cxxopts = _CXX_OPTS, + **kwargs + ) diff --git a/extensions/bindgen/repositories.bzl b/extensions/bindgen/repositories.bzl index 7f1eaa27f1..8e7d8ddc29 100644 --- a/extensions/bindgen/repositories.bzl +++ b/extensions/bindgen/repositories.bzl @@ -21,39 +21,54 @@ load("//3rdparty/crates:defs.bzl", "crate_repositories") BINDGEN_VERSION = "0.70.1" # buildifier: disable=unnamed-macro -def rust_bindgen_dependencies(): +def rust_bindgen_dependencies(is_bzlmod = False): """Declare dependencies needed for bindgen. + Args: + is_bzlmod (bool): Whether or not this macro is called in a bzlmod context. + Returns: list[struct(repo=str, is_dev_dep=bool)]: A list of the repositories defined by this macro. """ - maybe( - http_archive, - name = "llvm-raw", - urls = ["https://github.com/llvm/llvm-project/releases/download/llvmorg-14.0.6/llvm-project-14.0.6.src.tar.xz"], - strip_prefix = "llvm-project-14.0.6.src", - sha256 = "8b3cfd7bc695bd6cea0f37f53f0981f34f87496e79e2529874fd03a2f9dd3a8a", - build_file_content = "# empty", - patch_args = ["-p1"], - patches = [ - Label("//3rdparty/patches:llvm-project.cxx17.patch"), - Label("//3rdparty/patches:llvm-project.incompatible_disallow_empty_glob.patch"), - ], - ) + if not is_bzlmod: + maybe( + http_archive, + name = "llvm-raw", + urls = ["https://github.com/llvm/llvm-project/releases/download/llvmorg-17.0.3/llvm-project-17.0.3.src.tar.xz"], + strip_prefix = "llvm-project-17.0.3.src", + integrity = "sha256-vloeRNZPMGu0T859NuOzmTaU6OYSKyNIYIkGKDwXbbg=", + build_file_content = "# empty", + patch_args = ["-p1"], + patches = [ + # Label("//3rdparty/patches:llvm-project.cxx17.patch"), + Label("//3rdparty/patches:llvm-raw.incompatible_disallow_empty_glob.patch"), + ], + ) - maybe( - http_archive, - name = "zlib", - build_file = Label("//3rdparty:BUILD.zlib.bazel"), - sha256 = "c3e5e9fdd5004dcb542feda5ee4f0ff0744628baf8ed2dd5d66f8ca1197cb1a1", - strip_prefix = "zlib-1.2.11", - urls = [ - "https://zlib.net/zlib-1.2.11.tar.gz", - "https://storage.googleapis.com/mirror.tensorflow.org/zlib.net/zlib-1.2.11.tar.gz", - ], - ) + maybe( + http_archive, + name = "zlib", + build_file = Label("//3rdparty:BUILD.zlib.bazel"), + sha256 = "c3e5e9fdd5004dcb542feda5ee4f0ff0744628baf8ed2dd5d66f8ca1197cb1a1", + strip_prefix = "zlib-1.2.11", + urls = [ + "https://zlib.net/zlib-1.2.11.tar.gz", + "https://storage.googleapis.com/mirror.tensorflow.org/zlib.net/zlib-1.2.11.tar.gz", + ], + ) + + maybe( + http_archive, + name = "zstd", + build_file = Label("//3rdparty:BUILD.zstd.bazel"), + sha256 = "7c42d56fac126929a6a85dbc73ff1db2411d04f104fae9bdea51305663a83fd0", + strip_prefix = "zstd-1.5.2", + urls = [ + "https://github.com/facebook/zstd/releases/download/v1.5.2/zstd-1.5.2.tar.gz", + ], + ) bindgen_name = "rules_rust_bindgen__bindgen-cli-{}".format(BINDGEN_VERSION) maybe( @@ -67,7 +82,6 @@ def rust_bindgen_dependencies(): ) direct_deps = [ - struct(repo = "llvm-raw", is_dev_dep = False), struct(repo = bindgen_name, is_dev_dep = False), ] direct_deps.extend(crate_repositories()) diff --git a/extensions/bindgen/transitive_repositories.bzl b/extensions/bindgen/transitive_repositories.bzl index 66c80ee5fc..6e142775c2 100644 --- a/extensions/bindgen/transitive_repositories.bzl +++ b/extensions/bindgen/transitive_repositories.bzl @@ -1,6 +1,6 @@ """Transitive dependencies for the Rust `bindgen` rules""" -load("@llvm-raw//utils/bazel:configure.bzl", "llvm_configure", "llvm_disable_optional_support_deps") +load("@llvm-raw//utils/bazel:configure.bzl", "llvm_configure") # buildifier: disable=unnamed-macro def rust_bindgen_transitive_dependencies(): @@ -8,14 +8,12 @@ def rust_bindgen_transitive_dependencies(): llvm_configure( name = "llvm-project", - repo_mapping = {"@llvm_zlib": "@zlib"}, + repo_mapping = { + "@llvm_zlib": "@zlib", + "@llvm_zstd": "@zstd", + }, targets = [ "AArch64", "X86", ], ) - - # Disables optional dependencies for Support like zlib and terminfo. You may - # instead want to configure them using the macros in the corresponding bzl - # files. - llvm_disable_optional_support_deps() diff --git a/extensions/prost/.bazelignore b/extensions/prost/.bazelignore index 8c29e7dd07..68062bda56 100644 --- a/extensions/prost/.bazelignore +++ b/extensions/prost/.bazelignore @@ -1,5 +1,5 @@ examples bazel-out bazel-testlogs -bazel-extensions +bazel-prost bazel-bin diff --git a/extensions/prost/.bazelrc b/extensions/prost/.bazelrc index 6b20ca4b70..f3e5a5d06f 100644 --- a/extensions/prost/.bazelrc +++ b/extensions/prost/.bazelrc @@ -60,9 +60,8 @@ build --incompatible_merge_fixed_and_default_shell_env ## Bzlmod ############################################################################### -# TODO: migrate all dependencies from WORKSPACE to MODULE.bazel -# https://github.com/bazelbuild/rules_rust/issues/2181 -common --noenable_bzlmod --enable_workspace +# A configuration for disabling bzlmod. +common:no-bzlmod --noenable_bzlmod --enable_workspace # Disable the bzlmod lockfile, so we don't accidentally commit MODULE.bazel.lock common --lockfile_mode=off diff --git a/extensions/prost/MODULE.bazel b/extensions/prost/MODULE.bazel index fa1842e434..7b59f68316 100644 --- a/extensions/prost/MODULE.bazel +++ b/extensions/prost/MODULE.bazel @@ -16,11 +16,11 @@ local_path_override( bazel_dep( name = "bazel_skylib", - version = "1.5.0", + version = "1.7.1", ) bazel_dep( name = "rules_cc", - version = "0.0.9", + version = "0.0.17", ) bazel_dep( name = "rules_proto", @@ -28,13 +28,13 @@ bazel_dep( ) bazel_dep( name = "protobuf", - version = "21.7", + version = "28.3", repo_name = "com_google_protobuf", ) -rust_ext_prost = use_extension("//:extensions.bzl", "rust_ext_prost") +rust_ext = use_extension("//:extensions.bzl", "rust_ext") use_repo( - rust_ext_prost, + rust_ext, "rules_rust_prost_deps", "rules_rust_prost_deps__h2-0.4.6", "rules_rust_prost_deps__heck", @@ -50,3 +50,25 @@ use_repo( register_toolchains( "//:default_prost_toolchain", ) + +bazel_dep( + name = "googleapis", + version = "0.0.0-20240819-fe8ba054a", + dev_dependency = True, + repo_name = "com_google_googleapis", +) +bazel_dep( + name = "bazel_ci_rules", + version = "1.0.0", + dev_dependency = True, +) + +rust_ext_dev = use_extension( + "//private:internal_extensions.bzl", + "rust_ext_dev", + dev_dependency = True, +) +use_repo( + rust_ext_dev, + "buildkite_config", +) diff --git a/extensions/prost/WORKSPACE.bazel b/extensions/prost/WORKSPACE.bazel index 7b6296a252..f59107e98b 100644 --- a/extensions/prost/WORKSPACE.bazel +++ b/extensions/prost/WORKSPACE.bazel @@ -33,6 +33,11 @@ load("//:transitive_repositories.bzl", "rust_prost_transitive_repositories") rust_prost_transitive_repositories() +# Needed by protobuf +load("@rules_python//python:repositories.bzl", "py_repositories") + +py_repositories() + # buildifier: disable=bzl-visibility load("//private/tests:deps.bzl", "prost_test_deps") diff --git a/extensions/prost/extensions.bzl b/extensions/prost/extensions.bzl index 1fc8e4bf37..f3b956933c 100644 --- a/extensions/prost/extensions.bzl +++ b/extensions/prost/extensions.bzl @@ -2,7 +2,7 @@ load("//:repositories.bzl", "rust_prost_dependencies") -def _rust_ext_prost_impl(module_ctx): +def _rust_ext_impl(module_ctx): # This should contain the subset of WORKSPACE.bazel that defines # repositories. direct_deps = [] @@ -17,7 +17,7 @@ def _rust_ext_prost_impl(module_ctx): root_module_direct_dev_deps = [], ) -rust_ext_prost = module_extension( - doc = "Dependencies for rules_rust extensions.", - implementation = _rust_ext_prost_impl, +rust_ext = module_extension( + doc = "Dependencies for the rules_rust prost extension.", + implementation = _rust_ext_impl, ) diff --git a/extensions/prost/private/internal_extensions.bzl b/extensions/prost/private/internal_extensions.bzl new file mode 100644 index 0000000000..3b76d5e6ad --- /dev/null +++ b/extensions/prost/private/internal_extensions.bzl @@ -0,0 +1,26 @@ +"""Bzlmod internal extensions""" + +load("@bazel_ci_rules//:rbe_repo.bzl", "rbe_preconfig") + +def _rust_ext_dev_impl(module_ctx): + deps = [] + + rbe_preconfig( + name = "buildkite_config", + toolchain = "ubuntu1804-bazel-java11", + ) + + deps.append(struct(repo = "buildkite_config")) + + # is_dev_dep is ignored here. It's not relevant for internal_deps, as dev + # dependencies are only relevant for module extensions that can be used + # by other MODULES. + return module_ctx.extension_metadata( + root_module_direct_deps = [], + root_module_direct_dev_deps = [repo.repo for repo in deps], + ) + +rust_ext_dev = module_extension( + doc = "Development dependencies for the rules_rust_prost extension.", + implementation = _rust_ext_dev_impl, +) diff --git a/extensions/prost/private/tests/well_known_types/well_known_types_test.rs b/extensions/prost/private/tests/well_known_types/well_known_types_test.rs index f74796ee6d..eb985dc53d 100644 --- a/extensions/prost/private/tests/well_known_types/well_known_types_test.rs +++ b/extensions/prost/private/tests/well_known_types/well_known_types_test.rs @@ -2,11 +2,11 @@ use well_known_types_proto::any_proto::google::protobuf::Any; use well_known_types_proto::api_proto::google::protobuf::{Api, Method, Mixin}; -use well_known_types_proto::compiler_plugin_proto::google::protobuf::compiler::Version; use well_known_types_proto::descriptor_proto::google::protobuf::DescriptorProto; use well_known_types_proto::duration_proto::google::protobuf::Duration; use well_known_types_proto::empty_proto::google::protobuf::Empty; use well_known_types_proto::field_mask_proto::google::protobuf::FieldMask; +use well_known_types_proto::plugin_proto::google::protobuf::compiler::Version; use well_known_types_proto::source_context_proto::google::protobuf::SourceContext; use well_known_types_proto::struct_proto::google::protobuf::Struct; use well_known_types_proto::struct_proto::google::protobuf::Value; diff --git a/extensions/prost/repositories.bzl b/extensions/prost/repositories.bzl index 27a0772519..57180921a7 100644 --- a/extensions/prost/repositories.bzl +++ b/extensions/prost/repositories.bzl @@ -36,9 +36,9 @@ def rust_prost_dependencies(bzlmod = False): maybe( http_archive, name = "com_google_protobuf", - sha256 = "52b6160ae9266630adb5e96a9fc645215336371a740e87d411bfb63ea2f268a0", - strip_prefix = "protobuf-3.18.0", - urls = ["https://github.com/protocolbuffers/protobuf/releases/download/v3.18.0/protobuf-all-3.18.0.tar.gz"], + integrity = "sha256-fD69eq7dhvpdxHmg/agD9gLKr3jYr/fOg7ieG4rnRCo=", + strip_prefix = "protobuf-28.3", + urls = ["https://github.com/protocolbuffers/protobuf/releases/download/v28.3/protobuf-28.3.tar.gz"], ) maybe( http_archive, diff --git a/extensions/prost/transitive_repositories.bzl b/extensions/prost/transitive_repositories.bzl index 60c99ed545..277fd41169 100644 --- a/extensions/prost/transitive_repositories.bzl +++ b/extensions/prost/transitive_repositories.bzl @@ -1,6 +1,7 @@ """Definitions for loading transitive `@rules_rust//proto` dependencies""" load("@bazel_features//:deps.bzl", "bazel_features_deps") +load("@com_google_protobuf//:protobuf_deps.bzl", "protobuf_deps") load("@rules_proto//proto:repositories.bzl", "rules_proto_dependencies") def rust_prost_transitive_repositories(): @@ -11,3 +12,5 @@ def rust_prost_transitive_repositories(): rules_proto_dependencies() bazel_features_deps() + + protobuf_deps() diff --git a/extensions/protobuf/.bazelignore b/extensions/protobuf/.bazelignore index 8c29e7dd07..8233d3bb0d 100644 --- a/extensions/protobuf/.bazelignore +++ b/extensions/protobuf/.bazelignore @@ -1,5 +1,5 @@ examples bazel-out bazel-testlogs -bazel-extensions +bazel-protobuf bazel-bin diff --git a/extensions/protobuf/.bazelrc b/extensions/protobuf/.bazelrc index 57431732ce..b29663d9c4 100644 --- a/extensions/protobuf/.bazelrc +++ b/extensions/protobuf/.bazelrc @@ -64,9 +64,8 @@ build --incompatible_merge_fixed_and_default_shell_env ## Bzlmod ############################################################################### -# TODO: migrate all dependencies from WORKSPACE to MODULE.bazel -# https://github.com/bazelbuild/rules_rust/issues/2181 -common --noenable_bzlmod --enable_workspace +# A configuration for disabling bzlmod. +common:no-bzlmod --noenable_bzlmod --enable_workspace # Disable the bzlmod lockfile, so we don't accidentally commit MODULE.bazel.lock common --lockfile_mode=off diff --git a/extensions/protobuf/3rdparty/patches/README.md b/extensions/protobuf/3rdparty/patches/README.md index 1b19afb6c7..082164365c 100644 --- a/extensions/protobuf/3rdparty/patches/README.md +++ b/extensions/protobuf/3rdparty/patches/README.md @@ -20,8 +20,3 @@ For this crate, the patch that is applied is replacing the include! macro with what would be generated by the build.rs file. This lets us avoid running the build file altogether, at the expense of having to update the patch for every version. - - -## com_google_protobuf-v3.10.0-bzl_visibility - -The patches here provide the required visibility to `*.bzl` files used by the rules defined in `com_google_protobuf`. diff --git a/extensions/protobuf/3rdparty/patches/com_google_protobuf-v3.10.0-bzl_visibility.patch b/extensions/protobuf/3rdparty/patches/com_google_protobuf-v3.10.0-bzl_visibility.patch deleted file mode 100644 index ad694e22d1..0000000000 --- a/extensions/protobuf/3rdparty/patches/com_google_protobuf-v3.10.0-bzl_visibility.patch +++ /dev/null @@ -1,14 +0,0 @@ -diff --git a/BUILD b/BUILD -index efc3d8e7f..77e3ea413 100644 ---- a/BUILD -+++ b/BUILD -@@ -1236,3 +1236,9 @@ sh_test( - "update_file_lists.sh", - ], - ) -+ -+filegroup( -+ name = "bzl_srcs", -+ srcs = glob(["**/*.bzl"]), -+ visibility = ["//visibility:public"], -+) diff --git a/extensions/protobuf/MODULE.bazel b/extensions/protobuf/MODULE.bazel index a362f1954d..43dda3f5f5 100644 --- a/extensions/protobuf/MODULE.bazel +++ b/extensions/protobuf/MODULE.bazel @@ -16,11 +16,15 @@ local_path_override( bazel_dep( name = "bazel_skylib", - version = "1.5.0", + version = "1.7.1", +) +bazel_dep( + name = "platforms", + version = "0.0.10", ) bazel_dep( name = "rules_cc", - version = "0.0.9", + version = "0.0.17", ) bazel_dep( name = "rules_proto", @@ -28,14 +32,19 @@ bazel_dep( ) bazel_dep( name = "protobuf", - version = "21.7", + version = "28.3", repo_name = "com_google_protobuf", ) -rust_ext_protobuf = use_extension("//:extensions.bzl", "rust_ext_protobuf") +bazel_dep( + name = "bazel_ci_rules", + version = "1.0.0", + dev_dependency = True, +) + +rust_ext = use_extension("//:extensions.bzl", "rust_ext") use_repo( - rust_ext_protobuf, - "rules_rust_protobuf_deps", + rust_ext, "rules_rust_protobuf_deps__grpc-0.6.2", "rules_rust_protobuf_deps__grpc-compiler-0.6.2", "rules_rust_protobuf_deps__log-0.4.17", @@ -48,3 +57,13 @@ use_repo( register_toolchains( "//:default_proto_toolchain", ) + +rust_ext_dev = use_extension( + "//private:internal_extensions.bzl", + "rust_ext_dev", + dev_dependency = True, +) +use_repo( + rust_ext_dev, + "buildkite_config", +) diff --git a/extensions/protobuf/WORKSPACE.bazel b/extensions/protobuf/WORKSPACE.bazel index e0a8bc7075..fe7c379926 100644 --- a/extensions/protobuf/WORKSPACE.bazel +++ b/extensions/protobuf/WORKSPACE.bazel @@ -32,6 +32,11 @@ load("//:transitive_repositories.bzl", "rust_proto_protobuf_transitive_repositor rust_proto_protobuf_transitive_repositories() +# Needed by protobuf +load("@rules_python//python:repositories.bzl", "py_repositories") + +py_repositories() + load("@bazel_skylib//:workspace.bzl", "bazel_skylib_workspace") bazel_skylib_workspace() diff --git a/extensions/protobuf/extensions.bzl b/extensions/protobuf/extensions.bzl index fb37952d0a..9a6df1c598 100644 --- a/extensions/protobuf/extensions.bzl +++ b/extensions/protobuf/extensions.bzl @@ -2,7 +2,7 @@ load("//:repositories.bzl", "rust_proto_protobuf_dependencies") -def _rust_ext_protobuf_impl(module_ctx): +def _rust_ext_impl(module_ctx): # This should contain the subset of WORKSPACE.bazel that defines # repositories. direct_deps = [] @@ -17,7 +17,7 @@ def _rust_ext_protobuf_impl(module_ctx): root_module_direct_dev_deps = [], ) -rust_ext_protobuf = module_extension( - doc = "Dependencies for rules_rust extensions.", - implementation = _rust_ext_protobuf_impl, +rust_ext = module_extension( + doc = "Dependencies for the rules_rust protobuf extension.", + implementation = _rust_ext_impl, ) diff --git a/extensions/protobuf/private/BUILD.bazel b/extensions/protobuf/private/BUILD.bazel new file mode 100644 index 0000000000..e69de29bb2 diff --git a/extensions/protobuf/private/internal_extensions.bzl b/extensions/protobuf/private/internal_extensions.bzl new file mode 100644 index 0000000000..06c51353d3 --- /dev/null +++ b/extensions/protobuf/private/internal_extensions.bzl @@ -0,0 +1,26 @@ +"""Bzlmod internal extensions""" + +load("@bazel_ci_rules//:rbe_repo.bzl", "rbe_preconfig") + +def _rust_ext_dev_impl(module_ctx): + deps = [] + + rbe_preconfig( + name = "buildkite_config", + toolchain = "ubuntu1804-bazel-java11", + ) + + deps.append(struct(repo = "buildkite_config")) + + # is_dev_dep is ignored here. It's not relevant for internal_deps, as dev + # dependencies are only relevant for module extensions that can be used + # by other MODULES. + return module_ctx.extension_metadata( + root_module_direct_deps = [], + root_module_direct_dev_deps = [repo.repo for repo in deps], + ) + +rust_ext_dev = module_extension( + doc = "Development dependencies for the rules_rust_protobuf extension.", + implementation = _rust_ext_dev_impl, +) diff --git a/extensions/protobuf/repositories.bzl b/extensions/protobuf/repositories.bzl index 0d6f7d0c5e..6b7dfb80f9 100644 --- a/extensions/protobuf/repositories.bzl +++ b/extensions/protobuf/repositories.bzl @@ -40,16 +40,9 @@ def rust_proto_protobuf_dependencies(bzlmod = False): maybe( http_archive, name = "com_google_protobuf", - sha256 = "758249b537abba2f21ebc2d02555bf080917f0f2f88f4cbe2903e0e28c4187ed", - strip_prefix = "protobuf-3.10.0", - urls = [ - "https://mirror.bazel.build/github.com/protocolbuffers/protobuf/archive/v3.10.0.tar.gz", - "https://github.com/protocolbuffers/protobuf/archive/v3.10.0.tar.gz", - ], - patch_args = ["-p1"], - patches = [ - Label("//3rdparty/patches:com_google_protobuf-v3.10.0-bzl_visibility.patch"), - ], + integrity = "sha256-fD69eq7dhvpdxHmg/agD9gLKr3jYr/fOg7ieG4rnRCo=", + strip_prefix = "protobuf-28.3", + urls = ["https://github.com/protocolbuffers/protobuf/releases/download/v28.3/protobuf-28.3.tar.gz"], ) return crate_repositories() diff --git a/extensions/protobuf/transitive_repositories.bzl b/extensions/protobuf/transitive_repositories.bzl index 06c80470f7..0241e6bf74 100644 --- a/extensions/protobuf/transitive_repositories.bzl +++ b/extensions/protobuf/transitive_repositories.bzl @@ -3,6 +3,7 @@ load("@bazel_features//:deps.bzl", "bazel_features_deps") load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") load("@bazel_tools//tools/build_defs/repo:utils.bzl", "maybe") +load("@com_google_protobuf//:protobuf_deps.bzl", "protobuf_deps") load("@rules_proto//proto:repositories.bzl", "rules_proto_dependencies") def rust_proto_protobuf_transitive_repositories(): @@ -25,3 +26,5 @@ def rust_proto_protobuf_transitive_repositories(): "https://storage.googleapis.com/mirror.tensorflow.org/zlib.net/zlib-1.2.11.tar.gz", ], ) + + protobuf_deps() diff --git a/extensions/wasm_bindgen/.bazelignore b/extensions/wasm_bindgen/.bazelignore index 8c29e7dd07..4fda9c604c 100644 --- a/extensions/wasm_bindgen/.bazelignore +++ b/extensions/wasm_bindgen/.bazelignore @@ -1,5 +1,7 @@ -examples bazel-out bazel-testlogs -bazel-extensions +bazel-wasm_bindgen bazel-bin + +# Deprecated +rules_nodejs diff --git a/extensions/wasm_bindgen/.bazelrc b/extensions/wasm_bindgen/.bazelrc index 6b20ca4b70..f3e5a5d06f 100644 --- a/extensions/wasm_bindgen/.bazelrc +++ b/extensions/wasm_bindgen/.bazelrc @@ -60,9 +60,8 @@ build --incompatible_merge_fixed_and_default_shell_env ## Bzlmod ############################################################################### -# TODO: migrate all dependencies from WORKSPACE to MODULE.bazel -# https://github.com/bazelbuild/rules_rust/issues/2181 -common --noenable_bzlmod --enable_workspace +# A configuration for disabling bzlmod. +common:no-bzlmod --noenable_bzlmod --enable_workspace # Disable the bzlmod lockfile, so we don't accidentally commit MODULE.bazel.lock common --lockfile_mode=off diff --git a/extensions/wasm_bindgen/MODULE.bazel b/extensions/wasm_bindgen/MODULE.bazel index a0e3e4920c..ae74450730 100644 --- a/extensions/wasm_bindgen/MODULE.bazel +++ b/extensions/wasm_bindgen/MODULE.bazel @@ -16,25 +16,24 @@ local_path_override( bazel_dep( name = "bazel_skylib", - version = "1.5.0", + version = "1.7.1", ) bazel_dep( - name = "rules_cc", - version = "0.0.9", + name = "platforms", + version = "0.0.10", ) bazel_dep( - name = "aspect_rules_js", - version = "1.39.0", + name = "rules_cc", + version = "0.0.17", ) bazel_dep( - name = "rules_nodejs", - version = "5.8.5", + name = "aspect_rules_js", + version = "2.1.1", ) -rust_ext_wasm_bindgen = use_extension("//:extensions.bzl", "rust_ext_wasm_bindgen") +rust_ext = use_extension("//:extensions.bzl", "rust_ext") use_repo( - rust_ext_wasm_bindgen, - "rrwbd", + rust_ext, "rrwbd__anyhow-1.0.71", "rrwbd__assert_cmd-1.0.8", "rrwbd__diff-0.1.13", @@ -60,4 +59,22 @@ use_repo( register_toolchains( "//:default_wasm_bindgen_toolchain", + "@rules_rust//rust/private/dummy_cc_toolchain:dummy_cc_wasm32_toolchain", + "@rules_rust//rust/private/dummy_cc_toolchain:dummy_cc_wasm64_toolchain", +) + +bazel_dep( + name = "bazel_ci_rules", + version = "1.0.0", + dev_dependency = True, +) + +rust_ext_dev = use_extension( + "//private:internal_extensions.bzl", + "rust_ext_dev", + dev_dependency = True, +) +use_repo( + rust_ext_dev, + "buildkite_config", ) diff --git a/extensions/wasm_bindgen/WORKSPACE.bazel b/extensions/wasm_bindgen/WORKSPACE.bazel index 7a2baf56d1..9ff1eae1ca 100644 --- a/extensions/wasm_bindgen/WORKSPACE.bazel +++ b/extensions/wasm_bindgen/WORKSPACE.bazel @@ -30,10 +30,6 @@ load("//rules_js:repositories.bzl", "js_rust_wasm_bindgen_dependencies") js_rust_wasm_bindgen_dependencies() -load("//rules_nodejs:repositories.bzl", "nodejs_rust_wasm_bindgen_dependencies") - -nodejs_rust_wasm_bindgen_dependencies() - load("@bazel_skylib//:workspace.bzl", "bazel_skylib_workspace") bazel_skylib_workspace() @@ -50,16 +46,6 @@ rules_js_register_toolchains(node_version = DEFAULT_NODE_VERSION) load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") -http_archive( - name = "build_bazel_rules_nodejs", - sha256 = "709cc0dcb51cf9028dd57c268066e5bc8f03a119ded410a13b5c3925d6e43c48", - urls = ["https://github.com/bazelbuild/rules_nodejs/releases/download/5.8.4/rules_nodejs-5.8.4.tar.gz"], -) - -load("@build_bazel_rules_nodejs//:index.bzl", "node_repositories") - -node_repositories() - http_archive( name = "bazel_ci_rules", sha256 = "eca21884e6f66a88c358e580fd67a6b148d30ab57b1680f62a96c00f9bc6a07e", diff --git a/extensions/wasm_bindgen/defs.bzl b/extensions/wasm_bindgen/defs.bzl index 181f1dc0d5..c838f80071 100644 --- a/extensions/wasm_bindgen/defs.bzl +++ b/extensions/wasm_bindgen/defs.bzl @@ -2,6 +2,11 @@ Bazel rules for generating wasm modules for Javascript using [wasm-bindgen][wb]. +## Rules + +- [rust_wasm_bindgen](#rust_wasm_bindgen) +- [rust_wasm_bindgen_toolchain](#rust_wasm_bindgen_toolchain) + ## Setup To begin using the `wasm-bindgen` rules, users can load the necessary dependencies @@ -22,15 +27,15 @@ should avoid calling `rust_wasm_bindgen_register_toolchains` and instead use the [rust_wasm_bindgen_toolchain](#rust_wasm_bindgen_toolchain) rule to define their own toolchains to register in the workspace. -### Interfacing with Javascript rules +## Interfacing with Javascript rules While it's recommended for users to mantain their own , in the `@rules_rust_wasm_bindgen` package there exists interface sub-packages for various -Javascript Bazel rules. E.g. `build_bazel_rules_nodejs` or `aspect_rules_js`. The -rules defined there are a more convenient way to use `rust_wasm_bindgen` with the -associated javascript rules due to the inclusion of additional providers. Each -directory contains a `defs.bzl` file that defines the different variants of -`rust_wasm_bindgen`. (e.g. `nodejs_rust_wasm_bindgen` for the `rules_nodejs` submodule). +Javascript Bazel rules. E.g. `aspect_rules_js`. The rules defined there are a more +convenient way to use `rust_wasm_bindgen` with the associated javascript rules due +to the inclusion of additional providers. Each directory contains a `defs.bzl` file +that defines the different variants of `rust_wasm_bindgen`. (e.g. `js_rust_wasm_bindgen` +for the `rules_js` submodule). [wb]: https://github.com/rustwasm/wasm-bindgen diff --git a/extensions/wasm_bindgen/extensions.bzl b/extensions/wasm_bindgen/extensions.bzl index 37444316b6..bb7dd76865 100644 --- a/extensions/wasm_bindgen/extensions.bzl +++ b/extensions/wasm_bindgen/extensions.bzl @@ -1,18 +1,12 @@ """Bzlmod module extensions""" load("//:repositories.bzl", "rust_wasm_bindgen_dependencies") -load("//bindgen:repositories.bzl", "rust_bindgen_dependencies") -load("//prost:repositories.bzl", "rust_prost_dependencies") -load("//protobuf:repositories.bzl", "rust_proto_protobuf_dependencies") def _rust_ext_impl(module_ctx): # This should contain the subset of WORKSPACE.bazel that defines # repositories. direct_deps = [] - direct_deps.extend(rust_prost_dependencies(bzlmod = True)) - direct_deps.extend(rust_proto_protobuf_dependencies(bzlmod = True)) - direct_deps.extend(rust_bindgen_dependencies()) direct_deps.extend(rust_wasm_bindgen_dependencies()) # is_dev_dep is ignored here. It's not relevant for internal_deps, as dev @@ -24,6 +18,6 @@ def _rust_ext_impl(module_ctx): ) rust_ext = module_extension( - doc = "Dependencies for rules_rust extensions.", + doc = "Dependencies for the rules_rust wasm_bindgen extension.", implementation = _rust_ext_impl, ) diff --git a/extensions/wasm_bindgen/private/internal_extensions.bzl b/extensions/wasm_bindgen/private/internal_extensions.bzl new file mode 100644 index 0000000000..23c40d64e6 --- /dev/null +++ b/extensions/wasm_bindgen/private/internal_extensions.bzl @@ -0,0 +1,26 @@ +"""Bzlmod internal extensions""" + +load("@bazel_ci_rules//:rbe_repo.bzl", "rbe_preconfig") + +def _rust_ext_dev_impl(module_ctx): + deps = [] + + rbe_preconfig( + name = "buildkite_config", + toolchain = "ubuntu1804-bazel-java11", + ) + + deps.append(struct(repo = "buildkite_config")) + + # is_dev_dep is ignored here. It's not relevant for internal_deps, as dev + # dependencies are only relevant for module extensions that can be used + # by other MODULES. + return module_ctx.extension_metadata( + root_module_direct_deps = [], + root_module_direct_dev_deps = [repo.repo for repo in deps], + ) + +rust_ext_dev = module_extension( + doc = "Development dependencies for the rules_rust_wasm_bindgen extension.", + implementation = _rust_ext_dev_impl, +) diff --git a/extensions/wasm_bindgen/rules_js/test/BUILD.bazel b/extensions/wasm_bindgen/rules_js/test/BUILD.bazel index 03b221ca24..b587ca0f01 100644 --- a/extensions/wasm_bindgen/rules_js/test/BUILD.bazel +++ b/extensions/wasm_bindgen/rules_js/test/BUILD.bazel @@ -1,14 +1,8 @@ load("@aspect_rules_js//js:defs.bzl", "js_library", "js_test") -load("@bazel_skylib//rules:copy_file.bzl", "copy_file") +load("@bazel_skylib//rules:build_test.bzl", "build_test") load("@rules_rust//rust:defs.bzl", "rust_binary", "rust_shared_library") load("@rules_rust_wasm_bindgen//rules_js:defs.bzl", "js_rust_wasm_bindgen") -copy_file( - name = "hello_world_wasm_test.src", - src = "//test:hello_world_wasm_test.js", - out = "hello_world_wasm_test.js", -) - rust_binary( name = "hello_world_bin_wasm", srcs = ["//test:main.rs"], @@ -76,13 +70,13 @@ _WASM_DATA = [ js_test( name = "hello_world_wasm_direct_test", data = _WASM_DATA, - entry_point = ":hello_world_wasm_test.js", + entry_point = "hello_world_wasm_test.js", ) js_library( name = "hello_world_wasm_lib", srcs = [ - ":hello_world_wasm_test.js", + "hello_world_wasm_test.js", ], data = _WASM_DATA, deps = [], @@ -95,3 +89,8 @@ js_test( ], entry_point = ":hello_world_wasm_lib", ) + +build_test( + name = "build_test", + targets = _WASM_DATA, +) diff --git a/extensions/wasm_bindgen/test/hello_world_wasm_test.js b/extensions/wasm_bindgen/rules_js/test/hello_world_wasm_test.js similarity index 100% rename from extensions/wasm_bindgen/test/hello_world_wasm_test.js rename to extensions/wasm_bindgen/rules_js/test/hello_world_wasm_test.js diff --git a/extensions/wasm_bindgen/rules_nodejs/BUILD.bazel b/extensions/wasm_bindgen/rules_nodejs/BUILD.bazel index 153f72df79..a289cdf9aa 100644 --- a/extensions/wasm_bindgen/rules_nodejs/BUILD.bazel +++ b/extensions/wasm_bindgen/rules_nodejs/BUILD.bazel @@ -9,8 +9,9 @@ exports_files([ bzl_library( name = "bzl_lib", srcs = glob(["**/*.bzl"]), + tags = ["manuel"], deps = [ "//:bzl_lib", - "@rules_nodejs//nodejs:bzl", + "@rules_nodejs//nodejs:bzl_lib", ], ) diff --git a/extensions/wasm_bindgen/rules_nodejs/test/BUILD.bazel b/extensions/wasm_bindgen/rules_nodejs/test/BUILD.bazel deleted file mode 100644 index 610033fd58..0000000000 --- a/extensions/wasm_bindgen/rules_nodejs/test/BUILD.bazel +++ /dev/null @@ -1,68 +0,0 @@ -load("@build_bazel_rules_nodejs//:index.bzl", "nodejs_test") -load("@rules_rust//rust:defs.bzl", "rust_binary", "rust_shared_library") -load("@rules_rust_wasm_bindgen//rules_nodejs:defs.bzl", "nodejs_rust_wasm_bindgen") - -rust_binary( - name = "hello_world_bin_wasm", - srcs = ["//test:main.rs"], - edition = "2018", - deps = [ - "@rules_rust_wasm_bindgen//3rdparty:wasm_bindgen", - ], -) - -rust_shared_library( - name = "hello_world_lib_wasm", - srcs = ["//test:main.rs"], - edition = "2018", - deps = [ - "@rules_rust_wasm_bindgen//3rdparty:wasm_bindgen", - ], -) - -nodejs_rust_wasm_bindgen( - name = "hello_world_bundler_wasm_bindgen", - wasm_file = ":hello_world_bin_wasm", -) - -nodejs_rust_wasm_bindgen( - name = "hello_world_web_wasm_bindgen", - target = "web", - wasm_file = ":hello_world_lib_wasm", -) - -nodejs_rust_wasm_bindgen( - name = "hello_world_deno_wasm_bindgen", - target = "deno", - wasm_file = ":hello_world_lib_wasm", -) - -nodejs_rust_wasm_bindgen( - name = "hello_world_nomodules_wasm_bindgen", - target = "no-modules", - wasm_file = ":hello_world_lib_wasm", -) - -nodejs_rust_wasm_bindgen( - name = "hello_world_nodejs_wasm_bindgen", - target = "nodejs", - wasm_file = ":hello_world_lib_wasm", -) - -nodejs_test( - name = "hello_world_wasm_test", - args = ["rules_nodejs"], - data = [ - ":hello_world_bundler_wasm_bindgen", - ":hello_world_deno_wasm_bindgen", - ":hello_world_nodejs_wasm_bindgen", - ":hello_world_nomodules_wasm_bindgen", - ":hello_world_web_wasm_bindgen", - ], - entry_point = "//test:hello_world_wasm_test.js", - # TODO: Fix test on Windows - target_compatible_with = select({ - "@platforms//os:windows": ["@platforms//:incompatible"], - "//conditions:default": [], - }), -)