diff --git a/utils/bazel/llvm-project-overlay/llvm/BUILD.bazel b/utils/bazel/llvm-project-overlay/llvm/BUILD.bazel --- a/utils/bazel/llvm-project-overlay/llvm/BUILD.bazel +++ b/utils/bazel/llvm-project-overlay/llvm/BUILD.bazel @@ -28,6 +28,12 @@ ] # A command-line flag for restricting the list of LLVM targets to build. +# +# See `llvm_targets` in `:targets.bzl` for the full list of available targets. +# +# Usage: +# +# $ bazel build --@llvm-projectllvm:targets=AArch64,X86 --config=generic_clang @llvm-project... string_list_flag( name = "targets", build_setting_default = llvm_targets, @@ -43,7 +49,7 @@ for target in llvm_targets ] -# Replace macros in headers with lists of enabled targets. +# Expand LLVM target enumerations in C++ headers with lists of enabled targets. [ enum_targets_gen( name = name, diff --git a/utils/bazel/llvm-project-overlay/llvm/enum_targets_gen.bzl b/utils/bazel/llvm-project-overlay/llvm/enum_targets_gen.bzl --- a/utils/bazel/llvm-project-overlay/llvm/enum_targets_gen.bzl +++ b/utils/bazel/llvm-project-overlay/llvm/enum_targets_gen.bzl @@ -53,7 +53,9 @@ ), "valid_targets": attr.string_list( mandatory = True, - doc = "A list of LLVM targets that are valid for this enum.", + doc = "A list of LLVM targets that are valid for this enum. " + + "Since this value depends on what files are present, it " + + "must be evaluated outside the implementation of the rule.", ), "targets": attr.label( mandatory = True, diff --git a/utils/bazel/llvm-project-overlay/llvm/target_macros.bzl b/utils/bazel/llvm-project-overlay/llvm/target_macros.bzl --- a/utils/bazel/llvm-project-overlay/llvm/target_macros.bzl +++ b/utils/bazel/llvm-project-overlay/llvm/target_macros.bzl @@ -17,10 +17,10 @@ return [m.split("/")[2] for m in matches] def enabled_targets(pattern): - """Build a list of Bazel targets matching the pattern. + """Build a list of enabled LLVM targets. - This macro builds an expression that evaluates to a list of enabled - Bazel targets of the form ``. + This macro builds a depency list that evaluates to Bazel targets of the + form `` for every enabled LLVM target. """ # Build a list of selects that either choose the Bazel target or not, # depending on the `:targets` flag. @@ -32,7 +32,7 @@ for t in llvm_targets ] # Fold over the selects with "+". - result = selects[0] - for s in selects[1:]: + result = [] + for s in selects: result += s return result