[llvm] [Bazel] Fix `--warn-backrefs` errors in `Analysis` target (PR #170357)

Jason Macnak via llvm-commits llvm-commits at lists.llvm.org
Tue Dec 2 11:44:44 PST 2025


https://github.com/jmacnak created https://github.com/llvm/llvm-project/pull/170357

Commit b262785 introduced a separate `AnalysisFpExc` target to try to workaround the lack of a bazel equivalent of single source file properties. However, this introduces backref errors when `--warn-backrefs` is enabled.

This change alternatively just adds the `-ftrapping-math` copt to the entire `Analysis` target.

Fix suggested by @rocallahan. 

>From 78c6fdcb94e0b5d946d64b35cd70e2cc5db05cd9 Mon Sep 17 00:00:00 2001
From: Jason Macnak <natsu at google.com>
Date: Tue, 2 Dec 2025 11:33:02 -0800
Subject: [PATCH] [Bazel] Fix `--warn-backrefs` errors in `Analysis` target

Commit b262785 introduced a separate `AnalysisFpExc` target to
try to workaround the lack of a bazel equivalent of single source
file properties. However, this introduces backref errors when
`--warn-backrefs` is enabled.

This change alternatively just adds the `-ftrapping-math` copt
to the entire `Analysis` target.
---
 .../llvm-project-overlay/llvm/BUILD.bazel     | 33 +------------------
 1 file changed, 1 insertion(+), 32 deletions(-)

diff --git a/utils/bazel/llvm-project-overlay/llvm/BUILD.bazel b/utils/bazel/llvm-project-overlay/llvm/BUILD.bazel
index 1428299076fb3..8e9b51b58f4f5 100644
--- a/utils/bazel/llvm-project-overlay/llvm/BUILD.bazel
+++ b/utils/bazel/llvm-project-overlay/llvm/BUILD.bazel
@@ -1243,42 +1243,12 @@ cc_library(
     ],
 )
 
-AnalysisFpExcSrcs = [
-    "lib/Analysis/ConstantFolding.cpp",
-]
-
-cc_library(
-    name = "AnalysisFpExc",
-    srcs = AnalysisFpExcSrcs,
-    hdrs = glob(
-        [
-            "include/llvm/Analysis/*.h",
-            "include/llvm/Analysis/Utils/*.h",
-        ],
-    ),
-    copts = llvm_copts + ["-ftrapping-math"],
-    textual_hdrs = glob([
-        "include/llvm/Analysis/*.def",
-    ]),
-    deps = [
-        ":BinaryFormat",
-        ":Core",
-        ":Object",
-        ":ProfileData",
-        ":Support",
-        ":TargetParser",
-        ":config",
-        ":target_library_info_gen",
-    ],
-)
-
 cc_library(
     name = "Analysis",
     srcs = glob(
         [
             "lib/Analysis/*.cpp",
         ],
-        exclude = AnalysisFpExcSrcs,
     ),
     hdrs = glob(
         [
@@ -1288,12 +1258,11 @@ cc_library(
     ) + [
         "include/llvm-c/Analysis.h",
     ],
-    copts = llvm_copts,
+    copts = llvm_copts + ["-ftrapping-math"],
     textual_hdrs = glob([
         "include/llvm/Analysis/*.def",
     ]),
     deps = [
-        ":AnalysisFpExc",
         ":BinaryFormat",
         ":Core",
         ":FrontendHLSL",



More information about the llvm-commits mailing list