From 892260d7f3526c429047b645f22401635a7df368 Mon Sep 17 00:00:00 2001 From: Jordan Rupprecht Date: Thu, 22 Sep 2022 19:20:04 -0700 Subject: [PATCH] [bazel] Respect llvm_target_list in llvm-exegesis - 47afaf2eb02b1424a9aba241ccd02393a0cbc648 changed llvm-exegesis cmake rules - 5b2f838db42ea190fdda147a33b5f0fcc8145689 ported them to bazel, but did so by adding all the `lib/{target}/*.cpp` sources in exegesis to the build rule - c7bf9d084d037aa6c8fd479be9ccdf963dc59e10 removed it, because it breaks users who don't build Mips and fail when building `lib/Mips/*.cpp`. But that in turn breaks those who *do* build the Mips target. This should hopefully fix it for the final time by using selectively build subdirectories of exegesis target libs using llvm_target_exegesis, which is derived from llvm_targets, and is the list that can vary based on the downstream user. I verified this builds with and without `Mips` in the `DEFAULT_TARGETS` configure list, and also double checked with `bazel query --output=build @llvm-project//llvm:Exegesis` that `lib/Mips/Target.cpp` is being included if and only if `Mips` is in the target list. Reviewed By: aeubanks Differential Revision: https://reviews.llvm.org/D134512 --- utils/bazel/llvm-project-overlay/llvm/BUILD.bazel | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/utils/bazel/llvm-project-overlay/llvm/BUILD.bazel b/utils/bazel/llvm-project-overlay/llvm/BUILD.bazel index c6b7bf6..8994034 100644 --- a/utils/bazel/llvm-project-overlay/llvm/BUILD.bazel +++ b/utils/bazel/llvm-project-overlay/llvm/BUILD.bazel @@ -2591,16 +2591,18 @@ cc_library( name = "Exegesis", srcs = glob([ "tools/llvm-exegesis/lib/*.cpp", - "tools/llvm-exegesis/lib/AArch64/*.cpp", - "tools/llvm-exegesis/lib/PowerPC/*.cpp", - "tools/llvm-exegesis/lib/X86/*.cpp", - "tools/llvm-exegesis/lib/X86/*.h", # We have to include these headers here as well as in the `hdrs` below # to allow the `.cpp` files to use file-relative-inclusion to find # them, even though consumers of this library use inclusion relative to # `tools/llvm-exegesis/lib` with the `strip_includes_prefix` of this # library. This mixture appears to be incompatible with header modules. "tools/llvm-exegesis/lib/*.h", + ] + [ + "tools/llvm-exegesis/lib/{}/*.cpp".format(t) + for t in llvm_target_exegesis + ] + [ + "tools/llvm-exegesis/lib/{}/*.h".format(t) + for t in llvm_target_exegesis ]), hdrs = glob(["tools/llvm-exegesis/lib/*.h"]), copts = llvm_copts + ["-DHAVE_LIBPFM=1"], -- 2.7.4