[llvm] [bazel] Updated lit_test to work from external workspaces (PR #204489)

via llvm-commits llvm-commits at lists.llvm.org
Sun Jul 5 12:48:51 PDT 2026


https://github.com/UebelAndre updated https://github.com/llvm/llvm-project/pull/204489

>From 8726584ffe893334c3223ca637b8827830435abf Mon Sep 17 00:00:00 2001
From: UebelAndre <github at uebelandre.com>
Date: Wed, 17 Jun 2026 16:12:54 -0700
Subject: [PATCH] [bazel] Updated lit_test to work from external workspaces

---
 utils/bazel/.bazelrc                          |   7 +-
 .../include-cleaner/BUILD.bazel               |  35 ++--
 .../llvm-project-overlay/llvm/BUILD.bazel     |   9 +-
 .../llvm-project-overlay/llvm/lit_test.bzl    | 188 ++++++++++++++++--
 .../llvm/utils/lit/BUILD.bazel                |  28 +++
 .../llvm/utils/lit/tests/BUILD.bazel          |  17 +-
 .../llvm-project-overlay/mlir/tblgen.bzl      |  21 +-
 .../mlir/test/BUILD.bazel                     | 121 ++++++-----
 8 files changed, 311 insertions(+), 115 deletions(-)
 create mode 100644 utils/bazel/llvm-project-overlay/llvm/utils/lit/BUILD.bazel

diff --git a/utils/bazel/.bazelrc b/utils/bazel/.bazelrc
index bad694419d334..805284abb7888 100644
--- a/utils/bazel/.bazelrc
+++ b/utils/bazel/.bazelrc
@@ -9,8 +9,11 @@
 
 common --enable_bzlmod --noenable_workspace
 
-# TODO: Remove lit test reliance on this
-common --legacy_external_runfiles
+# Force the runfiles layout without the legacy `external/<repo>/...` mirror,
+# to match the Bazel 9+ default once --legacy_external_runfiles is removed.
+# All lit_expand_template callers use `File.short_path` (`../<repo>/...`
+# form) so no target relies on the legacy layout.
+common --nolegacy_external_runfiles
 
 # Prevent automatic __init__.py generation from confusing some lit tests.
 common --incompatible_default_to_explicit_init_py
diff --git a/utils/bazel/llvm-project-overlay/clang-tools-extra/include-cleaner/BUILD.bazel b/utils/bazel/llvm-project-overlay/clang-tools-extra/include-cleaner/BUILD.bazel
index 6f1f5b8d21556..acf4803b90434 100644
--- a/utils/bazel/llvm-project-overlay/clang-tools-extra/include-cleaner/BUILD.bazel
+++ b/utils/bazel/llvm-project-overlay/clang-tools-extra/include-cleaner/BUILD.bazel
@@ -2,9 +2,8 @@
 # See https://llvm.org/LICENSE.txt for license information.
 # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
 
-load("@bazel_skylib//rules:expand_template.bzl", "expand_template")
 load("@rules_cc//cc:defs.bzl", "cc_binary", "cc_library", "cc_test")
-load("//llvm:lit_test.bzl", "lit_test", "package_path")
+load("//llvm:lit_test.bzl", "lit_expand_template", "lit_test")
 
 package(
     default_visibility = ["//visibility:public"],
@@ -86,31 +85,23 @@ cc_test(
     ],
 )
 
-LLVM_LIT_PATH_FUNCTION = " " + \
-                         "# Allow generated file to be relocatable.\n" + \
-                         "from pathlib import Path\n" + \
-                         "def path(p):\n" + \
-                         "    p = Path(p)\n" + \
-                         "    if p.exists: return str(p.resolve())\n" + \
-                         "    if not p: return ''\n" + \
-                         "    return str((Path(__file__).parent / p).resolve())\n"
-
-LIT_SITE_CFG_IN_HEADER = "# Autogenerated, do not edit." + LLVM_LIT_PATH_FUNCTION
-
-expand_template(
+lit_expand_template(
     name = "lit_site_cfg_py",
     testonly = True,
     out = "test/lit.site.cfg.py",
+    dirname_substitutions = {
+        # Anchor on a file that lives in each target directory so the rule
+        # can read its `short_path.dirname`.
+        "@CMAKE_CURRENT_BINARY_DIR@": ":test/lit.cfg.py",
+        "@CMAKE_CURRENT_SOURCE_DIR@": ":test/lit.cfg.py",
+        "@CURRENT_TOOLS_DIR@": ":BUILD.bazel",
+        "@LLVM_LIBS_DIR@": "//llvm:BUILD.bazel",
+        "@LLVM_LIT_TOOLS_DIR@": "//llvm:BUILD.bazel",
+        "@LLVM_TOOLS_DIR@": "//llvm:BUILD.bazel",
+    },
     substitutions = {
-        "@CMAKE_CURRENT_BINARY_DIR@": package_path("//clang-tools-extra/include-cleaner:BUILD") + "/test",
-        "@CMAKE_CURRENT_SOURCE_DIR@": package_path("//clang-tools-extra/include-cleaner:BUILD") + "/test",
-        "@CURRENT_TOOLS_DIR@": package_path("//clang-tools-extra/include-cleaner:BUILD"),
-        "@LIT_SITE_CFG_IN_HEADER@": LIT_SITE_CFG_IN_HEADER,
-        "@LLVM_LIBS_DIR@": package_path("//llvm:BUILD"),
-        "@LLVM_LIT_TOOLS_DIR@": package_path("//llvm:BUILD"),
-        "@LLVM_TOOLS_DIR@": package_path("//llvm:BUILD"),
-        "@TARGET_TRIPLE@": "",
         '"@Python3_EXECUTABLE@"': "sys.executable",
+        "@TARGET_TRIPLE@": "",
     },
     template = "test/lit.site.cfg.py.in",
 )
diff --git a/utils/bazel/llvm-project-overlay/llvm/BUILD.bazel b/utils/bazel/llvm-project-overlay/llvm/BUILD.bazel
index 7de8be322a4b3..ab3aca2fb3463 100644
--- a/utils/bazel/llvm-project-overlay/llvm/BUILD.bazel
+++ b/utils/bazel/llvm-project-overlay/llvm/BUILD.bazel
@@ -51,7 +51,6 @@ exports_files([
     "include/llvm/Frontend/OpenMP/OMP.td",
     "include/llvm/IR/Intrinsics.td",
     "include/llvm/Option/OptParser.td",
-    "utils/lit/lit.py",
     # This one is needed for building and vendoring out lldb from off tree.
     "utils/lldbDataFormatters.py",
 ])
@@ -6586,11 +6585,13 @@ cc_library(
     ],
 )
 
-py_binary(
+# Compatibility alias: the lit sources have moved to //llvm/utils/lit:lit
+# (a py_library, matching where the upstream tool actually lives). Kept
+# here so downstream callers of `//llvm:lit` don't break.
+alias(
     name = "lit",
     testonly = True,
-    srcs = ["utils/lit/lit.py"] + glob(["utils/lit/lit/**/*.py"]),
-    imports = ["utils/lit"],
+    actual = "//llvm/utils/lit:lit_bin",
 )
 
 py_binary(
diff --git a/utils/bazel/llvm-project-overlay/llvm/lit_test.bzl b/utils/bazel/llvm-project-overlay/llvm/lit_test.bzl
index 64528f28492f5..2194c22ae148c 100644
--- a/utils/bazel/llvm-project-overlay/llvm/lit_test.bzl
+++ b/utils/bazel/llvm-project-overlay/llvm/lit_test.bzl
@@ -6,6 +6,174 @@
 load("@bazel_skylib//lib:paths.bzl", "paths")
 load("@rules_python//python:defs.bzl", _py_test = "py_test")
 
+# Python helper that resolves a path against the .cfg file's own location.
+# Injected into rendered lit.site.cfg files so that dirname substitutions
+# (which lit_expand_template renders as cfg-relative paths) resolve to absolute
+# runfiles paths at test runtime. Mirrors CMake's LLVM_LIT_PATH_FUNCTION from
+# llvm/cmake/modules/AddLLVM.cmake.
+_LIT_SITE_CFG_PATH_FUNCTION = (
+    "import os\n" +
+    "def path(p):\n" +
+    "    if not p: return ''\n" +
+    "    return os.path.abspath(os.path.join(os.path.dirname(__file__), p))\n"
+)
+
+_LIT_SITE_CFG_IN_HEADER = "# Autogenerated, do not edit.\n" + _LIT_SITE_CFG_PATH_FUNCTION
+
+def _short_path_relpath(from_dir, to_dir):
+    """Returns the relative path from from_dir to to_dir.
+
+    Both arguments are runfiles-root-relative (short_path-style) directories.
+    Any leading `..` segments that short_path uses for files in external repos
+    are treated as ordinary components, so resolutions within the same repo
+    (main<->main or external<->external) produce the correct relative path.
+    """
+    if from_dir == to_dir:
+        return "."
+    from_parts = [p for p in from_dir.split("/") if p]
+    to_parts = [p for p in to_dir.split("/") if p]
+    common = 0
+    for i in range(min(len(from_parts), len(to_parts))):
+        if from_parts[i] != to_parts[i]:
+            break
+        common += 1
+    parts = [".."] * (len(from_parts) - common) + to_parts[common:]
+    return "/".join(parts) if parts else "."
+
+def _lit_expand_template_impl(ctx):
+    out = ctx.outputs.out
+    cfg_dir = paths.dirname(out.short_path)
+
+    substitutions = {"@LIT_SITE_CFG_IN_HEADER@": _LIT_SITE_CFG_IN_HEADER}
+    for key, value in ctx.attr.substitutions.items():
+        if key in substitutions:
+            fail("substitution %r conflicts with a built-in key" % key)
+        substitutions[key] = value
+
+    # dirname_anchors is a label_keyed_string_dict whose values are JSON-encoded
+    # lists of placeholder strings. label_keyed_string_dict ships in stock
+    # Bazel (unlike string_keyed_label_dict, which requires Bazel 9+), so the
+    # macro inverts the user-facing `placeholder -> label` mapping into this
+    # form before handing it to the rule.
+    for anchor_target, placeholders_json in ctx.attr.dirname_anchors.items():
+        files = anchor_target.files.to_list()
+        if not files:
+            fail("dirname_substitutions anchor %s yielded no files" %
+                 anchor_target.label)
+
+        # Each placeholder resolves to the dirname of the anchor file (via its
+        # short_path); the file's content is irrelevant. A BUILD.bazel label is
+        # the conventional pick because every package has one.
+        anchor_dir = paths.dirname(files[0].short_path)
+        rel = _short_path_relpath(cfg_dir, anchor_dir)
+        rendered = "\" + path(\"%s\") + \"" % rel
+
+        for placeholder in json.decode(placeholders_json):
+            if placeholder in substitutions:
+                fail("dirname substitution %r conflicts with another substitution" %
+                     placeholder)
+
+            # The upstream lit.site.cfg(.py).in templates write path-bearing
+            # variables as bare string literals: `config.x = "@VAR@"`.
+            # Substituting the inner placeholder with `" + path("rel") + "`
+            # turns the line into `config.x = "" + path("rel") + ""`, which
+            # evaluates at lit-load time to the absolute runfiles path
+            # without modifying the template.
+            substitutions[placeholder] = rendered
+
+    ctx.actions.expand_template(
+        template = ctx.file.template,
+        output = out,
+        substitutions = substitutions,
+    )
+
+    return [DefaultInfo(
+        files = depset([out]),
+    )]
+
+_lit_expand_template = rule(
+    implementation = _lit_expand_template_impl,
+    doc = "Backing rule for the `lit_expand_template` macro; do not use directly.",
+    attrs = {
+        "dirname_anchors": attr.label_keyed_string_dict(
+            doc = "Anchor label -> JSON-encoded list of placeholders. For " +
+                  "each entry, the placeholders are replaced with a " +
+                  "`path(\"rel\")` call resolving to the dirname of the " +
+                  "anchor file at lit-load time. Built by the " +
+                  "`lit_expand_template` macro from its " +
+                  "`dirname_substitutions` argument.",
+            allow_files = True,
+        ),
+        "out": attr.output(
+            doc = "Generated lit.site.cfg(.py) file.",
+            mandatory = True,
+        ),
+        "substitutions": attr.string_dict(
+            doc = "Placeholder -> literal-string substitutions applied to " +
+                  "the template. `@LIT_SITE_CFG_IN_HEADER@` is reserved.",
+        ),
+        "template": attr.label(
+            allow_single_file = True,
+            mandatory = True,
+            doc = "Upstream lit.site.cfg(.py).in template to render.",
+        ),
+    },
+)
+
+def lit_expand_template(
+        name,
+        template,
+        out,
+        substitutions = None,
+        dirname_substitutions = None,
+        **kwargs):
+    """Renders an upstream lit.site.cfg(.py).in template for Bazel.
+
+    The upstream `.in` templates are kept unmodified. The macro:
+    - injects a `path()` helper at the top via the `@LIT_SITE_CFG_IN_HEADER@`
+      substitution slot,
+    - replaces `@VAR@` placeholders listed in `substitutions` with literal
+      strings, and
+    - replaces each placeholder in `dirname_substitutions` with a
+      `path("rel")` call that resolves at test runtime to the absolute
+      runfiles path of the anchor file's directory.
+
+    Args:
+      name: target name.
+      template: label of the upstream `.in` template.
+      out: filename of the rendered `lit.site.cfg(.py)` to generate.
+      substitutions: dict[str, str]. Placeholder -> literal substitution.
+      dirname_substitutions: dict[str, label]. Placeholder -> label of a file
+        whose containing directory the placeholder should resolve to. The
+        label is typically a `//pkg:BUILD.bazel`; only its file's
+        `short_path.dirname` is read. The macro inverts this to a
+        `label_keyed_string_dict` keyed by anchor label, with JSON-encoded
+        placeholder lists as values, so the rule works on Bazel versions
+        without `string_keyed_label_dict`.
+      **kwargs: forwarded to the underlying rule (e.g. `testonly`,
+        `visibility`).
+    """
+    dirname_substitutions = dirname_substitutions or {}
+
+    # Group placeholders by anchor label so the same label appears only once
+    # in the label_keyed_string_dict.
+    placeholders_by_anchor = {}
+    for placeholder, anchor in dirname_substitutions.items():
+        placeholders_by_anchor.setdefault(anchor, []).append(placeholder)
+    dirname_anchors = {
+        anchor: json.encode(sorted(placeholders))
+        for anchor, placeholders in placeholders_by_anchor.items()
+    }
+
+    _lit_expand_template(
+        name = name,
+        template = template,
+        out = out,
+        substitutions = substitutions or {},
+        dirname_anchors = dirname_anchors,
+        **kwargs
+    )
+
 def lit_test(
         name,
         srcs,
@@ -33,23 +201,15 @@ def lit_test(
     args = args or []
     data = data or []
     deps = deps or []
+
+    main = Label("//llvm/utils/lit:lit.py")
     py_test(
         name = name,
-        srcs = [Label("//llvm:lit")],
-        main = Label("//llvm:utils/lit/lit.py"),
-        args = args + ["-v"] + ["$(execpath %s)" % src for src in srcs],
+        srcs = [main],
+        main = main,
+        args = args + ["-v"] + ["$(rootpath %s)" % src for src in srcs],
         data = data + srcs,
         legacy_create_init = False,
-        deps = deps + [Label("//llvm:lit")],
+        deps = deps + [Label("//llvm/utils/lit")],
         **kwargs
     )
-
-def package_path(label):
-    """Returns the path to the package of 'label'.
-
-    Args:
-      label: label. The label to return the package path of.
-
-    For example, package_path("@foo//bar:BUILD") returns 'external/foo/bar'.
-    """
-    return paths.join(Label(label).workspace_root, Label(label).package)
diff --git a/utils/bazel/llvm-project-overlay/llvm/utils/lit/BUILD.bazel b/utils/bazel/llvm-project-overlay/llvm/utils/lit/BUILD.bazel
new file mode 100644
index 0000000000000..3caf6cd7d6485
--- /dev/null
+++ b/utils/bazel/llvm-project-overlay/llvm/utils/lit/BUILD.bazel
@@ -0,0 +1,28 @@
+# This file is licensed under the Apache License v2.0 with LLVM Exceptions.
+# See https://llvm.org/LICENSE.txt for license information.
+# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+
+load("@rules_python//python:py_library.bzl", "py_library")
+load("@rules_python//python:py_binary.bzl", "py_binary")
+
+package(default_visibility = ["//visibility:public"])
+
+licenses(["notice"])
+
+exports_files([
+    "lit.py",
+])
+
+py_library(
+    name = "lit",
+    testonly = True,
+    srcs = ["lit.py"] + glob(["lit/**/*.py"]),
+    imports = ["."],
+)
+
+py_binary(
+    name = "lit_bin",
+    srcs = ["lit.py"],
+    main = "lit.py",
+    deps = [":lit"],
+)
diff --git a/utils/bazel/llvm-project-overlay/llvm/utils/lit/tests/BUILD.bazel b/utils/bazel/llvm-project-overlay/llvm/utils/lit/tests/BUILD.bazel
index 55115fab47af6..1e4ec6c6cfe7a 100644
--- a/utils/bazel/llvm-project-overlay/llvm/utils/lit/tests/BUILD.bazel
+++ b/utils/bazel/llvm-project-overlay/llvm/utils/lit/tests/BUILD.bazel
@@ -2,19 +2,17 @@
 # See https://llvm.org/LICENSE.txt for license information.
 # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
 
-load("@bazel_skylib//rules:expand_template.bzl", "expand_template")
-load("//llvm:lit_test.bzl", "lit_test", "package_path")
+load("//llvm:lit_test.bzl", "lit_expand_template", "lit_test")
 
-expand_template(
+lit_expand_template(
     name = "lit_site_cfg",
     testonly = True,
     out = "lit.site.cfg",
-    substitutions = {
-        "@LIT_SITE_CFG_IN_HEADER@": "# Autogenerated, do not edit.",
-        "@LLVM_LIT_TOOLS_DIR@": package_path("//llvm/utils/lit:BUILD"),
-        "@LLVM_SOURCE_DIR@": package_path("//llvm:BUILD"),
-        "@LLVM_BINARY_DIR@": package_path("//llvm:BUILD"),
-        "@LLVM_TOOLS_DIR@": package_path("//llvm:BUILD"),
+    dirname_substitutions = {
+        "@LLVM_BINARY_DIR@": "//llvm:BUILD.bazel",
+        "@LLVM_LIT_TOOLS_DIR@": "//llvm/utils/lit:BUILD.bazel",
+        "@LLVM_SOURCE_DIR@": "//llvm:BUILD.bazel",
+        "@LLVM_TOOLS_DIR@": "//llvm:BUILD.bazel",
     },
     template = "lit.site.cfg.in",
 )
@@ -23,7 +21,6 @@ expand_template(
     lit_test(
         name = "%s.test" % src,
         srcs = [src],
-        args = ["--path %s" % package_path("//llvm:BUILD")],
         data = [
             "check-tested-lit-timeout-ability",
             "lit.cfg",
diff --git a/utils/bazel/llvm-project-overlay/mlir/tblgen.bzl b/utils/bazel/llvm-project-overlay/mlir/tblgen.bzl
index 38d56d099fe8a..fd395b36579c6 100644
--- a/utils/bazel/llvm-project-overlay/mlir/tblgen.bzl
+++ b/utils/bazel/llvm-project-overlay/mlir/tblgen.bzl
@@ -229,13 +229,30 @@ def _gentbl_test_impl(ctx):
         ctx.attr.deps,
     )
 
+    # The test runs from the runfiles tree, where files live under
+    # `<repo>/<package>/...` (with external repos at `../<repo>/...`) — not
+    # under `external/<repo>/...` or `bazel-out/<cfg>/bin/<repo>/...` as at
+    # execroot. Convert execroot-relative paths to the runfiles form so tblgen
+    # can open them from the test's CWD.
+    bin_prefix = ctx.bin_dir.path + "/"
+    genfiles_prefix = ctx.genfiles_dir.path + "/"
+
+    def _runfiles_path(p):
+        if p.startswith(bin_prefix):
+            p = p[len(bin_prefix):]
+        elif p.startswith(genfiles_prefix):
+            p = p[len(genfiles_prefix):]
+        if p.startswith("external/"):
+            return "../" + p[len("external/"):]
+        return p
+
     test_args = [ctx.executable.tblgen.short_path]
     test_args.extend(ctx.attr.opts)
-    test_args.append(td_file.path)
+    test_args.append(_runfiles_path(td_file.path))
     test_args.extend([
         arg
         for include in trans_includes.to_list()
-        for arg in ["-I", include, "-I", paths.join(ctx.bin_dir.path, include)]
+        for arg in ["-I", _runfiles_path(include), "-I", _runfiles_path(paths.join(ctx.bin_dir.path, include))]
     ])
 
     test_args.extend(["-o", "/dev/null"])
diff --git a/utils/bazel/llvm-project-overlay/mlir/test/BUILD.bazel b/utils/bazel/llvm-project-overlay/mlir/test/BUILD.bazel
index bcfc3ea9b8e65..244a2fb6584d5 100644
--- a/utils/bazel/llvm-project-overlay/mlir/test/BUILD.bazel
+++ b/utils/bazel/llvm-project-overlay/mlir/test/BUILD.bazel
@@ -2,9 +2,8 @@
 # See https://llvm.org/LICENSE.txt for license information.
 # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
 
-load("@bazel_skylib//rules:expand_template.bzl", "expand_template")
 load("@rules_cc//cc:defs.bzl", "cc_library")
-load("//llvm:lit_test.bzl", "package_path")
+load("//llvm:lit_test.bzl", "lit_expand_template")
 load("//llvm:targets.bzl", "llvm_targets")
 load("//mlir:tblgen.bzl", "gentbl_cc_library", "gentbl_sharded_ops", "td_library")
 
@@ -15,52 +14,52 @@ package(
 
 licenses(["notice"])
 
-LLVM_LIT_PATH_FUNCTION = " " + \
-                         "# Allow generated file to be relocatable.\n" + \
-                         "from pathlib import Path\n" + \
-                         "def path(p):\n" + \
-                         "    if not p: return ''\n" + \
-                         "    return str((Path(__file__).parent / p).resolve())\n"
-
-LIT_SITE_CFG_IN_HEADER = "# Autogenerated, do not edit." + LLVM_LIT_PATH_FUNCTION
-
-expand_template(
+lit_expand_template(
     name = "lit_site_cfg_py",
     testonly = True,
     out = "lit.site.cfg.py",
+    dirname_substitutions = {
+        "@LLVM_TOOLS_DIR@": "//llvm:BUILD.bazel",
+        "@MLIR_SOURCE_DIR@": "//mlir:BUILD.bazel",
+        "@MLIR_TOOLS_DIR@": "//mlir:BUILD.bazel",
+        # SHLIBDIR is already wrapped with path() in the upstream template
+        # (config.llvm_shlib_dir = lit_config.substitute(path(r"@SHLIBDIR@"))),
+        # but the double-wrap is harmless because path() is idempotent on
+        # absolute inputs.
+        "@SHLIBDIR@": "//llvm:BUILD.bazel",
+    },
     substitutions = {
-        "@LIT_SITE_CFG_IN_HEADER@": LIT_SITE_CFG_IN_HEADER,
-        "@LLVM_TOOLS_DIR@": package_path("//llvm:BUILD"),
-        "@ENABLE_SHARED@": "1",
+        # MLIR_BINARY_DIR is a string-literal substitution: the entire
+        # `"@MLIR_BINARY_DIR@"` (including its surrounding quotes) is replaced
+        # with a Python expression that reads the per-test undeclared outputs
+        # directory at lit-load time.
+        "\"@MLIR_BINARY_DIR@\"": "os.environ[\"TEST_UNDECLARED_OUTPUTS_DIR\"]",
         "@BUILD_SHARED_LIBS@": "1",
         "@ENABLE_ASSERTIONS@": "1",
-        "@MLIR_SOURCE_DIR@": package_path("//mlir:BUILD"),
-        "@MLIR_TOOLS_DIR@": package_path("//mlir:BUILD"),
-        "\"@MLIR_BINARY_DIR@\"": "os.environ[\"TEST_UNDECLARED_OUTPUTS_DIR\"]",
+        "@ENABLE_SHARED@": "1",
         # All disabled, but required to substituted because they are not in quotes.
         "@LLVM_BUILD_EXAMPLES@": "0",
+        "@LLVM_HAS_AMDGPU_TARGET@": "0",
         "@LLVM_HAS_NVPTX_TARGET@": "0",
         "@LLVM_INCLUDE_SPIRV_TOOLS_TESTS@": "0",
+        "@MLIR_ENABLE_BINDINGS_PYTHON@": "0",
         "@MLIR_ENABLE_CUDA_RUNNER@": "0",
-        "@LLVM_HAS_AMDGPU_TARGET@": "0",
-        "@MLIR_ENABLE_ROCM_RUNNER@": "0",
-        "@MLIR_ENABLE_SYCL_RUNNER@": "0",
         "@MLIR_ENABLE_LEVELZERO_RUNNER@": "0",
+        "@MLIR_ENABLE_PYTHON_STABLE_ABI@": "0",
+        "@MLIR_ENABLE_ROCM_RUNNER@": "0",
         "@MLIR_ENABLE_SPIRV_CPU_RUNNER@": "0",
+        "@MLIR_ENABLE_SYCL_RUNNER@": "0",
         "@MLIR_ENABLE_VULKAN_RUNNER@": "0",
-        "@MLIR_ENABLE_BINDINGS_PYTHON@": "0",
         "@MLIR_ENABLE_XEVM_CONVERSIONS@": "0",
-        "@MLIR_ENABLE_PYTHON_STABLE_ABI@": "0",
-        "@MLIR_RUN_ARM_SVE_TESTS@": "0",
+        "@MLIR_INCLUDE_INTEGRATION_TESTS@": "0",
         "@MLIR_RUN_ARM_SME_TESTS@": "0",
-        "@MLIR_RUN_X86_TESTS@": "0",
-        "@MLIR_RUN_X86_AMX_TESTS@": "0",
-        "@MLIR_RUN_CUDA_TENSOR_CORE_TESTS@": "0",
-        "@MLIR_RUN_CUDA_SM80_TESTS@": "0",
+        "@MLIR_RUN_ARM_SVE_TESTS@": "0",
         "@MLIR_RUN_CUDA_SM80_LT_TESTS@": "0",
+        "@MLIR_RUN_CUDA_SM80_TESTS@": "0",
         "@MLIR_RUN_CUDA_SM90_TESTS@": "0",
-        "@MLIR_INCLUDE_INTEGRATION_TESTS@": "0",
-        "@SHLIBDIR@": package_path("//llvm:BUILD"),
+        "@MLIR_RUN_CUDA_TENSOR_CORE_TESTS@": "0",
+        "@MLIR_RUN_X86_AMX_TESTS@": "0",
+        "@MLIR_RUN_X86_TESTS@": "0",
     },
     template = "lit.site.cfg.py.in",
 )
@@ -144,8 +143,8 @@ gentbl_cc_library(
     name = "TestOpsSyntaxIncGen",
     strip_include_prefix = "lib/Dialect/Test",
     tbl_outs = {
-        "lib/Dialect/Test/TestOpsSyntax.h.inc": ["-gen-op-decls"],
         "lib/Dialect/Test/TestOpsSyntax.cpp.inc": ["-gen-op-defs"],
+        "lib/Dialect/Test/TestOpsSyntax.h.inc": ["-gen-op-decls"],
     },
     tblgen = "//mlir:mlir-tblgen",
     td_file = "lib/Dialect/Test/TestOpsSyntax.td",
@@ -159,14 +158,14 @@ gentbl_cc_library(
     name = "TestOpsIncGen",
     strip_include_prefix = "lib/Dialect/Test",
     tbl_outs = {
-        "lib/Dialect/Test/TestOpsDialect.h.inc": [
-            "-gen-dialect-decls",
-            "-dialect=test",
-        ],
         "lib/Dialect/Test/TestOpsDialect.cpp.inc": [
             "-gen-dialect-defs",
             "-dialect=test",
         ],
+        "lib/Dialect/Test/TestOpsDialect.h.inc": [
+            "-gen-dialect-decls",
+            "-dialect=test",
+        ],
         "lib/Dialect/Test/TestPatterns.inc": ["-gen-rewriters"],
     },
     tblgen = "//mlir:mlir-tblgen",
@@ -181,12 +180,12 @@ gentbl_cc_library(
     name = "TestInterfacesIncGen",
     strip_include_prefix = "lib/Dialect/Test",
     tbl_outs = {
-        "lib/Dialect/Test/TestAttrInterfaces.h.inc": ["-gen-attr-interface-decls"],
         "lib/Dialect/Test/TestAttrInterfaces.cpp.inc": ["-gen-attr-interface-defs"],
-        "lib/Dialect/Test/TestTypeInterfaces.h.inc": ["-gen-type-interface-decls"],
-        "lib/Dialect/Test/TestTypeInterfaces.cpp.inc": ["-gen-type-interface-defs"],
-        "lib/Dialect/Test/TestOpInterfaces.h.inc": ["-gen-op-interface-decls"],
+        "lib/Dialect/Test/TestAttrInterfaces.h.inc": ["-gen-attr-interface-decls"],
         "lib/Dialect/Test/TestOpInterfaces.cpp.inc": ["-gen-op-interface-defs"],
+        "lib/Dialect/Test/TestOpInterfaces.h.inc": ["-gen-op-interface-decls"],
+        "lib/Dialect/Test/TestTypeInterfaces.cpp.inc": ["-gen-type-interface-defs"],
+        "lib/Dialect/Test/TestTypeInterfaces.h.inc": ["-gen-type-interface-decls"],
     },
     tblgen = "//mlir:mlir-tblgen",
     td_file = "lib/Dialect/Test/TestInterfaces.td",
@@ -201,14 +200,14 @@ gentbl_cc_library(
     name = "TestAttrDefsIncGen",
     strip_include_prefix = "lib/Dialect/Test",
     tbl_outs = {
-        "lib/Dialect/Test/TestAttrDefs.h.inc": [
-            "-gen-attrdef-decls",
-            "--attrdefs-dialect=test",
-        ],
         "lib/Dialect/Test/TestAttrDefs.cpp.inc": [
             "-gen-attrdef-defs",
             "--attrdefs-dialect=test",
         ],
+        "lib/Dialect/Test/TestAttrDefs.h.inc": [
+            "-gen-attrdef-decls",
+            "--attrdefs-dialect=test",
+        ],
     },
     tblgen = "//mlir:mlir-tblgen",
     td_file = "lib/Dialect/Test/TestOps.td",
@@ -222,8 +221,8 @@ gentbl_cc_library(
     name = "TestEnumDefsIncGen",
     strip_include_prefix = "lib/Dialect/Test",
     tbl_outs = {
-        "lib/Dialect/Test/TestOpEnums.h.inc": ["-gen-enum-decls"],
         "lib/Dialect/Test/TestOpEnums.cpp.inc": ["-gen-enum-defs"],
+        "lib/Dialect/Test/TestOpEnums.h.inc": ["-gen-enum-decls"],
     },
     tblgen = "//mlir:mlir-tblgen",
     td_file = "lib/Dialect/Test/TestEnumDefs.td",
@@ -237,14 +236,14 @@ gentbl_cc_library(
     name = "TestTypeDefsIncGen",
     strip_include_prefix = "lib/Dialect/Test",
     tbl_outs = {
-        "lib/Dialect/Test/TestTypeDefs.h.inc": [
-            "-gen-typedef-decls",
-            "--typedefs-dialect=test",
-        ],
         "lib/Dialect/Test/TestTypeDefs.cpp.inc": [
             "-gen-typedef-defs",
             "--typedefs-dialect=test",
         ],
+        "lib/Dialect/Test/TestTypeDefs.h.inc": [
+            "-gen-typedef-decls",
+            "--typedefs-dialect=test",
+        ],
     },
     tblgen = "//mlir:mlir-tblgen",
     td_file = "lib/Dialect/Test/TestTypeDefs.td",
@@ -308,23 +307,23 @@ gentbl_cc_library(
     name = "TestTransformDialectExtensionIncGen",
     strip_include_prefix = "lib/Dialect/Transform",
     tbl_outs = {
-        "lib/Dialect/Transform/TestTransformDialectExtension.h.inc": ["-gen-op-decls"],
         "lib/Dialect/Transform/TestTransformDialectExtension.cpp.inc": ["-gen-op-defs"],
-        "lib/Dialect/Transform/TestTransformDialectExtensionTypes.h.inc": [
-            "-gen-typedef-decls",
-            "-typedefs-dialect=transform",
-        ],
-        "lib/Dialect/Transform/TestTransformDialectExtensionTypes.cpp.inc": [
-            "-gen-typedef-defs",
-            "-typedefs-dialect=transform",
+        "lib/Dialect/Transform/TestTransformDialectExtension.h.inc": ["-gen-op-decls"],
+        "lib/Dialect/Transform/TestTransformDialectExtensionAttrs.cpp.inc": [
+            "-gen-attrdef-defs",
+            "-attrdefs-dialect=transform",
         ],
         "lib/Dialect/Transform/TestTransformDialectExtensionAttrs.h.inc": [
             "-gen-attrdef-decls",
             "-attrdefs-dialect=transform",
         ],
-        "lib/Dialect/Transform/TestTransformDialectExtensionAttrs.cpp.inc": [
-            "-gen-attrdef-defs",
-            "-attrdefs-dialect=transform",
+        "lib/Dialect/Transform/TestTransformDialectExtensionTypes.cpp.inc": [
+            "-gen-typedef-defs",
+            "-typedefs-dialect=transform",
+        ],
+        "lib/Dialect/Transform/TestTransformDialectExtensionTypes.h.inc": [
+            "-gen-typedef-decls",
+            "-typedefs-dialect=transform",
         ],
     },
     tblgen = "//mlir:mlir-tblgen",
@@ -494,8 +493,8 @@ gentbl_cc_library(
     includes = ["lib/Interfaces/TilingInterface"],
     strip_include_prefix = "lib",
     tbl_outs = {
-        "lib/Interfaces/TilingInterface/TestTilingInterfaceTransformOps.h.inc": ["-gen-op-decls"],
         "lib/Interfaces/TilingInterface/TestTilingInterfaceTransformOps.cpp.inc": ["-gen-op-defs"],
+        "lib/Interfaces/TilingInterface/TestTilingInterfaceTransformOps.h.inc": ["-gen-op-decls"],
     },
     tblgen = "//mlir:mlir-tblgen",
     td_file = "lib/Interfaces/TilingInterface/TestTilingInterfaceTransformOps.td",
@@ -615,8 +614,8 @@ gentbl_cc_library(
     includes = ["lib/Dialect/Test"],
     strip_include_prefix = "lib",
     tbl_outs = {
-        "lib/TestTransformsOps.h.inc": ["-gen-op-decls"],
         "lib/TestTransformsOps.cpp.inc": ["-gen-op-defs"],
+        "lib/TestTransformsOps.h.inc": ["-gen-op-decls"],
     },
     tblgen = "//mlir:mlir-tblgen",
     td_file = "lib/Transforms/TestTransformsOps.td",



More information about the llvm-commits mailing list