Author: Shoaib Meenai
Date: 2025-04-29T12:13:38-07:00
New Revision: 705ceff7c1fc328151a6506a91773aac429ccee3

URL: 
https://github.com/llvm/llvm-project/commit/705ceff7c1fc328151a6506a91773aac429ccee3
DIFF: 
https://github.com/llvm/llvm-project/commit/705ceff7c1fc328151a6506a91773aac429ccee3.diff

LOG: [TargetParser] Fix flaky installs of generated headers (#137853)

The `llvm-headers` target wasn't depending on the generated TargetParser
headers, so they'd be flakily installed or not installed depending on
which order the build steps ran in. Add an explicit dependency to fix
this, and switch to a single `target_parser_gen` target to mirror the
pattern used by `intrinsics_gen` (which also fixes a few other missing
dependencies). Switch `llvm-headers` to use `add_dependencies` instead
of `DEPENDS` for the tablegen dependencies as well, since `DEPENDS` is
only intended for creating a file-level dependency on the output of an
`add_custom_command` in the same CMakeLists.txt (see `DEPENDS` under
https://cmake.org/cmake/help/latest/command/add_custom_target.html).

Added: 
    

Modified: 
    clang/lib/AST/CMakeLists.txt
    clang/lib/Basic/CMakeLists.txt
    clang/lib/CodeGen/CMakeLists.txt
    clang/lib/Driver/CMakeLists.txt
    clang/tools/driver/CMakeLists.txt
    llvm/CMakeLists.txt
    llvm/cmake/modules/LLVMConfig.cmake.in
    llvm/include/llvm/TargetParser/CMakeLists.txt
    llvm/lib/TargetParser/CMakeLists.txt

Removed: 
    


################################################################################
diff  --git a/clang/lib/AST/CMakeLists.txt b/clang/lib/AST/CMakeLists.txt
index f6056e3935a63..26d4d04d46e95 100644
--- a/clang/lib/AST/CMakeLists.txt
+++ b/clang/lib/AST/CMakeLists.txt
@@ -145,5 +145,5 @@ add_clang_library(clangAST
   ClangDriverOptions
   intrinsics_gen
   # These generated headers are included transitively.
-  AArch64TargetParserTableGen
+  target_parser_gen
   )

diff  --git a/clang/lib/Basic/CMakeLists.txt b/clang/lib/Basic/CMakeLists.txt
index 419fd9bc136cf..0eacf79f5d478 100644
--- a/clang/lib/Basic/CMakeLists.txt
+++ b/clang/lib/Basic/CMakeLists.txt
@@ -134,8 +134,7 @@ add_clang_library(clangBasic
   omp_gen
   ClangDriverOptions
   # These generated headers are included transitively.
-  ARMTargetParserTableGen
-  AArch64TargetParserTableGen
+  target_parser_gen
   )
 
 target_link_libraries(clangBasic

diff  --git a/clang/lib/CodeGen/CMakeLists.txt 
b/clang/lib/CodeGen/CMakeLists.txt
index c377ac0786747..a05b31f971e18 100644
--- a/clang/lib/CodeGen/CMakeLists.txt
+++ b/clang/lib/CodeGen/CMakeLists.txt
@@ -162,8 +162,7 @@ add_clang_library(clangCodeGen
   intrinsics_gen
   ClangDriverOptions
   # These generated headers are included transitively.
-  ARMTargetParserTableGen
-  AArch64TargetParserTableGen
+  target_parser_gen
 
   LINK_LIBS
   clangAST

diff  --git a/clang/lib/Driver/CMakeLists.txt b/clang/lib/Driver/CMakeLists.txt
index 5bdb6614389cf..9dbededf1ade9 100644
--- a/clang/lib/Driver/CMakeLists.txt
+++ b/clang/lib/Driver/CMakeLists.txt
@@ -94,8 +94,7 @@ add_clang_library(clangDriver
   DEPENDS
   ClangDriverOptions
   # These generated headers are included transitively.
-  ARMTargetParserTableGen
-  AArch64TargetParserTableGen
+  target_parser_gen
 
   LINK_LIBS
   clangBasic

diff  --git a/clang/tools/driver/CMakeLists.txt 
b/clang/tools/driver/CMakeLists.txt
index 10ea5de387220..d9d36f7a41359 100644
--- a/clang/tools/driver/CMakeLists.txt
+++ b/clang/tools/driver/CMakeLists.txt
@@ -48,8 +48,7 @@ add_clang_tool(clang
   DEPENDS
   intrinsics_gen
   # These generated headers are included transitively.
-  ARMTargetParserTableGen
-  AArch64TargetParserTableGen
+  target_parser_gen
   ${support_plugins}
   ${CLANG_BOLT_DEPS}
   GENERATE_DRIVER

diff  --git a/llvm/CMakeLists.txt b/llvm/CMakeLists.txt
index 73c4fc14f0319..394e1bffa770a 100644
--- a/llvm/CMakeLists.txt
+++ b/llvm/CMakeLists.txt
@@ -1415,7 +1415,8 @@ if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY)
 
   # Installing the headers needs to depend on generating any public
   # tablegen'd headers.
-  add_custom_target(llvm-headers DEPENDS intrinsics_gen omp_gen)
+  add_custom_target(llvm-headers)
+  add_dependencies(llvm-headers intrinsics_gen omp_gen target_parser_gen)
   set_target_properties(llvm-headers PROPERTIES FOLDER "LLVM/Resources")
 
   if (NOT LLVM_ENABLE_IDE)

diff  --git a/llvm/cmake/modules/LLVMConfig.cmake.in 
b/llvm/cmake/modules/LLVMConfig.cmake.in
index 5ccc66b8039bf..c15b9576cd5d5 100644
--- a/llvm/cmake/modules/LLVMConfig.cmake.in
+++ b/llvm/cmake/modules/LLVMConfig.cmake.in
@@ -162,14 +162,8 @@ endif()
 if(NOT TARGET acc_gen)
   add_custom_target(acc_gen)
 endif()
-if(NOT TARGET ARMTargetParserTableGen)
-  add_custom_target(ARMTargetParserTableGen)
-endif()
-if(NOT TARGET AArch64TargetParserTableGen)
-  add_custom_target(AArch64TargetParserTableGen)
-endif()
-if(NOT TARGET RISCVTargetParserTableGen)
-  add_custom_target(RISCVTargetParserTableGen)
+if(NOT TARGET target_parser_gen)
+  add_custom_target(target_parser_gen)
 endif()
 
 set_property(GLOBAL PROPERTY LLVM_TARGETS_CONFIGURED On)

diff  --git a/llvm/include/llvm/TargetParser/CMakeLists.txt 
b/llvm/include/llvm/TargetParser/CMakeLists.txt
index f89d4eb5ea163..b456da66a022f 100644
--- a/llvm/include/llvm/TargetParser/CMakeLists.txt
+++ b/llvm/include/llvm/TargetParser/CMakeLists.txt
@@ -1,12 +1,11 @@
 set(LLVM_TARGET_DEFINITIONS ${PROJECT_SOURCE_DIR}/lib/Target/ARM/ARM.td)
 tablegen(LLVM ARMTargetParserDef.inc -gen-arm-target-def -I 
${PROJECT_SOURCE_DIR}/lib/Target/ARM/)
-add_public_tablegen_target(ARMTargetParserTableGen)
 
 set(LLVM_TARGET_DEFINITIONS 
${PROJECT_SOURCE_DIR}/lib/Target/AArch64/AArch64.td)
 tablegen(LLVM AArch64TargetParserDef.inc -gen-arm-target-def -I 
${PROJECT_SOURCE_DIR}/lib/Target/AArch64/)
-add_public_tablegen_target(AArch64TargetParserTableGen)
 
 set(LLVM_TARGET_DEFINITIONS ${PROJECT_SOURCE_DIR}/lib/Target/RISCV/RISCV.td)
 tablegen(LLVM RISCVTargetParserDef.inc -gen-riscv-target-def -I 
${PROJECT_SOURCE_DIR}/lib/Target/RISCV/)
-add_public_tablegen_target(RISCVTargetParserTableGen)
 
+# This covers all of the tablegen calls above.
+add_public_tablegen_target(target_parser_gen)

diff  --git a/llvm/lib/TargetParser/CMakeLists.txt 
b/llvm/lib/TargetParser/CMakeLists.txt
index 8ec32f7410566..8f8b3a578a1d9 100644
--- a/llvm/lib/TargetParser/CMakeLists.txt
+++ b/llvm/lib/TargetParser/CMakeLists.txt
@@ -39,7 +39,5 @@ add_llvm_component_library(LLVMTargetParser
   Support
 
   DEPENDS
-  ARMTargetParserTableGen
-  AArch64TargetParserTableGen
-  RISCVTargetParserTableGen
+  target_parser_gen
   )


        
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to