Skip to content

Commit d8127eb

Browse files
authored
[CMake] In LLVM unified builds, depend on the generation of Clang headers (#70144)
If one is building a LLVM unified build, with Swift as an external project, SwiftCompilerSources can compile before the `.td` files that generate Clang headers are finished, which will make the compilation fail to find some files (the `.inc` files derived from those `.td`). Make the library that uses the header depend on `clang-tablegen-targets` to ensure those are done before the library is tried to be used. This is not a problem in the normal `build-script` builds because in those cases, the LLVM/Clang headers are build way before Swift is started to be build.
1 parent 65aaa49 commit d8127eb

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

SwiftCompilerSources/CMakeLists.txt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,15 @@ else()
263263
add_library(importedHeaderDependencies "${CMAKE_CURRENT_BINARY_DIR}/HeaderDependencies.cpp")
264264
target_include_directories(importedHeaderDependencies PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/../include/swift")
265265

266+
# When building unified, we need to make sure all the Clang headers are
267+
# generated before we try to use them.
268+
# When building Swift against an already compiled LLVM/Clang, like
269+
# build-script does, this target does not exist, but the headers
270+
# are already completely generated at that point.
271+
if(TARGET clang-tablegen-targets)
272+
add_dependencies(importedHeaderDependencies clang-tablegen-targets)
273+
endif()
274+
266275
if(BOOTSTRAPPING_MODE MATCHES "HOSTTOOLS|CROSSCOMPILE")
267276

268277
if (NOT SWIFT_EXEC_FOR_SWIFT_MODULES)

0 commit comments

Comments
 (0)