Skip to content

Commit da3d772

Browse files
vargazJo Shields
authored andcommitted
Add LLVM_BUILD_EXECUTION_ENGINE and LLVM_TOOLS_TO_BUILD cmake options, they can be used to disable the building of lib/ExecutionEngine and only build a subset of tools.
1 parent 277fc81 commit da3d772

File tree

4 files changed

+27
-5
lines changed

4 files changed

+27
-5
lines changed

llvm/CMakeLists.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -501,6 +501,11 @@ option(LLVM_BUILD_EXAMPLES
501501
"Build the LLVM example programs. If OFF, just generate build targets." OFF)
502502
option(LLVM_INCLUDE_EXAMPLES "Generate build targets for the LLVM examples" ON)
503503

504+
option(LLVM_BUILD_EXECUTION_ENGINE
505+
"Build lib/ExecutionEngine." ON)
506+
507+
option(LLVM_TOOLS_TO_BUILD "List of tools to build" "")
508+
504509
option(LLVM_BUILD_TESTS
505510
"Build LLVM unit tests. If OFF, just generate build targets." OFF)
506511
option(LLVM_INCLUDE_TESTS "Generate build targets for the LLVM unit tests." ON)

llvm/cmake/modules/AddLLVM.cmake

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -965,10 +965,19 @@ macro(add_llvm_subdirectory project type name)
965965
option(${project}_${type}_${nameUPPER}_BUILD
966966
"Whether to build ${name} as part of ${project}" On)
967967
mark_as_advanced(${project}_${type}_${name}_BUILD)
968-
if(${project}_${type}_${nameUPPER}_BUILD)
969-
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/${add_llvm_external_dir} ${add_llvm_external_dir})
970-
# Don't process it in add_llvm_implicit_projects().
971-
set(${project}_${type}_${nameUPPER}_BUILD OFF)
968+
if("${project}${type}" STREQUAL "LLVMTOOL" AND (NOT "${LLVM_TOOLS_TO_BUILD}" STREQUAL ""))
969+
if("${name}" IN_LIST LLVM_TOOLS_TO_BUILD)
970+
message("Building tool ${name}.")
971+
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/${add_llvm_external_dir} ${add_llvm_external_dir})
972+
# Don't process it in add_llvm_implicit_projects().
973+
set(${project}_${type}_${nameUPPER}_BUILD OFF)
974+
endif()
975+
else()
976+
if(${${project}_${type}_${nameUPPER}_BUILD})
977+
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/${add_llvm_external_dir} ${add_llvm_external_dir})
978+
# Don't process it in add_llvm_implicit_projects().
979+
set(${project}_${type}_${nameUPPER}_BUILD OFF)
980+
endif()
972981
endif()
973982
else()
974983
set(LLVM_EXTERNAL_${nameUPPER}_SOURCE_DIR
@@ -1329,6 +1338,9 @@ function(add_lit_target target comment)
13291338
COMMAND ${CMAKE_COMMAND} -E echo "${target} does nothing, no tools built.")
13301339
message(STATUS "${target} does nothing.")
13311340
endif()
1341+
if( NOT LLVM_BUILD_TESTS )
1342+
return()
1343+
endif()
13321344
if (ARG_DEPENDS)
13331345
add_dependencies(${target} ${ARG_DEPENDS})
13341346
endif()

llvm/cmake/modules/CrossCompile.cmake

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ function(llvm_create_cross_target_internal target_name toolchain buildtype)
4949
-DLLVM_TARGET_IS_CROSSCOMPILE_HOST=TRUE
5050
-DLLVM_TARGETS_TO_BUILD="${targets_to_build_arg}"
5151
-DLLVM_EXPERIMENTAL_TARGETS_TO_BUILD="${experimental_targets_to_build_arg}"
52+
-DLLVM_TOOLS_TO_BUILD=""
5253
${build_type_flags} ${linker_flag} ${external_clang_dir}
5354
WORKING_DIRECTORY ${LLVM_${target_name}_BUILD}
5455
DEPENDS CREATE_LLVM_${target_name}

llvm/lib/ExecutionEngine/CMakeLists.txt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
1+
if(NOT LLVM_BUILD_EXECUTION_ENGINE)
2+
set(EXCLUDE_FROM_ALL ON)
3+
endif()
24

35
add_llvm_library(LLVMExecutionEngine
46
ExecutionEngine.cpp
@@ -18,10 +20,12 @@ if(BUILD_SHARED_LIBS)
1820
target_link_libraries(LLVMExecutionEngine PUBLIC LLVMRuntimeDyld)
1921
endif()
2022

23+
if(LLVM_BUILD_EXECUTION_ENGINE)
2124
add_subdirectory(Interpreter)
2225
add_subdirectory(MCJIT)
2326
add_subdirectory(Orc)
2427
add_subdirectory(RuntimeDyld)
28+
endif()
2529

2630
if( LLVM_USE_OPROFILE )
2731
add_subdirectory(OProfileJIT)

0 commit comments

Comments
 (0)