[llvm] [LLVM] Automatically strip `-fno-lifetime-dse` from compile_commands.json (PR #124623)
Joseph Huber via llvm-commits
llvm-commits at lists.llvm.org
Mon Jan 27 12:53:35 PST 2025
https://github.com/jhuber6 created https://github.com/llvm/llvm-project/pull/124623
Summary:
This flag is always passed by LLVM to bypass some LTO related bug with
GCC. The problem is that this is not supported by clang and shows up in
the compile_commands.json file. That means it will always show at least
one error complaining about this file. Since I already have a script to
merge the runtimes stuff, just strip this out there for convenience.
There was a discussion a long time ago about not adding this as a no-op
flag to clang, so this is the next best thing.
>From 06c18fcc960329d79038a555dbb039c3141cc29d Mon Sep 17 00:00:00 2001
From: Joseph Huber <huberjn at outlook.com>
Date: Mon, 27 Jan 2025 14:48:00 -0600
Subject: [PATCH] [LLVM] Automatically strip `-fno-lifetime-dse` from
compile_commands.json
Summary:
This flag is always passed by LLVM to bypass some LTO related bug with
GCC. The problem is that this is not supported by clang and shows up in
the compile_commands.json file. That means it will always show at least
one error complaining about this file. Since I already have a script to
merge the runtimes stuff, just strip this out there for convenience.
There was a discussion a long time ago about not adding this as a no-op
flag to clang, so this is the next best thing.
---
llvm/utils/merge-json.py | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/llvm/utils/merge-json.py b/llvm/utils/merge-json.py
index f5b9dcf11c4cdc..5b557b8e3da635 100644
--- a/llvm/utils/merge-json.py
+++ b/llvm/utils/merge-json.py
@@ -35,6 +35,13 @@ def main():
except (IOError, json.JSONDecodeError) as e:
continue
+ # LLVM passes this argument by default but it is not supported by clang,
+ # causing annoying errors in the generated compile_commands.json file.
+ # Remove it here before we deduplicate the entries.
+ for entry in merged_data:
+ if isinstance(entry, dict) and "command" in entry:
+ entry["command"] = entry["command"].replace("-fno-lifetime-dse ", "");
+
# Deduplicate by converting each entry to a tuple of sorted key-value pairs
unique_data = list({json.dumps(entry, sort_keys=True) for entry in merged_data})
unique_data = [json.loads(entry) for entry in unique_data]
More information about the llvm-commits
mailing list