[llvm] 52bcdac - [build] Fix stand-alone builds of clang.
Francesco Petrogalli via llvm-commits
llvm-commits at lists.llvm.org
Mon Jan 23 13:12:38 PST 2023
Author: Francesco Petrogalli
Date: 2023-01-23T22:11:47+01:00
New Revision: 52bcdac3b8425e20023151bb726b56fd6f62ec17
URL: https://github.com/llvm/llvm-project/commit/52bcdac3b8425e20023151bb726b56fd6f62ec17
DIFF: https://github.com/llvm/llvm-project/commit/52bcdac3b8425e20023151bb726b56fd6f62ec17.diff
LOG: [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
Added:
Modified:
clang/lib/Basic/CMakeLists.txt
clang/lib/Driver/CMakeLists.txt
llvm/cmake/modules/LLVMConfig.cmake.in
Removed:
################################################################################
diff --git a/clang/lib/Basic/CMakeLists.txt b/clang/lib/Basic/CMakeLists.txt
index 32af83ee23f31..936709da9716a 100644
--- a/clang/lib/Basic/CMakeLists.txt
+++ b/clang/lib/Basic/CMakeLists.txt
@@ -110,7 +110,6 @@ add_clang_library(clangBasic
DEPENDS
omp_gen
- RISCVTargetParserTableGen
)
target_link_libraries(clangBasic
diff --git a/clang/lib/Driver/CMakeLists.txt b/clang/lib/Driver/CMakeLists.txt
index ba56a9323400c..0b6ce9145c651 100644
--- a/clang/lib/Driver/CMakeLists.txt
+++ b/clang/lib/Driver/CMakeLists.txt
@@ -93,7 +93,6 @@ add_clang_library(clangDriver
DEPENDS
ClangDriverOptions
- RISCVTargetParserTableGen
LINK_LIBS
clangBasic
diff --git a/llvm/cmake/modules/LLVMConfig.cmake.in b/llvm/cmake/modules/LLVMConfig.cmake.in
index f1362fa032c2b..bae2a07c0fb16 100644
--- a/llvm/cmake/modules/LLVMConfig.cmake.in
+++ b/llvm/cmake/modules/LLVMConfig.cmake.in
@@ -140,9 +140,9 @@ if(NOT TARGET LLVMSupport)
@llvm_config_include_buildtree_only_exports@
endif()
-# By creating intrinsics_gen, omp_gen and acc_gen here, subprojects that depend
-# on LLVM's tablegen-generated headers can always depend on this target whether
-# building in-tree with LLVM or not.
+# By creating the following targets here, subprojects that depend on
+# LLVM's tablegen-generated headers can always depend on this target
+# whether building in-tree with LLVM or not.
if(NOT TARGET intrinsics_gen)
add_custom_target(intrinsics_gen)
endif()
@@ -152,6 +152,9 @@ endif()
if(NOT TARGET acc_gen)
add_custom_target(acc_gen)
endif()
+if(NOT TARGET RISCVTargetParserTableGen)
+ add_custom_target(RISCVTargetParserTableGen)
+endif()
set_property(GLOBAL PROPERTY LLVM_TARGETS_CONFIGURED On)
include(${LLVM_CMAKE_DIR}/LLVM-Config.cmake)
More information about the llvm-commits
mailing list