Skip to content

Commit 52bcdac

Browse files
committed
[build] Fix stand-alone builds of clang.
The header file `llvm/include/llvm/Targetparser/RISCVTargetParser.h` relies on the auto-generated *.inc file associated to the tablegen target `RISCVTargetParserTableGen`. Both clangBasic and clangDriver include `RISCVTargetParser.h`, therefore we need to make sure that the *.inc file is avaiable to avoid compilation errors like the following: FAILED: tools/clang/lib/Basic/CMakeFiles/obj.clangBasic.dir/Targets/RISCV.cpp.o /usr/bin/c++ [bunch of non interesting stuff] -c <path-to>/llvm-project/clang/lib/Basic/Targets/RISCV.cpp In file included from <path-to>/llvm-project/clang/lib/Basic/Targets/RISCV.cpp:19: <path-to>/llvm-project/llvm/include/llvm/TargetParser/RISCVTargetParser.h:29:10: fatal error: llvm/TargetParser/RISCVTargetParserDef.inc: No such file or directory 29 | #include "llvm/TargetParser/RISCVTargetParserDef.inc" | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ The stand-alone build of `clang` has been tested with the following script (see [*] for further information): ``` build_llvm=`pwd`/build-llvm build_clang=`pwd`/build-clang installprefix=`pwd`/install llvm=`pwd`/llvm-project mkdir -p $build_llvm mkdir -p $installprefix cmake -G Ninja -S $llvm/llvm -B $build_llvm \ -DLLVM_INSTALL_UTILS=ON \ -DCMAKE_INSTALL_PREFIX=$installprefix \ -DCMAKE_BUILD_TYPE=Release ninja -C $build_llvm install cmake -G Ninja -S $llvm/clang -B $build_clang \ -DLLVM_EXTERNAL_LIT=$build_llvm/utils/lit \ -DLLVM_ROOT=$installprefix ``` [*] https://llvm.org/docs/GettingStarted.html#stand-alone-builds Differential Revision: https://reviews.llvm.org/D141581
1 parent 9af9d39 commit 52bcdac

File tree

3 files changed

+6
-5
lines changed

3 files changed

+6
-5
lines changed

clang/lib/Basic/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,6 @@ add_clang_library(clangBasic
110110

111111
DEPENDS
112112
omp_gen
113-
RISCVTargetParserTableGen
114113
)
115114

116115
target_link_libraries(clangBasic

clang/lib/Driver/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,6 @@ add_clang_library(clangDriver
9393

9494
DEPENDS
9595
ClangDriverOptions
96-
RISCVTargetParserTableGen
9796

9897
LINK_LIBS
9998
clangBasic

llvm/cmake/modules/LLVMConfig.cmake.in

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -140,9 +140,9 @@ if(NOT TARGET LLVMSupport)
140140
@llvm_config_include_buildtree_only_exports@
141141
endif()
142142

143-
# By creating intrinsics_gen, omp_gen and acc_gen here, subprojects that depend
144-
# on LLVM's tablegen-generated headers can always depend on this target whether
145-
# building in-tree with LLVM or not.
143+
# By creating the following targets here, subprojects that depend on
144+
# LLVM's tablegen-generated headers can always depend on this target
145+
# whether building in-tree with LLVM or not.
146146
if(NOT TARGET intrinsics_gen)
147147
add_custom_target(intrinsics_gen)
148148
endif()
@@ -152,6 +152,9 @@ endif()
152152
if(NOT TARGET acc_gen)
153153
add_custom_target(acc_gen)
154154
endif()
155+
if(NOT TARGET RISCVTargetParserTableGen)
156+
add_custom_target(RISCVTargetParserTableGen)
157+
endif()
155158

156159
set_property(GLOBAL PROPERTY LLVM_TARGETS_CONFIGURED On)
157160
include(${LLVM_CMAKE_DIR}/LLVM-Config.cmake)

0 commit comments

Comments
 (0)