Skip to content

Commit cde798c

Browse files
committed
[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.
1 parent 7b1becd commit cde798c

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

llvm/utils/merge-json.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,13 @@ def main():
3535
except (IOError, json.JSONDecodeError) as e:
3636
continue
3737

38+
# LLVM passes this argument by default but it is not supported by clang,
39+
# causing annoying errors in the generated compile_commands.json file.
40+
# Remove it here before we deduplicate the entries.
41+
for entry in merged_data:
42+
if isinstance(entry, dict) and "command" in entry:
43+
entry["command"] = entry["command"].replace("-fno-lifetime-dse ", "")
44+
3845
# Deduplicate by converting each entry to a tuple of sorted key-value pairs
3946
unique_data = list({json.dumps(entry, sort_keys=True) for entry in merged_data})
4047
unique_data = [json.loads(entry) for entry in unique_data]

0 commit comments

Comments
 (0)