[llvm] [bazel][test] Continue fixing bazel build from 97dee78 (PR #141336)

Pat Doyle via llvm-commits llvm-commits at lists.llvm.org
Sat May 24 01:25:54 PDT 2025


https://github.com/patdoyle-google created https://github.com/llvm/llvm-project/pull/141336

this continues the work in 0967a6f by generating a header from clang-tools-extra/unittests/clang-doc/config.h.cmake

not clear all the tests pass yet, but fixes this build error at least:

ERROR: /var/lib/buildkite-agent/.cache/bazel/_bazel_buildkite-agent/6a1efeb401da192d3572f00e2f11245b/external/llvm-project/clang-tools-extra/unittests/BUILD.bazel:57:8: Compiling clang-tools-extra/unittests/clang-doc/HTMLMustacheGeneratorTest.cpp failed: (Exit 1): clang failed: error executing CppCompile command (from target @@llvm-project//clang-tools-extra/unittests:clang_doc_test) /usr/lib/llvm-18/bin/clang -U_FORTIFY_SOURCE -fstack-protector -Wall -Wthread-safety -Wself-assign -Wunused-but-set-parameter -Wno-free-nonheap-object -fcolor-diagnostics -fno-omit-frame-pointer ... (remaining 328 arguments skipped)
Use --sandbox_debug to see verbose messages from the sandbox and retain the sandbox build root for debugging
external/llvm-project/clang-tools-extra/unittests/clang-doc/HTMLMustacheGeneratorTest.cpp:12:10: fatal error: 'config.h' file not found
   12 | #include "config.h"
      |          ^~~~~~~~~~
1 error generated.

>From fd185319f99749aeb1992a6e8949aa533a116760 Mon Sep 17 00:00:00 2001
From: Pat Doyle <patdoyle at google.com>
Date: Fri, 23 May 2025 21:43:31 -0700
Subject: [PATCH 1/2] first attempt

---
 .../clang-tools-extra/unittests/BUILD.bazel           | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/utils/bazel/llvm-project-overlay/clang-tools-extra/unittests/BUILD.bazel b/utils/bazel/llvm-project-overlay/clang-tools-extra/unittests/BUILD.bazel
index e282e98bd571f..9ec49eff08af3 100644
--- a/utils/bazel/llvm-project-overlay/clang-tools-extra/unittests/BUILD.bazel
+++ b/utils/bazel/llvm-project-overlay/clang-tools-extra/unittests/BUILD.bazel
@@ -2,6 +2,7 @@
 # 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_test")
 
 package(
@@ -54,6 +55,15 @@ cc_test(
     ],
 )
 
+expand_template(
+    name = "clang_doc_config",
+    out = "clang-doc/config.h",
+    substitutions = {
+        "#define CLANG_DOC_TEST_ASSET_DIR \"${CLANG_DOC_TEST_ASSET_DIR}\"": "#define CLANG_DOC_TEST_ASSET_DIR \"clang-tools-extra/clang-doc/assets\"",
+    },
+    template = "clang-doc/config.h.cmake",
+)
+
 cc_test(
     name = "clang_doc_test",
     size = "small",
@@ -65,7 +75,6 @@ cc_test(
         allow_empty = False,
     ),
     data = ["//clang-tools-extra/clang-doc:assets"],
-    local_defines = ['CLANG_DOC_TEST_ASSET_DIR=\\"clang-tools-extra/clang-doc/assets\\"'],
     deps = [
         "//clang:ast",
         "//clang:basic",

>From 9807f6a0ca2160a09241af0a00c4dddf8687a726 Mon Sep 17 00:00:00 2001
From: Pat Doyle <patdoyle at google.com>
Date: Sat, 24 May 2025 01:15:16 -0700
Subject: [PATCH 2/2] should work now

---
 .../clang-tools-extra/unittests/BUILD.bazel            | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/utils/bazel/llvm-project-overlay/clang-tools-extra/unittests/BUILD.bazel b/utils/bazel/llvm-project-overlay/clang-tools-extra/unittests/BUILD.bazel
index 9ec49eff08af3..09c0f50b43d13 100644
--- a/utils/bazel/llvm-project-overlay/clang-tools-extra/unittests/BUILD.bazel
+++ b/utils/bazel/llvm-project-overlay/clang-tools-extra/unittests/BUILD.bazel
@@ -56,7 +56,7 @@ cc_test(
 )
 
 expand_template(
-    name = "clang_doc_config",
+    name = "clang_doc_config_h",
     out = "clang-doc/config.h",
     substitutions = {
         "#define CLANG_DOC_TEST_ASSET_DIR \"${CLANG_DOC_TEST_ASSET_DIR}\"": "#define CLANG_DOC_TEST_ASSET_DIR \"clang-tools-extra/clang-doc/assets\"",
@@ -64,6 +64,11 @@ expand_template(
     template = "clang-doc/config.h.cmake",
 )
 
+cc_library(
+    name = "clang_doc_config",
+    hdrs = ["clang-doc/config.h"],
+)
+
 cc_test(
     name = "clang_doc_test",
     size = "small",
@@ -73,9 +78,12 @@ cc_test(
             "clang-doc/*.h",
         ],
         allow_empty = False,
+        exclude = ["clang-doc/config.h"],
     ),
     data = ["//clang-tools-extra/clang-doc:assets"],
+    includes = ["clang-doc"],
     deps = [
+        ":clang_doc_config",
         "//clang:ast",
         "//clang:basic",
         "//clang-tools-extra/clang-doc:generators",



More information about the llvm-commits mailing list