Skip to content

Commit 136558b

Browse files
authored
[mlir][cmake] Fix missing entries in tablegen_compile_commands.yml (#147516)
Depending on the order of CMake includes the `tablegen_compile_commands.yml` was previously missing entries due to being deleted after a `tablegen` commands. This PR fixes this by 1) making sure `AddMLIR` includes `TableGen` such that new compile commands are added to a fresh YML file and 2) using an include guard to ensure the file is cleared exactly once
1 parent 1d33bba commit 136558b

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

llvm/cmake/modules/TableGen.cmake

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,6 @@
44
# Adds the name of the generated file to TABLEGEN_OUTPUT.
55
include(LLVMDistributionSupport)
66

7-
# Clear out any pre-existing compile_commands file before processing. This
8-
# allows for generating a clean compile_commands on each configure.
9-
file(REMOVE ${CMAKE_BINARY_DIR}/tablegen_compile_commands.yml)
10-
117
function(tablegen project ofn)
128
cmake_parse_arguments(ARG "" "" "DEPENDS;EXTRA_INCLUDES" ${ARGN})
139

@@ -250,3 +246,11 @@ macro(add_tablegen target project)
250246
set_property(GLOBAL APPEND PROPERTY ${export_upper}_EXPORTS ${target})
251247
endif()
252248
endmacro()
249+
250+
# Make sure 'tablegen_compile_commands.yml' is only deleted once the very
251+
# first time this file is included.
252+
include_guard(GLOBAL)
253+
254+
# Clear out any pre-existing compile_commands file before processing. This
255+
# allows for generating a clean compile_commands on each configure.
256+
file(REMOVE ${CMAKE_BINARY_DIR}/tablegen_compile_commands.yml)

mlir/cmake/modules/AddMLIR.cmake

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
include(TableGen)
12
include(GNUInstallDirs)
23
include(LLVMDistributionSupport)
34

0 commit comments

Comments
 (0)