f09cf34d00
This is a fairly large changeset, but it can be broken into a few pieces: - `llvm/Support/*TargetParser*` are all moved from the LLVM Support component into a new LLVM Component called "TargetParser". This potentially enables using tablegen to maintain this information, as is shown in https://reviews.llvm.org/D137517. This cannot currently be done, as llvm-tblgen relies on LLVM's Support component. - This also moves two files from Support which use and depend on information in the TargetParser: - `llvm/Support/Host.{h,cpp}` which contains functions for inspecting the current Host machine for info about it, primarily to support getting the host triple, but also for `-mcpu=native` support in e.g. Clang. This is fairly tightly intertwined with the information in `X86TargetParser.h`, so keeping them in the same component makes sense. - `llvm/ADT/Triple.h` and `llvm/Support/Triple.cpp`, which contains the target triple parser and representation. This is very intertwined with the Arm target parser, because the arm architecture version appears in canonical triples on arm platforms. - I moved the relevant unittests to their own directory. And so, we end up with a single component that has all the information about the following, which to me seems like a unified component: - Triples that LLVM Knows about - Architecture names and CPUs that LLVM knows about - CPU detection logic for LLVM Given this, I have also moved `RISCVISAInfo.h` into this component, as it seems to me to be part of that same set of functionality. If you get link errors in your components after this patch, you likely need to add TargetParser into LLVM_LINK_COMPONENTS in CMake. Differential Revision: https://reviews.llvm.org/D137838
137 lines
4.3 KiB
CMake
137 lines
4.3 KiB
CMake
set(LLVM_LINK_COMPONENTS
|
|
Option
|
|
FrontendOpenMP
|
|
Support
|
|
TargetParser
|
|
)
|
|
|
|
add_subdirectory(Core)
|
|
add_subdirectory(Inclusions)
|
|
add_subdirectory(Refactoring)
|
|
add_subdirectory(ASTDiff)
|
|
add_subdirectory(DumpTool)
|
|
add_subdirectory(Syntax)
|
|
add_subdirectory(DependencyScanning)
|
|
add_subdirectory(Transformer)
|
|
|
|
# Replace the last lib component of the current binary directory with include
|
|
string(FIND ${CMAKE_CURRENT_BINARY_DIR} "/lib/" PATH_LIB_START REVERSE)
|
|
if(PATH_LIB_START EQUAL -1)
|
|
message(FATAL_ERROR "Couldn't find lib component in binary directory")
|
|
endif()
|
|
math(EXPR PATH_LIB_END "${PATH_LIB_START}+5")
|
|
string(SUBSTRING ${CMAKE_CURRENT_BINARY_DIR} 0 ${PATH_LIB_START} PATH_HEAD)
|
|
string(SUBSTRING ${CMAKE_CURRENT_BINARY_DIR} ${PATH_LIB_END} -1 PATH_TAIL)
|
|
string(CONCAT BINARY_INCLUDE_DIR ${PATH_HEAD} "/include/clang/" ${PATH_TAIL})
|
|
|
|
if (NOT Python3_EXECUTABLE
|
|
OR APPLE
|
|
OR CMAKE_CROSSCOMPILING
|
|
OR GENERATOR_IS_MULTI_CONFIG
|
|
OR NOT LLVM_NATIVE_ARCH IN_LIST LLVM_TARGETS_TO_BUILD
|
|
)
|
|
configure_file(
|
|
EmptyNodeIntrospection.inc.in
|
|
${BINARY_INCLUDE_DIR}/NodeIntrospection.inc
|
|
COPYONLY
|
|
)
|
|
set(CLANG_TOOLING_BUILD_AST_INTROSPECTION "OFF" CACHE BOOL "")
|
|
else()
|
|
# The generation of ASTNodeAPI.json takes a long time in a
|
|
# Debug build due to parsing AST.h. Disable the processing
|
|
# but setting CLANG_TOOLING_BUILD_AST_INTROSPECTION as an
|
|
# internal hidden setting to override.
|
|
# When the processing is disabled, a trivial/empty JSON
|
|
# file is generated by clang-ast-dump and generate_cxx_src_locs.py
|
|
# generates the same API, but with a trivial implementation.
|
|
option(CLANG_TOOLING_BUILD_AST_INTROSPECTION "Enable AST introspection" TRUE)
|
|
|
|
set(skip_expensive_processing $<OR:$<CONFIG:Debug>,$<NOT:$<BOOL:${CLANG_TOOLING_BUILD_AST_INTROSPECTION}>>>)
|
|
|
|
set(implicitDirs)
|
|
foreach(implicitDir ${CMAKE_CXX_IMPLICIT_INCLUDE_DIRECTORIES})
|
|
list(APPEND implicitDirs -I ${implicitDir})
|
|
endforeach()
|
|
|
|
add_custom_command(
|
|
COMMENT Generate ASTNodeAPI.json
|
|
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/ASTNodeAPI.json
|
|
DEPENDS clang-ast-dump clang-resource-headers
|
|
COMMAND
|
|
$<TARGET_FILE:clang-ast-dump>
|
|
# Skip this in debug mode because parsing AST.h is too slow
|
|
--skip-processing=${skip_expensive_processing}
|
|
-I ${LLVM_BINARY_DIR}/lib/clang/${CLANG_VERSION_MAJOR}/include
|
|
-I ${CLANG_SOURCE_DIR}/include
|
|
-I ${LLVM_BINARY_DIR}/tools/clang/include
|
|
-I ${LLVM_BINARY_DIR}/include
|
|
-I ${LLVM_SOURCE_DIR}/include
|
|
${implicitDirs}
|
|
--json-output-path ${CMAKE_CURRENT_BINARY_DIR}/ASTNodeAPI.json
|
|
)
|
|
|
|
add_custom_target(run-ast-api-dump-tool
|
|
DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/ASTNodeAPI.json
|
|
)
|
|
|
|
add_custom_command(
|
|
COMMENT Generate NodeIntrospection.inc
|
|
OUTPUT ${BINARY_INCLUDE_DIR}/NodeIntrospection.inc
|
|
DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/ASTNodeAPI.json
|
|
${CMAKE_CURRENT_SOURCE_DIR}/DumpTool/generate_cxx_src_locs.py
|
|
${CMAKE_CURRENT_SOURCE_DIR}/EmptyNodeIntrospection.inc.in
|
|
COMMAND
|
|
${Python3_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/DumpTool/generate_cxx_src_locs.py
|
|
--json-input-path ${CMAKE_CURRENT_BINARY_DIR}/ASTNodeAPI.json
|
|
--output-file NodeIntrospection.inc
|
|
--use-empty-implementation ${skip_expensive_processing}
|
|
--empty-implementation
|
|
"${CMAKE_CURRENT_SOURCE_DIR}/EmptyNodeIntrospection.inc.in"
|
|
COMMAND
|
|
${CMAKE_COMMAND} -E copy_if_different
|
|
${CMAKE_CURRENT_BINARY_DIR}/NodeIntrospection.inc
|
|
${BINARY_INCLUDE_DIR}/NodeIntrospection.inc
|
|
)
|
|
|
|
add_custom_target(run-ast-api-generate-tool
|
|
DEPENDS
|
|
${BINARY_INCLUDE_DIR}/NodeIntrospection.inc
|
|
)
|
|
endif()
|
|
|
|
add_clang_library(clangTooling
|
|
AllTUsExecution.cpp
|
|
ArgumentsAdjusters.cpp
|
|
CommonOptionsParser.cpp
|
|
CompilationDatabase.cpp
|
|
Execution.cpp
|
|
ExpandResponseFilesCompilationDatabase.cpp
|
|
FileMatchTrie.cpp
|
|
FixIt.cpp
|
|
GuessTargetAndModeCompilationDatabase.cpp
|
|
InterpolatingCompilationDatabase.cpp
|
|
JSONCompilationDatabase.cpp
|
|
Refactoring.cpp
|
|
RefactoringCallbacks.cpp
|
|
StandaloneExecution.cpp
|
|
NodeIntrospection.cpp
|
|
${BINARY_INCLUDE_DIR}/NodeIntrospection.inc
|
|
Tooling.cpp
|
|
|
|
DEPENDS
|
|
ClangDriverOptions
|
|
omp_gen
|
|
|
|
LINK_LIBS
|
|
clangAST
|
|
clangASTMatchers
|
|
clangBasic
|
|
clangDriver
|
|
clangFormat
|
|
clangFrontend
|
|
clangLex
|
|
clangRewrite
|
|
clangSerialization
|
|
clangToolingCore
|
|
)
|