2016-03-28 18:19:32 +00:00
# See docs/CMake.html for instructions about how to build LLVM with CMake.
Reland "[CMake] Bumps minimum version to 3.20.0.
This reverts commit d763c6e5e2d0a6b34097aa7dabca31e9aff9b0b6.
Adds the patch by @hans from
https://github.com/llvm/llvm-project/issues/62719
This patch fixes the Windows build.
d763c6e5e2d0a6b34097aa7dabca31e9aff9b0b6 reverted the reviews
D144509 [CMake] Bumps minimum version to 3.20.0.
This partly undoes D137724.
This change has been discussed on discourse
https://discourse.llvm.org/t/rfc-upgrading-llvms-minimum-required-cmake-version/66193
Note this does not remove work-arounds for older CMake versions, that
will be done in followup patches.
D150532 [OpenMP] Compile assembly files as ASM, not C
Since CMake 3.20, CMake explicitly passes "-x c" (or equivalent)
when compiling a file which has been set as having the language
C. This behaviour change only takes place if "cmake_minimum_required"
is set to 3.20 or newer, or if the policy CMP0119 is set to new.
Attempting to compile assembly files with "-x c" fails, however
this is workarounded in many cases, as OpenMP overrides this with
"-x assembler-with-cpp", however this is only added for non-Windows
targets.
Thus, after increasing cmake_minimum_required to 3.20, this breaks
compiling the GNU assembly for Windows targets; the GNU assembly is
used for ARM and AArch64 Windows targets when building with Clang.
This patch unbreaks that.
D150688 [cmake] Set CMP0091 to fix Windows builds after the cmake_minimum_required bump
The build uses other mechanism to select the runtime.
Fixes #62719
Reviewed By: #libc, Mordante
Differential Revision: https://reviews.llvm.org/D151344
2023-05-24 18:12:32 +02:00
cmake_minimum_required ( VERSION 3.20.0 )
2022-10-27 14:30:02 +02:00
2024-09-06 18:51:44 +01:00
include ( CMakeDependentOption )
2022-10-24 06:31:37 +02:00
set ( LLVM_COMMON_CMAKE_UTILS ${ CMAKE_CURRENT_SOURCE_DIR } /../cmake )
include ( ${ LLVM_COMMON_CMAKE_UTILS } /Modules/CMakePolicy.cmake
N O _ P O L I C Y _ S C O P E )
2021-04-22 10:08:53 -07:00
2023-10-01 13:15:15 +00:00
# Builds with custom install names and installation rpath setups may not work
# in the build tree. Allow these cases to use CMake's default build tree
# behavior by setting `LLVM_NO_INSTALL_NAME_DIR_FOR_BUILD_TREE` to do this.
option ( LLVM_NO_INSTALL_NAME_DIR_FOR_BUILD_TREE "If set, use CMake's default build tree install name directory logic (Darwin only)" OFF )
mark_as_advanced ( LLVM_NO_INSTALL_NAME_DIR_FOR_BUILD_TREE )
if ( NOT LLVM_NO_INSTALL_NAME_DIR_FOR_BUILD_TREE )
set ( CMAKE_BUILD_WITH_INSTALL_NAME_DIR ON )
endif ( )
2019-05-21 20:28:32 +00:00
2024-03-11 17:43:14 +01:00
include ( ${ LLVM_COMMON_CMAKE_UTILS } /Modules/LLVMVersion.cmake )
2016-03-28 18:19:32 +00:00
2024-03-05 09:59:28 -05:00
set_directory_properties ( PROPERTIES LLVM_VERSION_MAJOR "${LLVM_VERSION_MAJOR}" )
2016-03-28 18:19:32 +00:00
if ( NOT PACKAGE_VERSION )
set ( PACKAGE_VERSION
" $ { L L V M _ V E R S I O N _ M A J O R } . $ { L L V M _ V E R S I O N _ M I N O R } . $ { L L V M _ V E R S I O N _ P A T C H } $ { L L V M _ V E R S I O N _ S U F F I X } " )
endif ( )
2022-01-31 17:56:42 -08:00
if ( NOT DEFINED LLVM_SHLIB_SYMBOL_VERSION )
2024-11-19 23:58:33 +01:00
# "Symbol version prefix for libLLVM.so and libclang-cpp.so"
2024-02-19 16:46:16 -08:00
set ( LLVM_SHLIB_SYMBOL_VERSION "LLVM_${LLVM_VERSION_MAJOR}.${LLVM_VERSION_MINOR}" )
2022-01-31 17:56:42 -08:00
endif ( )
2022-01-24 20:39:54 +01:00
if ( ( CMAKE_GENERATOR MATCHES "Visual Studio" ) AND ( MSVC_TOOLSET_VERSION LESS 142 ) AND ( CMAKE_GENERATOR_TOOLSET STREQUAL "" ) )
2017-05-25 21:01:30 +00:00
message ( WARNING "Visual Studio generators use the x86 host compiler by "
" d e f a u l t , e v e n f o r 6 4 - b i t t a r g e t s . T h i s c a n r e s u l t i n l i n k e r "
" i n s t a b i l i t y a n d o u t o f m e m o r y e r r o r s . T o u s e t h e 6 4 - b i t "
" h o s t c o m p i l e r , p a s s - T h o s t = x 6 4 o n t h e C M a k e c o m m a n d l i n e . " )
endif ( )
2019-07-08 18:29:29 +00:00
if ( CMAKE_GENERATOR STREQUAL "Xcode" AND NOT CMAKE_OSX_ARCHITECTURES )
# Some CMake features like object libraries get confused if you don't
# explicitly specify an architecture setting with the Xcode generator.
set ( CMAKE_OSX_ARCHITECTURES "x86_64" )
endif ( )
2016-03-28 18:19:32 +00:00
project ( LLVM
2017-11-02 20:33:36 +00:00
V E R S I O N $ { L L V M _ V E R S I O N _ M A J O R } . $ { L L V M _ V E R S I O N _ M I N O R } . $ { L L V M _ V E R S I O N _ P A T C H }
L A N G U A G E S C C X X A S M )
2016-03-28 18:19:32 +00:00
2022-08-20 10:33:21 -04:00
if ( NOT DEFINED CMAKE_INSTALL_LIBDIR AND DEFINED LLVM_LIBDIR_SUFFIX )
# Must go before `include(GNUInstallDirs)`.
set ( CMAKE_INSTALL_LIBDIR "lib${LLVM_LIBDIR_SUFFIX}" )
endif ( )
# Must go after `DEFINED LLVM_LIBDIR_SUFFIX` check.
set ( LLVM_LIBDIR_SUFFIX "" CACHE STRING "Define suffix of library directory name (32/64)" )
# Must go after `project(..)`.
2022-01-19 06:45:07 +00:00
include ( GNUInstallDirs )
2022-08-07 21:52:37 +02:00
# This C++ standard is required to build LLVM.
set ( LLVM_REQUIRED_CXX_STANDARD 17 )
# If we find that the cache contains CMAKE_CXX_STANDARD it means that it's a old CMakeCache.txt
# and we can just inform the user and then reset it.
if ( $ CACHE{CMAKE_CXX_STANDARD} AND $ CACHE{CMAKE_CXX_STANDARD} LESS ${ LLVM_REQUIRED_CXX_STANDARD } )
message ( WARNING "Resetting cache value for CMAKE_CXX_STANDARD to ${LLVM_REQUIRED_CXX_STANDARD}" )
unset ( CMAKE_CXX_STANDARD CACHE )
endif ( )
# if CMAKE_CXX_STANDARD is still set after the cache unset above it means that the user requested it
# and we allow it to be set to something newer than the required standard but otherwise we fail.
if ( DEFINED CMAKE_CXX_STANDARD AND CMAKE_CXX_STANDARD LESS ${ LLVM_REQUIRED_CXX_STANDARD } )
message ( FATAL_ERROR "Requested CMAKE_CXX_STANDARD=${CMAKE_CXX_STANDARD} which is less than the required ${LLVM_REQUIRED_CXX_STANDARD}." )
endif ( )
set ( CMAKE_CXX_STANDARD ${ LLVM_REQUIRED_CXX_STANDARD } CACHE STRING "C++ standard to conform to" )
2019-10-25 10:57:52 -07:00
set ( CMAKE_CXX_STANDARD_REQUIRED YES )
2022-08-07 21:52:37 +02:00
2020-12-03 10:37:18 -05:00
if ( CYGWIN )
# Cygwin is a bit stricter and lack things like 'strdup', 'stricmp', etc in
# c++xx mode.
set ( CMAKE_CXX_EXTENSIONS YES )
else ( )
set ( CMAKE_CXX_EXTENSIONS NO )
endif ( )
2019-10-25 10:57:52 -07:00
2016-08-18 18:17:28 +00:00
if ( NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES )
2022-04-29 11:42:06 +02:00
message ( FATAL_ERROR "
N o b u i l d t y p e s e l e c t e d . Y o u n e e d t o p a s s - D C M A K E _ B U I L D _ T Y P E = < t y p e > i n o r d e r t o c o n f i g u r e L L V M .
A v a i l a b l e o p t i o n s a r e :
* - D C M A K E _ B U I L D _ T Y P E = R e l e a s e - F o r a n o p t i m i z e d b u i l d w i t h n o a s s e r t i o n s o r d e b u g i n f o .
* - D C M A K E _ B U I L D _ T Y P E = D e b u g - F o r a n u n o p t i m i z e d b u i l d w i t h a s s e r t i o n s a n d d e b u g i n f o .
* - D C M A K E _ B U I L D _ T Y P E = R e l W i t h D e b I n f o - F o r a n o p t i m i z e d b u i l d w i t h n o a s s e r t i o n s b u t w i t h d e b u g i n f o .
* - D C M A K E _ B U I L D _ T Y P E = M i n S i z e R e l - F o r a b u i l d o p t i m i z e d f o r s i z e i n s t e a d o f s p e e d .
L e a r n m o r e a b o u t t h e s e o p t i o n s i n o u r d o c u m e n t a t i o n a t h t t p s : / / l l v m . o r g / d o c s / C M a k e . h t m l #cmake-build-type
" )
2016-08-18 18:17:28 +00:00
endif ( )
2022-09-12 16:46:04 +05:00
# Set default build type for cmake's try_compile module.
# CMake 3.17 or newer sets CMAKE_DEFAULT_BUILD_TYPE to one of the
# items from CMAKE_CONFIGURATION_TYPES. Logic below can be further
# simplified once LLVM's minimum CMake version is updated to 3.17.
if ( CMAKE_DEFAULT_BUILD_TYPE )
set ( CMAKE_TRY_COMPILE_CONFIGURATION ${ CMAKE_DEFAULT_BUILD_TYPE } )
else ( )
if ( CMAKE_CONFIGURATION_TYPES )
list ( GET CMAKE_CONFIGURATION_TYPES 0 CMAKE_TRY_COMPILE_CONFIGURATION )
elseif ( CMAKE_BUILD_TYPE )
set ( CMAKE_TRY_COMPILE_CONFIGURATION ${ CMAKE_BUILD_TYPE } )
endif ( )
endif ( )
2016-11-07 22:13:38 +00:00
# Side-by-side subprojects layout: automatically set the
# LLVM_EXTERNAL_${project}_SOURCE_DIR using LLVM_ALL_PROJECTS
# This allows an easy way of setting up a build directory for llvm and another
# one for llvm+clang+... using the same sources.
2022-09-21 09:50:53 -04:00
set ( LLVM_ALL_PROJECTS "bolt;clang;clang-tools-extra;compiler-rt;cross-project-tests;libc;libclc;lld;lldb;mlir;openmp;polly;pstl" )
2024-10-15 22:34:49 -04:00
if ( ${ CMAKE_SYSTEM_NAME } MATCHES "AIX" )
# Disallow 'openmp' as a LLVM PROJECT on AIX as the supported way is to use
# LLVM_ENABLE_RUNTIMES.
list ( REMOVE_ITEM LLVM_ALL_PROJECTS openmp )
endif ( )
2020-04-09 16:13:11 +01:00
# The flang project is not yet part of "all" projects (see C++ requirements)
set ( LLVM_EXTRA_PROJECTS "flang" )
# List of all known projects in the mono repo
2021-09-18 13:56:54 +03:00
set ( LLVM_KNOWN_PROJECTS "${LLVM_ALL_PROJECTS};${LLVM_EXTRA_PROJECTS}" )
2016-11-07 22:13:38 +00:00
set ( LLVM_ENABLE_PROJECTS "" CACHE STRING
2022-01-03 01:29:39 +00:00
" S e m i c o l o n - s e p a r a t e d l i s t o f p r o j e c t s t o build ( ${ LLVM_KNOWN_PROJECTS } ) , o r \ " a l l \ " . " )
2022-08-23 11:04:44 +02:00
# Make sure expansion happens first to not handle "all" in rest of the checks.
if ( LLVM_ENABLE_PROJECTS STREQUAL "all" )
set ( LLVM_ENABLE_PROJECTS ${ LLVM_ALL_PROJECTS } )
endif ( )
2021-09-24 18:48:08 -04:00
foreach ( proj ${ LLVM_ENABLE_PROJECTS } )
2022-08-23 11:04:44 +02:00
if ( NOT proj STREQUAL "llvm" AND NOT "${proj}" IN_LIST LLVM_KNOWN_PROJECTS )
2022-09-21 09:50:53 -04:00
MESSAGE ( FATAL_ERROR "${proj} isn't a known project: ${LLVM_KNOWN_PROJECTS}. Did you mean to enable it as a runtime in LLVM_ENABLE_RUNTIMES?" )
2021-10-28 10:42:51 -04:00
endif ( )
endforeach ( )
2021-09-18 02:38:17 +00:00
2021-05-04 15:52:15 +00:00
if ( "flang" IN_LIST LLVM_ENABLE_PROJECTS )
if ( NOT "mlir" IN_LIST LLVM_ENABLE_PROJECTS )
message ( STATUS "Enabling MLIR as a dependency to flang" )
list ( APPEND LLVM_ENABLE_PROJECTS "mlir" )
endif ( )
2021-07-12 08:44:38 +00:00
if ( NOT "clang" IN_LIST LLVM_ENABLE_PROJECTS )
2025-03-26 12:45:52 +01:00
message ( STATUS "Enabling clang as a dependency to flang" )
list ( APPEND LLVM_ENABLE_PROJECTS "clang" )
2021-05-04 15:52:15 +00:00
endif ( )
2020-05-21 05:30:49 +00:00
endif ( )
2019-02-05 08:47:28 +00:00
2024-12-02 14:47:58 -08:00
if ( "libc" IN_LIST LLVM_ENABLE_PROJECTS )
message ( WARNING "Using LLVM_ENABLE_PROJECTS=libc is deprecated now, and will "
" b e c o m e a f a t a l e r r o r i n t h e L L V M 2 1 r e l e a s e . P l e a s e u s e "
" - D L L V M _ E N A B L E _ R U N T I M E S = l i b c o r s e e t h e i n s t r u c t i o n s a t "
" h t t p s : / / l i b c . l l v m . o r g / f o r b u i l d i n g t h e r u n t i m e s . " )
endif ( )
2025-01-27 22:32:38 -08:00
if ( "compiler-rt" IN_LIST LLVM_ENABLE_PROJECTS )
message ( WARNING "Using LLVM_ENABLE_PROJECTS=compiler-rt is deprecated now, and will "
" b e c o m e a f a t a l e r r o r i n t h e L L V M 2 1 r e l e a s e . P l e a s e u s e "
" - D L L V M _ E N A B L E _ R U N T I M E S = c o m p i l e r - r t o r s e e t h e i n s t r u c t i o n s a t "
" h t t p s : / / c o m p i l e r - r t . l l v m . o r g / f o r b u i l d i n g t h e r u n t i m e s . " )
endif ( )
2025-02-16 15:39:52 +01:00
if ( "flang-rt" IN_LIST LLVM_ENABLE_RUNTIMES )
if ( NOT "flang" IN_LIST LLVM_ENABLE_PROJECTS )
message ( FATAL_ERROR "Flang is not enabled, but is required for the Flang-RT runtime" )
endif ( )
endif ( )
2022-08-23 11:10:18 -04:00
# Select the runtimes to build
2022-08-23 11:14:15 -04:00
#
# As we migrate runtimes to using the bootstrapping build, the set of default runtimes
# should grow as we remove those runtimes from LLVM_ENABLE_PROJECTS above.
set ( LLVM_DEFAULT_RUNTIMES "libcxx;libcxxabi;libunwind" )
2025-02-16 15:39:52 +01:00
set ( LLVM_SUPPORTED_RUNTIMES "libc;libunwind;libcxxabi;pstl;libcxx;compiler-rt;openmp;llvm-libgcc;offload;flang-rt" )
2022-08-23 11:10:18 -04:00
set ( LLVM_ENABLE_RUNTIMES "" CACHE STRING
" S e m i c o l o n - s e p a r a t e d l i s t o f r u n t i m e s t o b u i l d , o r \ " a l l \ " ( $ { L L V M _ D E F A U L T _ R U N T I M E S } ) . S u p p o r t e d r u n t i m e s a r e $ { L L V M _ S U P P O R T E D _ R U N T I M E S } . " )
if ( LLVM_ENABLE_RUNTIMES STREQUAL "all" )
set ( LLVM_ENABLE_RUNTIMES ${ LLVM_DEFAULT_RUNTIMES } )
endif ( )
foreach ( proj IN LISTS LLVM_ENABLE_RUNTIMES )
if ( NOT "${proj}" IN_LIST LLVM_SUPPORTED_RUNTIMES )
2022-12-05 11:33:29 +00:00
message ( FATAL_ERROR "Runtime \" ${ proj } \" is not a supported runtime. Supported runtimes are: ${ LLVM_SUPPORTED_RUNTIMES } " )
2022-08-23 11:10:18 -04:00
endif ( )
endforeach ( )
2024-03-13 14:25:22 -05:00
# Set a shorthand option to enable the GPU build of the 'libc' project.
option ( LIBC_GPU_BUILD "Enable the 'libc' project targeting the GPU" OFF )
if ( LIBC_GPU_BUILD )
if ( LLVM_RUNTIME_TARGETS )
list ( APPEND LLVM_RUNTIME_TARGETS "nvptx64-nvidia-cuda" "amdgcn-amd-amdhsa" )
else ( )
set ( LLVM_RUNTIME_TARGETS "default;nvptx64-nvidia-cuda;amdgcn-amd-amdhsa" )
endif ( )
list ( APPEND RUNTIMES_nvptx64-nvidia-cuda_LLVM_ENABLE_RUNTIMES "libc" )
list ( APPEND RUNTIMES_amdgcn-amd-amdhsa_LLVM_ENABLE_RUNTIMES "libc" )
endif ( )
2024-03-11 09:05:49 -05:00
foreach ( _name ${ LLVM_RUNTIME_TARGETS } )
if ( "libc" IN_LIST RUNTIMES_ ${ _name } _LLVM_ENABLE_RUNTIMES )
if ( "${_name}" STREQUAL "amdgcn-amd-amdhsa" OR "${_name}" STREQUAL "nvptx64-nvidia-cuda" )
set ( LLVM_LIBC_GPU_BUILD ON )
endif ( )
endif ( )
endforeach ( )
2024-03-11 09:18:47 -05:00
if ( "${LIBC_TARGET_TRIPLE}" STREQUAL "amdgcn-amd-amdhsa" OR
" $ { L I B C _ T A R G E T _ T R I P L E } " S T R E Q U A L " n v p t x 6 4 - n v i d i a - c u d a " )
set ( LLVM_LIBC_GPU_BUILD ON )
endif ( )
2024-09-25 14:32:29 -07:00
2019-02-05 08:47:28 +00:00
# LLVM_ENABLE_PROJECTS_USED is `ON` if the user has ever used the
# `LLVM_ENABLE_PROJECTS` CMake cache variable. This exists for
# several reasons:
#
# * As an indicator that the `LLVM_ENABLE_PROJECTS` list is now the single
# source of truth for which projects to build. This means we will ignore user
# supplied `LLVM_TOOL_<project>_BUILD` CMake cache variables and overwrite
# them.
#
# * The case where the user previously had `LLVM_ENABLE_PROJECTS` set to a
# non-empty list but now the user wishes to disable building all other projects
# by setting `LLVM_ENABLE_PROJECTS` to an empty string. In that case we still
# need to set the `LLVM_TOOL_${upper_proj}_BUILD` variables so that we disable
# building all the projects that were previously enabled.
set ( LLVM_ENABLE_PROJECTS_USED OFF CACHE BOOL "" )
mark_as_advanced ( LLVM_ENABLE_PROJECTS_USED )
if ( LLVM_ENABLE_PROJECTS_USED OR NOT LLVM_ENABLE_PROJECTS STREQUAL "" )
set ( LLVM_ENABLE_PROJECTS_USED ON CACHE BOOL "" FORCE )
2020-04-09 16:13:11 +01:00
foreach ( proj ${ LLVM_KNOWN_PROJECTS } ${ LLVM_EXTERNAL_PROJECTS } )
2019-02-05 08:47:28 +00:00
string ( TOUPPER "${proj}" upper_proj )
string ( REGEX REPLACE "-" "_" upper_proj ${ upper_proj } )
if ( "${proj}" IN_LIST LLVM_ENABLE_PROJECTS )
message ( STATUS "${proj} project is enabled" )
set ( SHOULD_ENABLE_PROJECT TRUE )
set ( PROJ_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../${proj}" )
if ( NOT EXISTS "${PROJ_DIR}" OR NOT IS_DIRECTORY "${PROJ_DIR}" )
message ( FATAL_ERROR "LLVM_ENABLE_PROJECTS requests ${proj} but directory not found: ${PROJ_DIR}" )
endif ( )
2019-07-26 19:25:57 +00:00
if ( LLVM_EXTERNAL_ ${ upper_proj } _SOURCE_DIR STREQUAL "" )
set ( LLVM_EXTERNAL_ ${ upper_proj } _SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../${proj}" CACHE PATH "" FORCE )
else ( )
set ( LLVM_EXTERNAL_ ${ upper_proj } _SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../${proj}" CACHE PATH "" )
endif ( )
2019-05-27 09:03:00 +00:00
elseif ( "${proj}" IN_LIST LLVM_EXTERNAL_PROJECTS )
message ( STATUS "${proj} project is enabled" )
set ( SHOULD_ENABLE_PROJECT TRUE )
2019-02-05 08:47:28 +00:00
else ( )
message ( STATUS "${proj} project is disabled" )
set ( SHOULD_ENABLE_PROJECT FALSE )
endif ( )
# Force `LLVM_TOOL_${upper_proj}_BUILD` variables to have values that
# corresponds with `LLVM_ENABLE_PROJECTS`. This prevents the user setting
# `LLVM_TOOL_${upper_proj}_BUILD` variables externally. At some point
# we should deprecate allowing users to set these variables by turning them
# into normal CMake variables rather than cache variables.
set ( LLVM_TOOL_ ${ upper_proj } _BUILD
$ { S H O U L D _ E N A B L E _ P R O J E C T }
C A C H E
B O O L " W h e t h e r t o b u i l d $ { u p p e r _ p r o j } a s p a r t o f L L V M " F O R C E
)
endforeach ( )
endif ( )
unset ( SHOULD_ENABLE_PROJECT )
2016-11-07 22:13:38 +00:00
2023-02-13 08:56:56 +01:00
# Build llvm with ccache if the package is present
set ( LLVM_CCACHE_BUILD OFF CACHE BOOL "Set to ON for a ccache enabled build" )
if ( LLVM_CCACHE_BUILD )
find_program ( CCACHE_PROGRAM ccache )
if ( CCACHE_PROGRAM )
set ( LLVM_CCACHE_MAXSIZE "" CACHE STRING "Size of ccache" )
set ( LLVM_CCACHE_DIR "" CACHE STRING "Directory to keep ccached data" )
set ( LLVM_CCACHE_PARAMS "CCACHE_CPP2=yes CCACHE_HASHDIR=yes"
C A C H E S T R I N G " P a r a m e t e r s t o p a s s t h r o u g h t o c c a c h e " )
if ( NOT CMAKE_SYSTEM_NAME MATCHES "Windows" )
set ( CCACHE_PROGRAM "${LLVM_CCACHE_PARAMS} ${CCACHE_PROGRAM}" )
if ( LLVM_CCACHE_MAXSIZE )
set ( CCACHE_PROGRAM "CCACHE_MAXSIZE=${LLVM_CCACHE_MAXSIZE} ${CCACHE_PROGRAM}" )
endif ( )
if ( LLVM_CCACHE_DIR )
set ( CCACHE_PROGRAM "CCACHE_DIR=${LLVM_CCACHE_DIR} ${CCACHE_PROGRAM}" )
endif ( )
set_property ( GLOBAL PROPERTY RULE_LAUNCH_COMPILE ${ CCACHE_PROGRAM } )
else ( )
if ( LLVM_CCACHE_MAXSIZE OR LLVM_CCACHE_DIR OR
N O T L L V M _ C C A C H E _ P A R A M S M A T C H E S " C C A C H E _ C P P 2 = y e s C C A C H E _ H A S H D I R = y e s " )
message ( FATAL_ERROR "Ccache configuration through CMake is not supported on Windows. Please use environment variables." )
endif ( )
# RULE_LAUNCH_COMPILE should work with Ninja but currently has issues
# with cmd.exe and some MSVC tools other than cl.exe
set ( CMAKE_C_COMPILER_LAUNCHER ${ CCACHE_PROGRAM } )
set ( CMAKE_CXX_COMPILER_LAUNCHER ${ CCACHE_PROGRAM } )
endif ( )
else ( )
message ( FATAL_ERROR "Unable to find the program ccache. Set LLVM_CCACHE_BUILD to OFF" )
endif ( )
2016-08-01 21:28:03 +00:00
endif ( )
2021-12-14 14:34:44 +00:00
set ( LLVM_EXTERNAL_PROJECT_BUILD_TOOL_ARGS "" CACHE STRING
" O p t i o n a l a r g u m e n t s f o r t h e n a t i v e t o o l u s e d i n C M a k e - - b u i l d i n v o c a t i o n s f o r e x t e r n a l p r o j e c t s . " )
mark_as_advanced ( LLVM_EXTERNAL_PROJECT_BUILD_TOOL_ARGS )
2016-11-17 04:36:59 +00:00
option ( LLVM_DEPENDENCY_DEBUGGING "Dependency debugging mode to verify correctly expressed library dependencies (Darwin only)" OFF )
# Some features of the LLVM build may be disallowed when dependency debugging is
# enabled. In particular you cannot use ccache because we want to force compile
# operations to always happen.
if ( LLVM_DEPENDENCY_DEBUGGING )
if ( NOT CMAKE_HOST_APPLE )
message ( FATAL_ERROR "Dependency debugging is only currently supported on Darwin hosts." )
endif ( )
2023-02-13 08:56:56 +01:00
if ( LLVM_CCACHE_BUILD )
message ( FATAL_ERROR "Cannot enable dependency debugging while using ccache." )
2016-11-17 04:36:59 +00:00
endif ( )
endif ( )
2017-02-14 18:32:41 +00:00
option ( LLVM_ENABLE_DAGISEL_COV "Debug: Prints tablegen patterns that were used for selecting" OFF )
[globalisel][tablegen] Generate rule coverage and use it to identify untested rules
Summary:
This patch adds a LLVM_ENABLE_GISEL_COV which, like LLVM_ENABLE_DAGISEL_COV,
causes TableGen to instrument the generated table to collect rule coverage
information. However, LLVM_ENABLE_GISEL_COV goes a bit further than
LLVM_ENABLE_DAGISEL_COV. The information is written to files
(${CMAKE_BINARY_DIR}/gisel-coverage-* by default). These files can then be
concatenated into ${LLVM_GISEL_COV_PREFIX}-all after which TableGen will
read this information and use it to emit warnings about untested rules.
This technique could also be used by SelectionDAG and can be further
extended to detect hot rules and give them priority over colder rules.
Usage:
* Enable LLVM_ENABLE_GISEL_COV in CMake
* Build the compiler and run some tests
* cat gisel-coverage-[0-9]* > gisel-coverage-all
* Delete lib/Target/*/*GenGlobalISel.inc*
* Build the compiler
Known issues:
* ${LLVM_GISEL_COV_PREFIX}-all must be generated as a manual
step due to a lack of a portable 'cat' command. It should be the
concatenation of all ${LLVM_GISEL_COV_PREFIX}-[0-9]* files.
* There's no mechanism to discard coverage information when the ruleset
changes
Depends on D39742
Reviewers: ab, qcolombet, t.p.northover, aditya_nandakumar, rovka
Reviewed By: rovka
Subscribers: vsk, arsenm, nhaehnle, mgorny, kristof.beyls, javed.absar, igorb, llvm-commits
Differential Revision: https://reviews.llvm.org/D39747
llvm-svn: 318356
2017-11-16 00:46:35 +00:00
option ( LLVM_ENABLE_GISEL_COV "Enable collection of GlobalISel rule coverage" OFF )
if ( LLVM_ENABLE_GISEL_COV )
set ( LLVM_GISEL_COV_PREFIX "${CMAKE_BINARY_DIR}/gisel-coverage-" CACHE STRING "Provide a filename prefix to collect the GlobalISel rule coverage" )
endif ( )
2017-02-14 18:32:41 +00:00
2016-03-28 18:19:32 +00:00
# Add path for custom modules
2022-01-03 02:25:06 +00:00
list ( INSERT CMAKE_MODULE_PATH 0
2016-03-28 18:19:32 +00:00
" $ { C M A K E _ C U R R E N T _ S O U R C E _ D I R } / c m a k e "
" $ { C M A K E _ C U R R E N T _ S O U R C E _ D I R } / c m a k e / m o d u l e s "
2022-01-03 02:25:06 +00:00
" $ { L L V M _ C O M M O N _ C M A K E _ U T I L S } / M o d u l e s "
2016-03-28 18:19:32 +00:00
)
# Generate a CompilationDatabase (compile_commands.json file) for our build,
# for use by clang_complete, YouCompleteMe, etc.
set ( CMAKE_EXPORT_COMPILE_COMMANDS 1 )
2017-11-02 21:43:32 +00:00
option ( LLVM_INSTALL_BINUTILS_SYMLINKS
" I n s t a l l s y m l i n k s f r o m t h e b i n u t i l s t o o l n a m e s t o t h e c o r r e s p o n d i n g L L V M t o o l s . " O F F )
2019-07-31 16:46:57 +00:00
option ( LLVM_INSTALL_CCTOOLS_SYMLINKS
" I n s t a l l s y m l i n k s f r o m t h e c c t o o l s t o o l n a m e s t o t h e c o r r e s p o n d i n g L L V M t o o l s . " O F F )
2022-10-12 10:04:21 +02:00
# By default we use symlinks on Unix platforms and copy binaries on Windows
# If you have the correct setup on Windows you can use this option to enable
# symlinks and save a lot of diskspace.
option ( LLVM_USE_SYMLINKS "Use symlinks instead of copying binaries" ${ CMAKE_HOST_UNIX } )
2016-03-28 18:19:32 +00:00
option ( LLVM_INSTALL_UTILS "Include utility binaries in the 'install' target." OFF )
option ( LLVM_INSTALL_TOOLCHAIN_ONLY "Only include toolchain files in the 'install' target." OFF )
[LLVM] Allow modulemap installation
Summary:
Currently we can't install the modulemaps provided by LLVM, since they are not structured to support headers generated as part of the build (ex. `llvm/IR/Attributes.gen`).
This patch restructures the module maps in order to support installation.
Modules containing generated headers are defined in the new `module.extern.modulemap` file, and are referenced from the main `module.modulemap` using `extern module`. There are two versions of the `module.extern.modulemap` file; one used when building and another, `module.install.modulemap`, which is re-named during installation.
Users can opt-into module map installation using `-DLLVM_INSTALL_MODULEMAPS=ON`. The default value is `OFF` due to llvm.org/PR31905.
Reviewers: rsmith, mehdi_amini, bruno, EricWF
Reviewed By: EricWF
Subscribers: tschuett, chapuni, mgorny, llvm-commits
Differential Revision: https://reviews.llvm.org/D53510
llvm-svn: 347420
2018-11-21 20:46:50 +00:00
# Unfortunatly Clang is too eager to search directories for module maps, which can cause the
# installed version of the maps to be found when building LLVM from source. Therefore we turn off
# the installation by default. See llvm.org/PR31905.
option ( LLVM_INSTALL_MODULEMAPS "Install the modulemap files in the 'install' target." OFF )
2016-03-28 18:19:32 +00:00
option ( LLVM_USE_FOLDERS "Enable solution folders in Visual Studio. Disable for Express versions." ON )
if ( LLVM_USE_FOLDERS )
set_property ( GLOBAL PROPERTY USE_FOLDERS ON )
endif ( )
include ( VersionFromVCS )
option ( LLVM_APPEND_VC_REV
2019-02-06 03:51:00 +00:00
" E m b e d t h e v e r s i o n c o n t r o l s y s t e m r e v i s i o n i n L L V M " O N )
2016-03-28 18:19:32 +00:00
2023-09-25 14:32:52 +01:00
set ( LLVM_FORCE_VC_REVISION
" " C A C H E S T R I N G " F o r c e c u s t o m V C r e v i s i o n f o r L L V M _ A P P E N D _ V C _ R E V " )
set ( LLVM_FORCE_VC_REPOSITORY
" " C A C H E S T R I N G " F o r c e c u s t o m V C r e p o s i t o r y f o r L L V M _ A P P E N D _ V C _ R E V " )
2022-06-06 04:25:55 +00:00
option ( LLVM_TOOL_LLVM_DRIVER_BUILD "Enables building the llvm multicall tool" OFF )
2016-03-28 18:19:32 +00:00
set ( PACKAGE_NAME LLVM )
set ( PACKAGE_STRING "${PACKAGE_NAME} ${PACKAGE_VERSION}" )
2022-01-06 17:33:25 +08:00
set ( PACKAGE_BUGREPORT "https://github.com/llvm/llvm-project/issues/" )
2016-03-28 18:19:32 +00:00
set ( BUG_REPORT_URL "${PACKAGE_BUGREPORT}" CACHE STRING
" D e f a u l t U R L w h e r e b u g r e p o r t s a r e t o b e s u b m i t t e d . " )
2024-01-16 10:50:48 -05:00
set ( LLDB_BUG_REPORT_URL "${BUG_REPORT_URL}" CACHE STRING
" D e f a u l t U R L w h e r e l l d b b u g r e p o r t s a r e t o b e s u b m i t t e d . " )
2016-03-28 18:19:32 +00:00
# Configure CPack.
2022-12-06 10:55:17 +01:00
if ( NOT DEFINED CPACK_PACKAGE_INSTALL_DIRECTORY )
set ( CPACK_PACKAGE_INSTALL_DIRECTORY "LLVM" )
endif ( )
if ( NOT DEFINED CPACK_PACKAGE_VENDOR )
set ( CPACK_PACKAGE_VENDOR "LLVM" )
endif ( )
2016-03-28 18:19:32 +00:00
set ( CPACK_PACKAGE_VERSION_MAJOR ${ LLVM_VERSION_MAJOR } )
set ( CPACK_PACKAGE_VERSION_MINOR ${ LLVM_VERSION_MINOR } )
set ( CPACK_PACKAGE_VERSION_PATCH ${ LLVM_VERSION_PATCH } )
set ( CPACK_PACKAGE_VERSION ${ PACKAGE_VERSION } )
set ( CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE.TXT" )
if ( WIN32 AND NOT UNIX )
2022-12-06 10:55:17 +01:00
set ( CPACK_NSIS_COMPRESSOR "/SOLID lzma \r\n SetCompressorDictSize 32" )
if ( NOT DEFINED CPACK_PACKAGE_INSTALL_REGISTRY_KEY )
set ( CPACK_PACKAGE_INSTALL_REGISTRY_KEY "LLVM" )
endif ( )
2016-03-28 18:19:32 +00:00
set ( CPACK_PACKAGE_ICON "${CMAKE_CURRENT_SOURCE_DIR}\\\\cmake\\\\nsis_logo.bmp" )
set ( CPACK_NSIS_MUI_ICON "${CMAKE_CURRENT_SOURCE_DIR}\\\\cmake\\\\nsis_icon.ico" )
set ( CPACK_NSIS_MUI_UNIICON "${CMAKE_CURRENT_SOURCE_DIR}\\\\cmake\\\\nsis_icon.ico" )
set ( CPACK_NSIS_MODIFY_PATH "ON" )
set ( CPACK_NSIS_ENABLE_UNINSTALL_BEFORE_INSTALL "ON" )
if ( CMAKE_CL_64 )
2022-12-06 10:55:17 +01:00
if ( NOT DEFINED CPACK_NSIS_INSTALL_ROOT )
set ( CPACK_NSIS_INSTALL_ROOT "$PROGRAMFILES64" )
endif ( )
2016-03-28 18:19:32 +00:00
endif ( )
endif ( )
include ( CPack )
# Sanity check our source directory to make sure that we are not trying to
2017-09-27 21:37:33 +00:00
# generate an in-source build (unless on MSVC_IDE, where it is ok), and to make
2016-03-28 18:19:32 +00:00
# sure that we don't have any stray generated files lying around in the tree
# (which would end up getting picked up by header search, instead of the correct
# versions).
2017-10-19 00:43:48 +00:00
if ( CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_CURRENT_BINARY_DIR AND NOT MSVC_IDE )
2016-03-28 18:19:32 +00:00
message ( FATAL_ERROR " In-source builds are not allowed.
P l e a s e c r e a t e a d i r e c t o r y a n d r u n c m a k e f r o m t h e r e , p a s s i n g t h e p a t h
t o t h i s s o u r c e d i r e c t o r y a s t h e l a s t a r g u m e n t .
T h i s p r o c e s s c r e a t e d t h e f i l e ` C M a k e C a c h e . t x t ' a n d t h e d i r e c t o r y ` C M a k e F i l e s ' .
P l e a s e d e l e t e t h e m . " )
endif ( )
string ( TOUPPER "${CMAKE_BUILD_TYPE}" uppercase_CMAKE_BUILD_TYPE )
2023-11-16 10:32:14 -08:00
option ( LLVM_ADDITIONAL_BUILD_TYPES "Additional build types that are allowed to be passed into CMAKE_BUILD_TYPE" "" )
set ( ALLOWED_BUILD_TYPES DEBUG RELEASE RELWITHDEBINFO MINSIZEREL ${ LLVM_ADDITIONAL_BUILD_TYPES } )
string ( REPLACE ";" "|" ALLOWED_BUILD_TYPES_STRING "${ALLOWED_BUILD_TYPES}" )
string ( TOUPPER "${ALLOWED_BUILD_TYPES_STRING}" uppercase_ALLOWED_BUILD_TYPES )
2016-03-28 18:19:32 +00:00
if ( CMAKE_BUILD_TYPE AND
2023-11-16 10:32:14 -08:00
N O T u p p e r c a s e _ C M A K E _ B U I L D _ T Y P E M A T C H E S " ^ ( $ { u p p e r c a s e _ A L L O W E D _ B U I L D _ T Y P E S } ) $ " )
message ( FATAL_ERROR "Unknown value for CMAKE_BUILD_TYPE: ${CMAKE_BUILD_TYPE}" )
2016-03-28 18:19:32 +00:00
endif ( )
2022-08-15 09:50:14 +02:00
# LLVM_INSTALL_PACKAGE_DIR needs to be declared prior to adding the tools
# subdirectory in order to have the value available for llvm-config.
include ( GNUInstallPackageDir )
set ( LLVM_INSTALL_PACKAGE_DIR "${CMAKE_INSTALL_PACKAGEDIR}/llvm" CACHE STRING
" P a t h f o r C M a k e s u b d i r e c t o r y f o r LLVM ( defaults to ' ${ CMAKE_INSTALL_PACKAGEDIR } /llvm' ) " )
2021-12-11 01:36:24 +00:00
set ( LLVM_TOOLS_INSTALL_DIR "${CMAKE_INSTALL_BINDIR}" CACHE STRING
" P a t h f o r b i n a r y subdirectory ( defaults to ' ${ CMAKE_INSTALL_BINDIR } ' ) " )
2016-06-08 21:19:26 +00:00
mark_as_advanced ( LLVM_TOOLS_INSTALL_DIR )
2018-01-19 17:02:12 +00:00
set ( LLVM_UTILS_INSTALL_DIR "${LLVM_TOOLS_INSTALL_DIR}" CACHE STRING
2017-07-05 12:57:30 +00:00
" P a t h t o i n s t a l l L L V M utilities ( enabled by LLVM_INSTALL_UTILS=ON ) ( d e f a u l t s t o L L V M _ T O O L S _ I N S T A L L _ D I R ) " )
2018-01-19 17:02:12 +00:00
mark_as_advanced ( LLVM_UTILS_INSTALL_DIR )
2017-07-05 12:57:30 +00:00
2021-12-11 01:36:24 +00:00
set ( LLVM_EXAMPLES_INSTALL_DIR "examples" CACHE STRING
" P a t h f o r e x a m p l e s subdirectory ( enabled by LLVM_BUILD_EXAMPLES=ON ) ( d e f a u l t s t o ' e x a m p l e s ' ) " )
mark_as_advanced ( LLVM_EXAMPLES_INSTALL_DIR )
2016-03-28 18:19:32 +00:00
# They are used as destination of target generators.
set ( LLVM_RUNTIME_OUTPUT_INTDIR ${ CMAKE_CURRENT_BINARY_DIR } / ${ CMAKE_CFG_INTDIR } /bin )
2022-08-18 22:44:46 -04:00
set ( LLVM_LIBRARY_OUTPUT_INTDIR ${ CMAKE_CURRENT_BINARY_DIR } / ${ CMAKE_CFG_INTDIR } /lib ${ LLVM_LIBDIR_SUFFIX } )
2016-03-28 18:19:32 +00:00
if ( WIN32 OR CYGWIN )
# DLL platform -- put DLLs into bin.
set ( LLVM_SHLIB_OUTPUT_INTDIR ${ LLVM_RUNTIME_OUTPUT_INTDIR } )
else ( )
set ( LLVM_SHLIB_OUTPUT_INTDIR ${ LLVM_LIBRARY_OUTPUT_INTDIR } )
endif ( )
# Each of them corresponds to llvm-config's.
set ( LLVM_TOOLS_BINARY_DIR ${ LLVM_RUNTIME_OUTPUT_INTDIR } ) # --bindir
set ( LLVM_LIBRARY_DIR ${ LLVM_LIBRARY_OUTPUT_INTDIR } ) # --libdir
set ( LLVM_MAIN_SRC_DIR ${ CMAKE_CURRENT_SOURCE_DIR } ) # --src-root
set ( LLVM_MAIN_INCLUDE_DIR ${ LLVM_MAIN_SRC_DIR } /include ) # --includedir
set ( LLVM_BINARY_DIR ${ CMAKE_CURRENT_BINARY_DIR } ) # --prefix
2021-12-07 16:46:55 -08:00
2021-09-16 18:27:53 +02:00
# Note: LLVM_CMAKE_DIR does not include generated files
set ( LLVM_CMAKE_DIR ${ LLVM_MAIN_SRC_DIR } /cmake/modules )
2016-03-28 18:19:32 +00:00
set ( LLVM_EXAMPLES_BINARY_DIR ${ LLVM_BINARY_DIR } /examples )
set ( LLVM_INCLUDE_DIR ${ CMAKE_CURRENT_BINARY_DIR } /include )
2017-08-13 18:49:33 +00:00
# List of all targets to be built by default:
2016-03-28 18:19:32 +00:00
set ( LLVM_ALL_TARGETS
A A r c h 6 4
A M D G P U
A R M
[AVR] Include AVR by default in LLVM builds
This was initially committed and promptly reverted in 9059056e273ccc3a236751609e498b4c401eb6ff
after a MSan failure was found by the sanitizer bots.
These have since been fixed.
Summary:
This patch makes the AVR backend an official target of LLVM, serving
as a request for comments for moving the AVR backend out of
experimental.
A future patch will move the LLVM AVR buildbot (llvm-avr-linux) from the
staging buildmaster to the production buildmaster, so error emails will
start to go out.
Summary of the backend
----------------------
- 16-bit little endian
- AsmParser based assembly parser
- uses the MC library for generating AVR ELFs
- most logic driven from standard TableGen-erated tables like other
backends
- passes all of the test suite under `check-all`, including generic
CodeGen and DebugInfo tests
- Used in two frontends
- Limited, but functional support for DebugInfo and LLVM DWARF dumping
- Binary compatible with AVR-GCC and avr-{libc,libgcc} for the most part
- Cannot lower 32-bit shifts due to a bug, can lower shifts larger or
smaller
- Supports assembly/MC for all the entire AVR ISA, generally generates poorly
optimized machine instructions, with most focus thus far on correctness
I've added reviewers and subscribers from previous patches where backends were made official,
and those who participated in the recent thread on llvm-dev, please add anybody I've missed.
The most recent discussion on this topic can be found in the llvm-dev thread [Moving the AVR backend out of experimental](https://lists.llvm.org/pipermail/llvm-dev/2020-February/139158.html)
Reviewers: chandlerc, lattner, rengolin, tstellar, arsenm, thakis, simoll, asb
Reviewed By: rengolin, thakis
Subscribers: CryZe, wdng, mgorny, aprantl, Jim, hans, aykevl, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D75099
2020-03-12 19:07:01 +13:00
A V R
2016-03-28 18:19:32 +00:00
B P F
H e x a g o n
2016-08-23 01:06:44 +00:00
L a n a i
2023-01-11 16:35:48 +08:00
L o o n g A r c h
2016-03-28 18:19:32 +00:00
M i p s
M S P 4 3 0
N V P T X
P o w e r P C
2019-07-18 04:05:18 +00:00
R I S C V
2016-03-28 18:19:32 +00:00
S p a r c
2025-01-21 12:39:03 +01:00
S P I R V
2016-03-28 18:19:32 +00:00
S y s t e m Z
2021-12-02 11:17:47 +01:00
V E
2018-10-03 23:56:52 +00:00
W e b A s s e m b l y
2016-03-28 18:19:32 +00:00
X 8 6
X C o r e
)
2023-06-27 16:28:08 -07:00
set ( LLVM_ALL_EXPERIMENTAL_TARGETS
A R C
C S K Y
D i r e c t X
M 6 8 k
X t e n s a
)
2016-03-28 18:19:32 +00:00
# List of targets with JIT support:
set ( LLVM_TARGETS_WITH_JIT X86 PowerPC AArch64 ARM Mips SystemZ )
set ( LLVM_TARGETS_TO_BUILD "all"
C A C H E S T R I N G " S e m i c o l o n - s e p a r a t e d l i s t o f t a r g e t s t o b u i l d , o r \ " a l l \ " . " )
set ( LLVM_EXPERIMENTAL_TARGETS_TO_BUILD ""
2023-06-27 16:28:08 -07:00
C A C H E S T R I N G " S e m i c o l o n - s e p a r a t e d l i s t o f e x p e r i m e n t a l t a r g e t s t o b u i l d , o r \ " a l l \ " . " )
2016-03-28 18:19:32 +00:00
option ( BUILD_SHARED_LIBS
" B u i l d a l l l i b r a r i e s a s s h a r e d l i b r a r i e s i n s t e a d o f s t a t i c " O F F )
option ( LLVM_ENABLE_BACKTRACES "Enable embedding backtraces on crash." ON )
if ( LLVM_ENABLE_BACKTRACES )
set ( ENABLE_BACKTRACES 1 )
endif ( )
2019-05-02 19:37:26 +00:00
option ( LLVM_ENABLE_UNWIND_TABLES "Emit unwind tables for the libraries" ON )
2016-03-28 18:19:32 +00:00
option ( LLVM_ENABLE_CRASH_OVERRIDES "Enable crash overrides." ON )
if ( LLVM_ENABLE_CRASH_OVERRIDES )
set ( ENABLE_CRASH_OVERRIDES 1 )
endif ( )
2018-08-20 16:49:54 +00:00
option ( LLVM_ENABLE_CRASH_DUMPS "Turn on memory dumps on crashes. Currently only implemented on Windows." OFF )
2024-10-08 18:15:46 +01:00
set ( LLVM_ENABLE_DEBUGLOC_COVERAGE_TRACKING "DISABLED" CACHE STRING
" E n h a n c e D e b u g i f y ' s l i n e n u m b e r c o v e r a g e t r a c k i n g ; e n a b l i n g t h i s i s A B I - b r e a k i n g . C a n b e D I S A B L E D , o r C O V E R A G E . " )
set_property ( CACHE LLVM_ENABLE_DEBUGLOC_COVERAGE_TRACKING PROPERTY STRINGS DISABLED COVERAGE )
2025-03-17 11:32:59 +00:00
option ( LLVM_EXPERIMENTAL_KEY_INSTRUCTIONS
" A d d a d d i t i o n a l f i e l d s t o D I L o c a t i o n s t o s u p p o r t K e y I n s t r u c t i o n s " O F F )
2021-10-13 12:18:32 +00:00
set ( WINDOWS_PREFER_FORWARD_SLASH_DEFAULT OFF )
if ( MINGW )
# Cygwin doesn't identify itself as Windows, and thus gets path::Style::posix
# as native path style, regardless of what this is set to.
set ( WINDOWS_PREFER_FORWARD_SLASH_DEFAULT ON )
endif ( )
option ( LLVM_WINDOWS_PREFER_FORWARD_SLASH "Prefer path names with forward slashes on Windows." ${ WINDOWS_PREFER_FORWARD_SLASH_DEFAULT } )
2016-03-28 18:19:32 +00:00
option ( LLVM_ENABLE_FFI "Use libffi to call external functions from the interpreter" OFF )
set ( FFI_LIBRARY_DIR "" CACHE PATH "Additional directory, where CMake should search for libffi.so" )
set ( FFI_INCLUDE_DIR "" CACHE PATH "Additional directory, where CMake should search for ffi.h or ffi/ffi.h" )
set ( LLVM_TARGET_ARCH "host"
C A C H E S T R I N G " S e t t a r g e t t o u s e f o r L L V M J I T o r u s e \ " h o s t \ " f o r a u t o m a t i c d e t e c t i o n . " )
2017-11-14 22:32:49 +00:00
set ( LLVM_ENABLE_LIBXML2 "ON" CACHE STRING "Use libxml2 if available. Can be ON, OFF, or FORCE_ON" )
2017-07-20 21:42:04 +00:00
2016-11-18 01:25:49 +00:00
option ( LLVM_ENABLE_LIBEDIT "Use libedit if available." ON )
2018-04-11 07:32:43 +00:00
option ( LLVM_ENABLE_LIBPFM "Use libpfm for performance counters if available." ON )
2020-07-09 14:17:33 +02:00
# On z/OS, threads cannot be used because TLS is not supported.
if ( CMAKE_SYSTEM_NAME MATCHES "OS390" )
option ( LLVM_ENABLE_THREADS "Use threads if available." OFF )
else ( )
option ( LLVM_ENABLE_THREADS "Use threads if available." ON )
endif ( )
2016-03-28 18:19:32 +00:00
2020-03-12 15:51:40 -07:00
set ( LLVM_ENABLE_ZLIB "ON" CACHE STRING "Use zlib for compression/decompression if available. Can be ON, OFF, or FORCE_ON" )
2016-03-28 18:19:32 +00:00
2022-07-19 10:54:35 -07:00
set ( LLVM_ENABLE_ZSTD "ON" CACHE STRING "Use zstd for compression/decompression if available. Can be ON, OFF, or FORCE_ON" )
2022-09-02 21:00:07 +00:00
set ( LLVM_USE_STATIC_ZSTD FALSE CACHE BOOL "Use static version of zstd. Can be TRUE, FALSE" )
2022-09-01 07:49:42 -07:00
2021-12-13 17:39:01 +00:00
set ( LLVM_ENABLE_CURL "OFF" CACHE STRING "Use libcurl for the HTTP client if available. Can be ON, OFF, or FORCE_ON" )
2021-12-02 19:33:04 +00:00
2024-08-25 08:17:48 +09:00
set ( LLVM_HAS_LOGF128 "OFF" CACHE STRING "Use logf128 to constant fold fp128 logarithm calls. Can be ON, OFF, or FORCE_ON" )
2022-07-06 18:39:59 +00:00
set ( LLVM_ENABLE_HTTPLIB "OFF" CACHE STRING "Use cpp-httplib HTTP server library if available. Can be ON, OFF, or FORCE_ON" )
2019-03-25 17:47:45 +00:00
set ( LLVM_Z3_INSTALL_DIR "" CACHE STRING "Install directory of the Z3 solver." )
option ( LLVM_ENABLE_Z3_SOLVER
" E n a b l e S u p p o r t f o r t h e Z 3 c o n s t r a i n t s o l v e r i n L L V M . "
$ { L L V M _ E N A B L E _ Z 3 _ S O L V E R _ D E F A U L T }
)
if ( LLVM_ENABLE_Z3_SOLVER )
2024-06-26 17:53:16 +02:00
find_package ( Z3 4.8.9 )
2020-12-14 17:45:44 +00:00
2020-06-06 16:18:52 -04:00
if ( LLVM_Z3_INSTALL_DIR )
if ( NOT Z3_FOUND )
2024-06-26 17:53:16 +02:00
message ( FATAL_ERROR "Z3 >= 4.8.9 has not been found in LLVM_Z3_INSTALL_DIR: ${LLVM_Z3_INSTALL_DIR}." )
2020-06-06 16:18:52 -04:00
endif ( )
endif ( )
2020-12-14 17:45:44 +00:00
2019-03-25 17:47:45 +00:00
if ( NOT Z3_FOUND )
message ( FATAL_ERROR "LLVM_ENABLE_Z3_SOLVER cannot be enabled when Z3 is not available." )
endif ( )
set ( LLVM_WITH_Z3 1 )
endif ( )
2020-06-06 16:18:52 -04:00
set ( LLVM_ENABLE_Z3_SOLVER_DEFAULT "${Z3_FOUND}" )
2016-03-28 18:19:32 +00:00
if ( LLVM_TARGETS_TO_BUILD STREQUAL "all" )
set ( LLVM_TARGETS_TO_BUILD ${ LLVM_ALL_TARGETS } )
endif ( )
2023-06-27 16:28:08 -07:00
if ( LLVM_EXPERIMENTAL_TARGETS_TO_BUILD STREQUAL "all" )
set ( LLVM_EXPERIMENTAL_TARGETS_TO_BUILD ${ LLVM_ALL_EXPERIMENTAL_TARGETS } )
endif ( )
2016-03-28 18:19:32 +00:00
set ( LLVM_TARGETS_TO_BUILD
$ { L L V M _ T A R G E T S _ T O _ B U I L D }
$ { L L V M _ E X P E R I M E N T A L _ T A R G E T S _ T O _ B U I L D } )
list ( REMOVE_DUPLICATES LLVM_TARGETS_TO_BUILD )
2023-12-07 15:04:56 -05:00
if ( NOT CMAKE_SYSTEM_NAME MATCHES "OS390" )
option ( LLVM_ENABLE_PIC "Build Position-Independent Code" ON )
endif ( )
2016-03-28 18:19:32 +00:00
option ( LLVM_ENABLE_MODULES "Compile with C++ modules enabled." OFF )
2016-06-30 01:46:49 +00:00
if ( ${ CMAKE_SYSTEM_NAME } MATCHES "Darwin" )
2016-06-30 17:15:44 +00:00
option ( LLVM_ENABLE_MODULE_DEBUGGING "Compile with -gmodules." ON )
2016-06-30 01:46:49 +00:00
else ( )
2016-06-30 17:15:44 +00:00
option ( LLVM_ENABLE_MODULE_DEBUGGING "Compile with -gmodules." OFF )
2016-06-30 01:46:49 +00:00
endif ( )
Reland [lldb][cmake] Also use local submodule visibility on Darwin
Relanding this as D79632 should fix the macOS tests with this option.
Original commit:
Summary:
Currently building LLVM on macOS and on other platforms with LLVM_ENABLE_MODULES is using different module flags,
which means that a passing modules build on macOS might fail on Linux and vice versa. -fmodules-local-submodule-visibility
is the mode that has clearer semantics and is closer to the actual C++ module standard, so let's make this the default everywhere.
We can still test building without local submodule visibility on an additional bot by just changing the respective CMake flag. However,
if building without local-submodule-visibility breaks we won't revert other commits and we won't loose LLDB's/Clang's test run
information.
Reviewers: aprantl, bruno, Bigcheese
Reviewed By: Bigcheese
Subscribers: abidh, dexonsmith, JDevlieghere, lldb-commits, mgorny, llvm-commits
Tags: #llvm, #lldb
Differential Revision: https://reviews.llvm.org/D74892
2020-04-27 14:58:50 +02:00
option ( LLVM_ENABLE_LOCAL_SUBMODULE_VISIBILITY "Compile with -fmodules-local-submodule-visibility." ON )
2016-03-28 18:19:32 +00:00
option ( LLVM_ENABLE_LIBCXX "Use libc++ if available." OFF )
2023-05-28 02:34:30 +00:00
option ( LLVM_ENABLE_LLVM_LIBC "Set to on to link all LLVM executables against LLVM libc, assuming it is accessible by the host compiler." OFF )
2019-08-14 19:55:59 +00:00
option ( LLVM_STATIC_LINK_CXX_STDLIB "Statically link the standard library." OFF )
2016-07-29 00:46:13 +00:00
option ( LLVM_ENABLE_LLD "Use lld as C and C++ linker." OFF )
2016-03-28 18:19:32 +00:00
option ( LLVM_ENABLE_PEDANTIC "Compile with pedantic enabled." ON )
option ( LLVM_ENABLE_WERROR "Fail and stop if a warning is triggered." OFF )
2017-12-07 22:55:40 +00:00
option ( LLVM_ENABLE_DUMP "Enable dump functions even when assertions are disabled" OFF )
2022-03-17 22:19:33 +00:00
option ( LLVM_UNREACHABLE_OPTIMIZE "Optimize llvm_unreachable() as undefined behavior (default), guaranteed trap when OFF" ON )
2017-10-15 14:32:27 +00:00
2016-03-28 18:19:32 +00:00
if ( NOT uppercase_CMAKE_BUILD_TYPE STREQUAL "DEBUG" )
option ( LLVM_ENABLE_ASSERTIONS "Enable assertions" OFF )
else ( )
option ( LLVM_ENABLE_ASSERTIONS "Enable assertions" ON )
endif ( )
2016-04-29 15:22:48 +00:00
2017-09-27 21:19:56 +00:00
option ( LLVM_ENABLE_EXPENSIVE_CHECKS "Enable expensive checks" OFF )
2017-09-26 02:36:58 +00:00
2020-03-13 09:13:34 +00:00
# While adding scalable vector support to LLVM, we temporarily want to
2020-04-23 09:52:49 -07:00
# allow an implicit conversion of TypeSize to uint64_t, and to allow
# code to get the fixed number of elements from a possibly scalable vector.
# This CMake flag enables a more strict mode where it asserts that the type
# is not a scalable vector type.
2020-03-13 09:13:34 +00:00
#
# Enabling this flag makes it easier to find cases where the compiler makes
# assumptions on the size being 'fixed size', when building tests for
# SVE/SVE2 or other scalable vector architectures.
[ValueTypes] Add EVT::isFixedLengthVector
Summary:
Related to D75672, this patch adds EVT::isFixedLengthVector to determine
if the underlying vector type is of fixed length.
An assert is introduced in EVT::getVectorNumElements that triggers for
types that aren't fixed length. This is currently guarded by a flag
added D75297 that is off by default and has been renamed to the more
generic ENABLE_STRICT_FIXED_SIZE_VECTORS.
Ideally we want to get rid of getVectorNumElements but a quick grep
shows there are >350 uses in lib/CodeGen and 75 in lib/Target/AArch64
alone. All of these probably aren't EVT::getVectorNumElements (some may
be the MVT equivalent), but there are many places to fixup and having
the assert on by default would make the SVE upstreaming effort
difficult.
Reviewers: sdesmalen, efriedma, ctetreau, huntergr, rengolin
Reviewed By: efriedma
Subscribers: mgorny, kristof.beyls, hiraditya, danielkiss, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D76376
2020-03-18 16:51:45 +00:00
option ( LLVM_ENABLE_STRICT_FIXED_SIZE_VECTORS
2020-04-23 09:52:49 -07:00
" E n a b l e a s s e r t i o n s t h a t t y p e i s n o t s c a l a b l e i n i m p l i c i t c o n v e r s i o n f r o m T y p e S i z e t o u i n t 6 4 _ t a n d c a l l s t o g e t N u m E l e m e n t s " O F F )
2020-03-13 09:13:34 +00:00
2016-03-28 18:19:32 +00:00
set ( LLVM_ABI_BREAKING_CHECKS "WITH_ASSERTS" CACHE STRING
" E n a b l e a b i - b r e a k i n g c h e c k s . C a n b e W I T H _ A S S E R T S , F O R C E _ O N o r F O R C E _ O F F . " )
Bump minimum toolchain version
Summary:
The RFC on moving past C++11 got good traction:
http://lists.llvm.org/pipermail/llvm-dev/2019-January/129452.html
This patch therefore bumps the toolchain versions according to our policy:
llvm.org/docs/DeveloperPolicy.html#toolchain
Subscribers: mgorny, jkorous, dexonsmith, llvm-commits, mehdi_amini, jyknight, rsmith, chandlerc, smeenai, hans, reames, lattner, lhames, erichkeane
Differential Revision: https://reviews.llvm.org/D57264
llvm-svn: 353374
2019-02-07 05:20:00 +00:00
option ( LLVM_FORCE_USE_OLD_TOOLCHAIN
2016-03-28 18:19:32 +00:00
" S e t t o O N t o f o r c e u s i n g a n o l d , u n s u p p o r t e d h o s t t o o l c h a i n . " O F F )
2020-05-26 06:23:57 -04:00
set ( LLVM_LOCAL_RPATH "" CACHE FILEPATH
" I f s e t , a n a b s o l u t e p a t h a d d e d a s r p a t h o n b i n a r i e s t h a t d o n o t a l r e a d y c o n t a i n a n e x e c u t a b l e - r e l a t i v e r p a t h . " )
Bump minimum toolchain version
Summary:
The RFC on moving past C++11 got good traction:
http://lists.llvm.org/pipermail/llvm-dev/2019-January/129452.html
This patch therefore bumps the toolchain versions according to our policy:
llvm.org/docs/DeveloperPolicy.html#toolchain
Subscribers: mgorny, jkorous, dexonsmith, llvm-commits, mehdi_amini, jyknight, rsmith, chandlerc, smeenai, hans, reames, lattner, lhames, erichkeane
Differential Revision: https://reviews.llvm.org/D57264
llvm-svn: 353374
2019-02-07 05:20:00 +00:00
option ( LLVM_TEMPORARILY_ALLOW_OLD_TOOLCHAIN
" S e t t o O N t o o n l y w a r n w h e n u s i n g a t o o l c h a i n w h i c h i s a b o u t t o b e d e p r e c a t e d , i n s t e a d o f e m i t t i n g a n e r r o r . " O F F )
2016-03-28 18:19:32 +00:00
option ( LLVM_USE_INTEL_JITEVENTS
" U s e I n t e l J I T A P I t o i n f o r m Intel ( R ) VTune ( TM ) A m p l i f i e r X E 2 0 1 1 a b o u t J I T c o d e "
O F F )
if ( LLVM_USE_INTEL_JITEVENTS )
# Verify we are on a supported platform
if ( NOT CMAKE_SYSTEM_NAME MATCHES "Windows" AND NOT CMAKE_SYSTEM_NAME MATCHES "Linux" )
message ( FATAL_ERROR
" I n t e l J I T A P I s u p p o r t i s a v a i l a b l e o n L i n u x a n d W i n d o w s o n l y . " )
endif ( )
endif ( LLVM_USE_INTEL_JITEVENTS )
option ( LLVM_USE_OPROFILE
" U s e o p a g e n t J I T i n t e r f a c e t o i n f o r m O P r o f i l e a b o u t J I T c o d e " O F F )
option ( LLVM_EXTERNALIZE_DEBUGINFO
" G e n e r a t e d S Y M f i l e s a n d s t r i p e x e c u t a b l e s a n d libraries ( Darwin Only ) " O F F )
2024-04-05 14:41:20 -07:00
option ( LLVM_ENABLE_EXPORTED_SYMBOLS_IN_EXECUTABLES
" P r e s e r v e e x p o r t e d s y m b o l s i n e x e c u t a b l e s " O N )
2018-11-16 18:10:36 +00:00
set ( LLVM_CODESIGNING_IDENTITY "" CACHE STRING
" S i g n e x e c u t a b l e s a n d d y l i b s w i t h t h e g i v e n i d e n t i t y o r s k i p i f empty ( Darwin Only ) " )
2018-07-10 17:32:48 +00:00
2016-03-28 18:19:32 +00:00
# If enabled, verify we are on a platform that supports oprofile.
if ( LLVM_USE_OPROFILE )
if ( NOT CMAKE_SYSTEM_NAME MATCHES "Linux" )
message ( FATAL_ERROR "OProfile support is available on Linux only." )
endif ( NOT CMAKE_SYSTEM_NAME MATCHES "Linux" )
endif ( LLVM_USE_OPROFILE )
Add PerfJITEventListener for perf profiling support.
This new JIT event listener supports generating profiling data for
the linux 'perf' profiling tool, allowing it to generate function and
instruction level profiles.
Currently this functionality is not enabled by default, but must be
enabled with LLVM_USE_PERF=yes. Given that the listener has no
dependencies, it might be sensible to enable by default once the
initial issues have been shaken out.
I followed existing precedent in registering the listener by default
in lli. Should there be a decision to enable this by default on linux,
that should probably be changed.
Please note that until https://reviews.llvm.org/D47343 is resolved,
using this functionality with mcjit rather than orcjit will not
reliably work.
Disregarding the previous comment, here's an example:
$ cat /tmp/expensive_loop.c
bool stupid_isprime(uint64_t num)
{
if (num == 2)
return true;
if (num < 1 || num % 2 == 0)
return false;
for(uint64_t i = 3; i < num / 2; i+= 2) {
if (num % i == 0)
return false;
}
return true;
}
int main(int argc, char **argv)
{
int numprimes = 0;
for (uint64_t num = argc; num < 100000; num++)
{
if (stupid_isprime(num))
numprimes++;
}
return numprimes;
}
$ clang -ggdb -S -c -emit-llvm /tmp/expensive_loop.c -o
/tmp/expensive_loop.ll
$ perf record -o perf.data -g -k 1 ./bin/lli -jit-kind=mcjit /tmp/expensive_loop.ll 1
$ perf inject --jit -i perf.data -o perf.jit.data
$ perf report -i perf.jit.data
- 92.59% lli jitted-5881-2.so [.] stupid_isprime
stupid_isprime
main
llvm::MCJIT::runFunction
llvm::ExecutionEngine::runFunctionAsMain
main
__libc_start_main
0x4bf6258d4c544155
+ 0.85% lli ld-2.27.so [.] do_lookup_x
And line-level annotations also work:
│ for(uint64_t i = 3; i < num / 2; i+= 2) {
│1 30: movq $0x3,-0x18(%rbp)
0.03 │1 38: mov -0x18(%rbp),%rax
0.03 │ mov -0x10(%rbp),%rcx
│ shr $0x1,%rcx
3.63 │ ┌──cmp %rcx,%rax
│ ├──jae 6f
│ │ if (num % i == 0)
0.03 │ │ mov -0x10(%rbp),%rax
│ │ xor %edx,%edx
89.00 │ │ divq -0x18(%rbp)
│ │ cmp $0x0,%rdx
0.22 │ │↓ jne 5f
│ │ return false;
│ │ movb $0x0,-0x1(%rbp)
│ │↓ jmp 73
│ │ }
3.22 │1 5f:│↓ jmp 61
│ │ for(uint64_t i = 3; i < num / 2; i+= 2) {
Subscribers: mgorny, llvm-commits
Differential Revision: https://reviews.llvm.org/D44892
llvm-svn: 337789
2018-07-24 00:54:06 +00:00
option ( LLVM_USE_PERF
" U s e p e r f J I T i n t e r f a c e t o i n f o r m p e r f a b o u t J I T c o d e " O F F )
# If enabled, verify we are on a platform that supports perf.
if ( LLVM_USE_PERF )
if ( NOT CMAKE_SYSTEM_NAME MATCHES "Linux" )
message ( FATAL_ERROR "perf support is available on Linux only." )
endif ( NOT CMAKE_SYSTEM_NAME MATCHES "Linux" )
endif ( LLVM_USE_PERF )
2016-03-28 18:19:32 +00:00
set ( LLVM_USE_SANITIZER "" CACHE STRING
" D e f i n e t h e s a n i t i z e r u s e d t o b u i l d b i n a r i e s a n d t e s t s . " )
2018-05-17 16:55:29 +00:00
option ( LLVM_OPTIMIZE_SANITIZED_BUILDS "Pass -O1 on debug sanitizer builds" ON )
2020-10-14 19:09:50 -07:00
set ( LLVM_UBSAN_FLAGS
" - f s a n i t i z e = u n d e f i n e d - f n o - s a n i t i z e = v p t r , f u n c t i o n - f n o - s a n i t i z e - r e c o v e r = a l l "
C A C H E S T R I N G
" C o m p i l e f l a g s s e t t o e n a b l e U B S a n . O n l y u s e d i f L L V M _ U S E _ S A N I T I Z E R c o n t a i n s ' U n d e f i n e d ' . " )
2017-10-12 21:58:41 +00:00
set ( LLVM_LIB_FUZZING_ENGINE "" CACHE PATH
" P a t h t o f u z z i n g l i b r a r y f o r l i n k i n g w i t h f u z z t a r g e t s " )
2016-03-28 18:19:32 +00:00
option ( LLVM_USE_SPLIT_DWARF
2021-08-30 12:32:20 +03:00
" U s e - g s p l i t - d w a r f w h e n c o m p i l i n g l l v m a n d - - g d b - i n d e x w h e n l i n k i n g . " O F F )
2016-03-28 18:19:32 +00:00
# Define an option controlling whether we should build for 32-bit on 64-bit
# platforms, where supported.
2020-02-20 15:39:16 -05:00
if ( CMAKE_SIZEOF_VOID_P EQUAL 8 AND NOT ( WIN32 OR ${ CMAKE_SYSTEM_NAME } MATCHES "AIX" ) )
2016-03-28 18:19:32 +00:00
# TODO: support other platforms and toolchains.
option ( LLVM_BUILD_32_BITS "Build 32 bits executables and libraries." OFF )
endif ( )
# Define the default arguments to use with 'lit', and an option for the user to
# override.
set ( LIT_ARGS_DEFAULT "-sv" )
if ( MSVC_IDE OR XCODE )
set ( LIT_ARGS_DEFAULT "${LIT_ARGS_DEFAULT} --no-progress-bar" )
endif ( )
2023-07-26 16:46:09 +05:30
if ( LLVM_INDIVIDUAL_TEST_COVERAGE )
set ( LIT_ARGS_DEFAULT "${LIT_ARGS_DEFAULT} --per-test-coverage" )
endif ( )
2016-03-28 18:19:32 +00:00
set ( LLVM_LIT_ARGS "${LIT_ARGS_DEFAULT}" CACHE STRING "Default options for lit" )
# On Win32 hosts, provide an option to specify the path to the GnuWin32 tools.
if ( WIN32 AND NOT CYGWIN )
set ( LLVM_LIT_TOOLS_DIR "" CACHE PATH "Path to GnuWin32 tools" )
endif ( )
2022-08-02 14:53:36 +03:00
set ( LLVM_NATIVE_TOOL_DIR "" CACHE PATH "Path to a directory containing prebuilt matching native tools (such as llvm-tblgen)" )
2016-03-28 18:19:32 +00:00
[Support] Vendor rpmalloc in-tree and use it for the Windows 64-bit release (#91862)
### Context
We have a longstanding performance issue on Windows, where to this day,
the default heap allocator is still lockfull. With the number of cores
increasing, building and using LLVM with the default Windows heap
allocator is sub-optimal. Notably, the ThinLTO link times with LLD are
extremely long, and increase proportionally with the number of cores in
the machine.
In
https://github.com/llvm/llvm-project/commit/a6a37a2fcd2a8048a75bd0d8280497ed89d73224,
I introduced the ability build LLVM with several popular lock-free
allocators. Downstream users however have to build their own toolchain
with this option, and building an optimal toolchain is a bit tedious and
long. Additionally, LLVM is now integrated into Visual Studio, which
AFAIK re-distributes the vanilla LLVM binaries/installer. The point
being that many users are impacted and might not be aware of this
problem, or are unable to build a more optimal version of the toolchain.
The symptom before this PR is that most of the CPU time goes to the
kernel (darker blue) when linking with ThinLTO:

With this PR, most time is spent in user space (light blue):

On higher core count machines, before this PR, the CPU usage becomes
pretty much flat because of contention:
<img width="549" alt="VM_176_windows_heap"
src="https://github.com/llvm/llvm-project/assets/37383324/f27d5800-ee02-496d-a4e7-88177e0727f0">
With this PR, similarily most CPU time is now used:
<img width="549" alt="VM_176_with_rpmalloc"
src="https://github.com/llvm/llvm-project/assets/37383324/7d4785dd-94a7-4f06-9b16-aaa4e2e505c8">
### Changes in this PR
The avenue I've taken here is to vendor/re-licence rpmalloc in-tree, and
use it when building the Windows 64-bit release. Given the permissive
rpmalloc licence, prior discussions with the LLVM foundation and
@lattner suggested this vendoring. Rpmalloc's author (@mjansson) kindly
agreed to ~~donate~~ re-licence the rpmalloc code in LLVM (please do
correct me if I misinterpreted our past communications).
I've chosen rpmalloc because it's small and gives the best value
overall. The source code is only 4 .c files. Rpmalloc is statically
replacing the weak CRT alloc symbols at link time, and has no dynamic
patching like mimalloc. As an alternative, there were several
unsuccessfull attempts made by Russell Gallop to use SCUDO in the past,
please see thread in https://reviews.llvm.org/D86694. If later someone
comes up with a PR of similar performance that uses SCUDO, we could then
delete this vendored rpmalloc folder.
I've added a new cmake flag `LLVM_ENABLE_RPMALLOC` which essentialy sets
`LLVM_INTEGRATED_CRT_ALLOC` to the in-tree rpmalloc source.
### Performance
The most obvious test is profling a ThinLTO linking step with LLD. I've
used a Clang compilation as a testbed, ie.
```
set OPTS=/GS- /D_ITERATOR_DEBUG_LEVEL=0 -Xclang -O3 -fstrict-aliasing -march=native -flto=thin -fwhole-program-vtables -fuse-ld=lld
cmake -G Ninja %ROOT%/llvm -DCMAKE_BUILD_TYPE=Release -DLLVM_ENABLE_ASSERTIONS=TRUE -DLLVM_ENABLE_PROJECTS="clang" -DLLVM_ENABLE_PDB=ON -DLLVM_OPTIMIZED_TABLEGEN=ON -DCMAKE_C_COMPILER=clang-cl.exe -DCMAKE_CXX_COMPILER=clang-cl.exe -DCMAKE_LINKER=lld-link.exe -DLLVM_ENABLE_LLD=ON -DCMAKE_CXX_FLAGS="%OPTS%" -DCMAKE_C_FLAGS="%OPTS%" -DLLVM_ENABLE_LTO=THIN
```
I've profiled the linking step with no LTO cache, with Powershell, such
as:
```
Measure-Command { lld-link /nologo @CMakeFiles\clang.rsp /out:bin\clang.exe /implib:lib\clang.lib /pdb:bin\clang.pdb /version:0.0 /machine:x64 /STACK:10000000 /DEBUG /OPT:REF /OPT:ICF /INCREMENTAL:NO /subsystem:console /MANIFEST:EMBED,ID=1 }`
```
Timings:
| Machine | Allocator | Time to link |
|--------|--------|--------|
| 16c/32t AMD Ryzen 9 5950X | Windows Heap | 10 min 38 sec |
| | **Rpmalloc** | **4 min 11 sec** |
| 32c/64t AMD Ryzen Threadripper PRO 3975WX | Windows Heap | 23 min 29
sec |
| | **Rpmalloc** | **2 min 11 sec** |
| | **Rpmalloc + /threads:64** | **1 min 50 sec** |
| 176 vCPU (2 socket) Intel Xeon Platinium 8481C (fixed clock 2.7 GHz) |
Windows Heap | 43 min 40 sec |
| | **Rpmalloc** | **1 min 45 sec** |
This also improves the overall performance when building with clang-cl.
I've profiled a regular compilation of clang itself, ie:
```
set OPTS=/GS- /D_ITERATOR_DEBUG_LEVEL=0 /arch:AVX -fuse-ld=lld
cmake -G Ninja %ROOT%/llvm -DCMAKE_BUILD_TYPE=Release -DLLVM_ENABLE_ASSERTIONS=TRUE -DLLVM_ENABLE_PROJECTS="clang;lld" -DLLVM_ENABLE_PDB=ON -DLLVM_OPTIMIZED_TABLEGEN=ON -DCMAKE_C_COMPILER=clang-cl.exe -DCMAKE_CXX_COMPILER=clang-cl.exe -DCMAKE_LINKER=lld-link.exe -DLLVM_ENABLE_LLD=ON -DCMAKE_CXX_FLAGS="%OPTS%" -DCMAKE_C_FLAGS="%OPTS%"
```
This saves approx. 30 sec when building on the Threadripper PRO 3975WX:
```
(default Windows Heap)
C:\src\git\llvm-project>hyperfine -r 5 -p "make_llvm.bat stage1_test2" "ninja clang -C stage1_test2"
Benchmark 1: ninja clang -C stage1_test2
Time (mean ± σ): 392.716 s ± 3.830 s [User: 17734.025 s, System: 1078.674 s]
Range (min … max): 390.127 s … 399.449 s 5 runs
(rpmalloc)
C:\src\git\llvm-project>hyperfine -r 5 -p "make_llvm.bat stage1_test2" "ninja clang -C stage1_test2"
Benchmark 1: ninja clang -C stage1_test2
Time (mean ± σ): 360.824 s ± 1.162 s [User: 15148.637 s, System: 905.175 s]
Range (min … max): 359.208 s … 362.288 s 5 runs
```
2024-06-20 10:54:02 -04:00
set ( LLVM_ENABLE_RPMALLOC "" CACHE BOOL "Replace the CRT allocator with rpmalloc." )
if ( LLVM_ENABLE_RPMALLOC )
if ( NOT ( CMAKE_SYSTEM_NAME MATCHES "Windows|Linux" ) )
message ( FATAL_ERROR "LLVM_ENABLE_RPMALLOC is only supported on Windows and Linux." )
endif ( )
if ( LLVM_USE_SANITIZER )
message ( FATAL_ERROR "LLVM_ENABLE_RPMALLOC cannot be used along with LLVM_USE_SANITIZER!" )
endif ( )
if ( WIN32 )
if ( CMAKE_CONFIGURATION_TYPES )
foreach ( BUILD_MODE ${ CMAKE_CONFIGURATION_TYPES } )
string ( TOUPPER "${BUILD_MODE}" uppercase_BUILD_MODE )
if ( uppercase_BUILD_MODE STREQUAL "DEBUG" )
message ( WARNING "The Debug target isn't supported along with LLVM_ENABLE_RPMALLOC!" )
endif ( )
endforeach ( )
else ( )
if ( CMAKE_BUILD_TYPE AND uppercase_CMAKE_BUILD_TYPE STREQUAL "DEBUG" )
message ( FATAL_ERROR "The Debug target isn't supported along with LLVM_ENABLE_RPMALLOC!" )
endif ( )
endif ( )
endif ( )
# Override the C runtime allocator with the in-tree rpmalloc
set ( LLVM_INTEGRATED_CRT_ALLOC "${CMAKE_CURRENT_SOURCE_DIR}/lib/Support" )
set ( CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded" )
endif ( )
set ( LLVM_INTEGRATED_CRT_ALLOC "${LLVM_INTEGRATED_CRT_ALLOC}" CACHE PATH "Replace the Windows CRT allocator with any of {rpmalloc|mimalloc|snmalloc}. Only works with CMAKE_MSVC_RUNTIME_LIBRARY=MultiThreaded." )
2020-09-15 19:18:24 -04:00
if ( LLVM_INTEGRATED_CRT_ALLOC )
if ( NOT WIN32 )
message ( FATAL_ERROR "LLVM_INTEGRATED_CRT_ALLOC is only supported on Windows." )
endif ( )
if ( LLVM_USE_SANITIZER )
message ( FATAL_ERROR "LLVM_INTEGRATED_CRT_ALLOC cannot be used along with LLVM_USE_SANITIZER!" )
endif ( )
if ( CMAKE_BUILD_TYPE AND uppercase_CMAKE_BUILD_TYPE STREQUAL "DEBUG" )
message ( FATAL_ERROR "The Debug target isn't supported along with LLVM_INTEGRATED_CRT_ALLOC!" )
endif ( )
endif ( )
2016-03-28 18:19:32 +00:00
# Define options to control the inclusion and default build behavior for
# components which may not strictly be necessary (tools, examples, and tests).
#
# This is primarily to support building smaller or faster project files.
option ( LLVM_INCLUDE_TOOLS "Generate build targets for the LLVM tools." ON )
option ( LLVM_BUILD_TOOLS
" B u i l d t h e L L V M t o o l s . I f O F F , j u s t g e n e r a t e b u i l d t a r g e t s . " O N )
option ( LLVM_INCLUDE_UTILS "Generate build targets for the LLVM utils." ON )
2016-07-10 02:43:47 +00:00
option ( LLVM_BUILD_UTILS
" B u i l d L L V M u t i l i t y b i n a r i e s . I f O F F , j u s t g e n e r a t e b u i l d t a r g e t s . " O N )
2016-03-28 18:19:32 +00:00
2017-03-23 22:40:10 +00:00
option ( LLVM_INCLUDE_RUNTIMES "Generate build targets for the LLVM runtimes." ON )
option ( LLVM_BUILD_RUNTIMES
" B u i l d t h e L L V M r u n t i m e s . I f O F F , j u s t g e n e r a t e b u i l d t a r g e t s . " O N )
2016-03-28 18:19:32 +00:00
option ( LLVM_BUILD_RUNTIME
" B u i l d t h e L L V M r u n t i m e l i b r a r i e s . " O N )
option ( LLVM_BUILD_EXAMPLES
" B u i l d t h e L L V M e x a m p l e p r o g r a m s . I f O F F , j u s t g e n e r a t e b u i l d t a r g e t s . " O F F )
option ( LLVM_INCLUDE_EXAMPLES "Generate build targets for the LLVM examples" ON )
option ( LLVM_BUILD_TESTS
" B u i l d L L V M u n i t t e s t s . I f O F F , j u s t g e n e r a t e b u i l d t a r g e t s . " O F F )
option ( LLVM_INCLUDE_TESTS "Generate build targets for the LLVM unit tests." ON )
2023-03-10 17:22:14 -08:00
option ( LLVM_INSTALL_GTEST
" I n s t a l l t h e l l v m g t e s t l i b r a r y . T h i s s h o u l d b e o n i f y o u w a n t t o d o
s t a n d - a l o n e b u i l d s o f t h e o t h e r p r o j e c t s a n d r u n t h e i r u n i t t e s t s . " O F F )
Pull google/benchmark library to the LLVM tree
This patch pulls google/benchmark v1.4.1 into the LLVM tree so that any
project could use it for benchmark generation. A dummy benchmark is
added to `llvm/benchmarks/DummyYAML.cpp` to validate the correctness of
the build process.
The current version does not utilize LLVM LNT and LLVM CMake
infrastructure, but that might be sufficient for most users. Two
introduced CMake variables:
* `LLVM_INCLUDE_BENCHMARKS` (`ON` by default) generates benchmark
targets
* `LLVM_BUILD_BENCHMARKS` (`OFF` by default) adds generated
benchmark targets to the list of default LLVM targets (i.e. if `ON`
benchmarks will be built upon standard build invocation, e.g. `ninja` or
`make` with no specific targets)
List of modifications:
* `BENCHMARK_ENABLE_TESTING` is disabled
* `BENCHMARK_ENABLE_EXCEPTIONS` is disabled
* `BENCHMARK_ENABLE_INSTALL` is disabled
* `BENCHMARK_ENABLE_GTEST_TESTS` is disabled
* `BENCHMARK_DOWNLOAD_DEPENDENCIES` is disabled
Original discussion can be found here:
http://lists.llvm.org/pipermail/llvm-dev/2018-August/125023.html
Reviewed by: dberris, lebedev.ri
Subscribers: ilya-biryukov, ioeric, EricWF, lebedev.ri, srhines,
dschuff, mgorny, krytarowski, fedor.sergeev, mgrang, jfb, llvm-commits
Differential Revision: https://reviews.llvm.org/D50894
llvm-svn: 340809
2018-08-28 09:42:41 +00:00
option ( LLVM_BUILD_BENCHMARKS " Add LLVM benchmark targets to the list of default
t a r g e t s . I f O F F , b e n c h m a r k s s t i l l c o u l d b e b u i l t u s i n g B e n c h m a r k s t a r g e t . " O F F )
2018-09-07 21:47:00 +00:00
option ( LLVM_INCLUDE_BENCHMARKS "Generate benchmark targets. If OFF, benchmarks can't be built." ON )
Pull google/benchmark library to the LLVM tree
This patch pulls google/benchmark v1.4.1 into the LLVM tree so that any
project could use it for benchmark generation. A dummy benchmark is
added to `llvm/benchmarks/DummyYAML.cpp` to validate the correctness of
the build process.
The current version does not utilize LLVM LNT and LLVM CMake
infrastructure, but that might be sufficient for most users. Two
introduced CMake variables:
* `LLVM_INCLUDE_BENCHMARKS` (`ON` by default) generates benchmark
targets
* `LLVM_BUILD_BENCHMARKS` (`OFF` by default) adds generated
benchmark targets to the list of default LLVM targets (i.e. if `ON`
benchmarks will be built upon standard build invocation, e.g. `ninja` or
`make` with no specific targets)
List of modifications:
* `BENCHMARK_ENABLE_TESTING` is disabled
* `BENCHMARK_ENABLE_EXCEPTIONS` is disabled
* `BENCHMARK_ENABLE_INSTALL` is disabled
* `BENCHMARK_ENABLE_GTEST_TESTS` is disabled
* `BENCHMARK_DOWNLOAD_DEPENDENCIES` is disabled
Original discussion can be found here:
http://lists.llvm.org/pipermail/llvm-dev/2018-August/125023.html
Reviewed by: dberris, lebedev.ri
Subscribers: ilya-biryukov, ioeric, EricWF, lebedev.ri, srhines,
dschuff, mgorny, krytarowski, fedor.sergeev, mgrang, jfb, llvm-commits
Differential Revision: https://reviews.llvm.org/D50894
llvm-svn: 340809
2018-08-28 09:42:41 +00:00
2016-03-28 18:19:32 +00:00
option ( LLVM_BUILD_DOCS "Build the llvm documentation." OFF )
option ( LLVM_INCLUDE_DOCS "Generate build targets for llvm documentation." ON )
option ( LLVM_ENABLE_DOXYGEN "Use doxygen to generate llvm API documentation." OFF )
option ( LLVM_ENABLE_SPHINX "Use Sphinx to generate llvm documentation." OFF )
2016-08-23 18:07:16 +00:00
option ( LLVM_ENABLE_OCAMLDOC "Build OCaml bindings documentation." ON )
2018-05-20 08:37:54 +00:00
option ( LLVM_ENABLE_BINDINGS "Build bindings." ON )
2025-02-26 13:01:53 -05:00
option ( LLVM_ENABLE_TELEMETRY "Enable the telemetry library. If set to OFF, library cannot be enabled after build (eg., at runtime)" ON )
2016-03-28 18:19:32 +00:00
2021-12-11 01:36:24 +00:00
set ( LLVM_INSTALL_DOXYGEN_HTML_DIR "${CMAKE_INSTALL_DOCDIR}/llvm/doxygen-html"
2016-09-27 19:52:29 +00:00
C A C H E S T R I N G " D o x y g e n - g e n e r a t e d H T M L d o c u m e n t a t i o n i n s t a l l d i r e c t o r y " )
2021-12-11 01:36:24 +00:00
set ( LLVM_INSTALL_OCAMLDOC_HTML_DIR "${CMAKE_INSTALL_DOCDIR}/llvm/ocaml-html"
2016-09-27 19:52:29 +00:00
C A C H E S T R I N G " O C a m l d o c - g e n e r a t e d H T M L d o c u m e n t a t i o n i n s t a l l d i r e c t o r y " )
2016-03-28 18:19:32 +00:00
option ( LLVM_BUILD_EXTERNAL_COMPILER_RT
" B u i l d c o m p i l e r - r t a s a n e x t e r n a l p r o j e c t . " O F F )
2017-04-19 00:03:36 +00:00
option ( LLVM_VERSION_PRINTER_SHOW_HOST_TARGET_INFO
" S h o w t a r g e t a n d h o s t i n f o w h e n t o o l s a r e i n v o k e d w i t h - - v e r s i o n . " O N )
2024-04-05 13:01:09 -04:00
option ( LLVM_VERSION_PRINTER_SHOW_BUILD_CONFIG
" S h o w t h e o p t i o n a l b u i l d c o n f i g f l a g s w h e n t o o l s a r e i n v o k e d w i t h - - v e r s i o n . " O N )
2016-03-28 18:19:32 +00:00
# You can configure which libraries from LLVM you want to include in the
# shared library by setting LLVM_DYLIB_COMPONENTS to a semi-colon delimited
# list of LLVM components. All component names handled by llvm-config are valid.
if ( NOT DEFINED LLVM_DYLIB_COMPONENTS )
set ( LLVM_DYLIB_COMPONENTS "all" CACHE STRING
" S e m i c o l o n - s e p a r a t e d l i s t o f c o m p o n e n t s t o i n c l u d e i n l i b L L V M , o r \ " a l l \ " . " )
endif ( )
2019-11-08 10:05:37 -08:00
[RFC] Build LLVM-C.dll on MSVC that exports only the C API
Summary:
Hello!
This commit adds a LLVM-C target that is always built on MSVC. A big fat warning, this is my first cmake code ever so there is a fair bit of I-have-no-idea-what-I'm-doing going on here. Which is also why I placed it outside of llvm-shlib as I was afraid of breaking things of other people. Secondly llvm-shlib builds a LLVM.so which exports all symbols and then does a thin library that points to it, but on Windows we do not build a LLVM.dll so that would have complicated the code more.
The patch includes a python script that calls dumpbin.exe to get all of the symbols from the built libraries. It then grabs all the symbols starting with LLVM and generates the export file from those. The export file is then used to create the library just like the LLVM-C that is built on darwin.
Improvements that I need help with, to follow up this review.
- Get cmake to make sure that dumpbin.exe is on the path and wire the full path to the script.
- Use LLVM-C.dll when building llvm-c-test so we can verify that the symbols are exported.
- Bundle the LLVM-C.dll with the windows installer.
Why do this? I'm building a language frontend which is self-hosting, and on windows because of various tooling issues we have a problem of consuming the LLVM*.lib directly on windows. Me and the users of my projects using LLVM would be greatly helped by having LLVM-C.dll built and shipped by the Windows installer. Not only does LLVM takes forever to build, you have to run a extra python script in order to get the final DLL.
Any comments, thoughts or help is greatly appreciated.
Cheers, Jakob.
Patch by: Wallbraker (Jakob Bornecrantz)
Reviewers: compnerd, beanz, hans, smeenai
Reviewed By: beanz
Subscribers: xbolva00, bhelyer, Memnarch, rnk, fedor.sergeev, chapuni, smeenai, john.brawn, deadalnix, llvm-commits, mgorny
Differential Revision: https://reviews.llvm.org/D35077
llvm-svn: 339151
2018-08-07 15:54:50 +00:00
if ( MSVC )
2019-03-19 09:14:09 +00:00
option ( LLVM_BUILD_LLVM_C_DYLIB "Build LLVM-C.dll (Windows only)" ON )
2019-11-14 09:18:44 -08:00
if ( BUILD_SHARED_LIBS )
message ( FATAL_ERROR "BUILD_SHARED_LIBS options is not supported on Windows." )
endif ( )
2024-11-16 23:51:57 +08:00
else ( )
[RFC] Build LLVM-C.dll on MSVC that exports only the C API
Summary:
Hello!
This commit adds a LLVM-C target that is always built on MSVC. A big fat warning, this is my first cmake code ever so there is a fair bit of I-have-no-idea-what-I'm-doing going on here. Which is also why I placed it outside of llvm-shlib as I was afraid of breaking things of other people. Secondly llvm-shlib builds a LLVM.so which exports all symbols and then does a thin library that points to it, but on Windows we do not build a LLVM.dll so that would have complicated the code more.
The patch includes a python script that calls dumpbin.exe to get all of the symbols from the built libraries. It then grabs all the symbols starting with LLVM and generates the export file from those. The export file is then used to create the library just like the LLVM-C that is built on darwin.
Improvements that I need help with, to follow up this review.
- Get cmake to make sure that dumpbin.exe is on the path and wire the full path to the script.
- Use LLVM-C.dll when building llvm-c-test so we can verify that the symbols are exported.
- Bundle the LLVM-C.dll with the windows installer.
Why do this? I'm building a language frontend which is self-hosting, and on windows because of various tooling issues we have a problem of consuming the LLVM*.lib directly on windows. Me and the users of my projects using LLVM would be greatly helped by having LLVM-C.dll built and shipped by the Windows installer. Not only does LLVM takes forever to build, you have to run a extra python script in order to get the final DLL.
Any comments, thoughts or help is greatly appreciated.
Cheers, Jakob.
Patch by: Wallbraker (Jakob Bornecrantz)
Reviewers: compnerd, beanz, hans, smeenai
Reviewed By: beanz
Subscribers: xbolva00, bhelyer, Memnarch, rnk, fedor.sergeev, chapuni, smeenai, john.brawn, deadalnix, llvm-commits, mgorny
Differential Revision: https://reviews.llvm.org/D35077
llvm-svn: 339151
2018-08-07 15:54:50 +00:00
option ( LLVM_BUILD_LLVM_C_DYLIB "Build libllvm-c re-export library (Darwin only)" OFF )
2024-09-06 18:51:44 +01:00
endif ( )
# Used to test building the llvm shared library with explicit symbol visibility on
# Windows and Linux. For ELF platforms default symbols visibility is set to hidden.
set ( LLVM_BUILD_LLVM_DYLIB_VIS FALSE CACHE BOOL "" )
mark_as_advanced ( LLVM_BUILD_LLVM_DYLIB_VIS )
set ( CAN_BUILD_LLVM_DYLIB OFF )
if ( NOT MSVC OR LLVM_BUILD_LLVM_DYLIB_VIS )
set ( CAN_BUILD_LLVM_DYLIB ON )
endif ( )
cmake_dependent_option ( LLVM_LINK_LLVM_DYLIB "Link tools against the libllvm dynamic library" OFF
" C A N _ B U I L D _ L L V M _ D Y L I B " O F F )
set ( LLVM_BUILD_LLVM_DYLIB_default OFF )
if ( LLVM_LINK_LLVM_DYLIB OR LLVM_BUILD_LLVM_C_DYLIB )
set ( LLVM_BUILD_LLVM_DYLIB_default ON )
endif ( )
cmake_dependent_option ( LLVM_BUILD_LLVM_DYLIB "Build libllvm dynamic library" ${ LLVM_BUILD_LLVM_DYLIB_default }
" C A N _ B U I L D _ L L V M _ D Y L I B " O F F )
cmake_dependent_option ( LLVM_DYLIB_EXPORT_INLINES " Force inline members of classes to be DLL exported when
b u i l d i n g w i t h c l a n g - c l s o t h e l i b l l v m D L L i s c o m p a t i b l e w i t h MSVC "
O F F
" MSVC ; L L V M _ B U I L D _ L L V M _ D Y L I B _ V I S " O F F )
if ( LLVM_BUILD_LLVM_DYLIB_VIS )
set ( LLVM_BUILD_LLVM_DYLIB ON )
[RFC] Build LLVM-C.dll on MSVC that exports only the C API
Summary:
Hello!
This commit adds a LLVM-C target that is always built on MSVC. A big fat warning, this is my first cmake code ever so there is a fair bit of I-have-no-idea-what-I'm-doing going on here. Which is also why I placed it outside of llvm-shlib as I was afraid of breaking things of other people. Secondly llvm-shlib builds a LLVM.so which exports all symbols and then does a thin library that points to it, but on Windows we do not build a LLVM.dll so that would have complicated the code more.
The patch includes a python script that calls dumpbin.exe to get all of the symbols from the built libraries. It then grabs all the symbols starting with LLVM and generates the export file from those. The export file is then used to create the library just like the LLVM-C that is built on darwin.
Improvements that I need help with, to follow up this review.
- Get cmake to make sure that dumpbin.exe is on the path and wire the full path to the script.
- Use LLVM-C.dll when building llvm-c-test so we can verify that the symbols are exported.
- Bundle the LLVM-C.dll with the windows installer.
Why do this? I'm building a language frontend which is self-hosting, and on windows because of various tooling issues we have a problem of consuming the LLVM*.lib directly on windows. Me and the users of my projects using LLVM would be greatly helped by having LLVM-C.dll built and shipped by the Windows installer. Not only does LLVM takes forever to build, you have to run a extra python script in order to get the final DLL.
Any comments, thoughts or help is greatly appreciated.
Cheers, Jakob.
Patch by: Wallbraker (Jakob Bornecrantz)
Reviewers: compnerd, beanz, hans, smeenai
Reviewed By: beanz
Subscribers: xbolva00, bhelyer, Memnarch, rnk, fedor.sergeev, chapuni, smeenai, john.brawn, deadalnix, llvm-commits, mgorny
Differential Revision: https://reviews.llvm.org/D35077
llvm-svn: 339151
2018-08-07 15:54:50 +00:00
endif ( )
2016-03-28 18:19:32 +00:00
2019-11-13 20:29:19 -08:00
if ( LLVM_LINK_LLVM_DYLIB AND BUILD_SHARED_LIBS )
message ( FATAL_ERROR "Cannot enable BUILD_SHARED_LIBS with LLVM_LINK_LLVM_DYLIB. We recommend disabling BUILD_SHARED_LIBS." )
endif ( )
2016-03-28 18:19:32 +00:00
option ( LLVM_OPTIMIZED_TABLEGEN "Force TableGen to be built with optimization" OFF )
2016-11-28 17:12:09 +00:00
if ( CMAKE_CROSSCOMPILING OR ( LLVM_OPTIMIZED_TABLEGEN AND ( LLVM_ENABLE_ASSERTIONS OR CMAKE_CONFIGURATION_TYPES ) ) )
2016-03-28 18:19:32 +00:00
set ( LLVM_USE_HOST_TOOLS ON )
endif ( )
2021-11-17 15:43:35 -06:00
option ( LLVM_OMIT_DAGISEL_COMMENTS "Do not add comments to DAG ISel" ON )
if ( CMAKE_BUILD_TYPE AND uppercase_CMAKE_BUILD_TYPE MATCHES "^(RELWITHDEBINFO|DEBUG)$" )
set ( LLVM_OMIT_DAGISEL_COMMENTS OFF )
endif ( )
2019-07-30 22:49:11 +00:00
if ( MSVC_IDE )
2016-03-28 18:19:32 +00:00
option ( LLVM_ADD_NATIVE_VISUALIZERS_TO_SOLUTION "Configure project to use Visual Studio native visualizers" TRUE )
endif ( )
2023-07-26 16:46:09 +05:30
if ( NOT LLVM_INDIVIDUAL_TEST_COVERAGE )
if ( LLVM_BUILD_INSTRUMENTED OR LLVM_BUILD_INSTRUMENTED_COVERAGE OR LLVM_ENABLE_IR_PGO )
if ( NOT LLVM_PROFILE_MERGE_POOL_SIZE )
# A pool size of 1-2 is probably sufficient on an SSD. 3-4 should be fine
# for spinning disks. Anything higher may only help on slower mediums.
set ( LLVM_PROFILE_MERGE_POOL_SIZE "4" )
2023-07-21 14:56:02 +05:30
endif ( )
2023-07-26 16:46:09 +05:30
if ( NOT LLVM_PROFILE_FILE_PATTERN )
if ( NOT LLVM_PROFILE_DATA_DIR )
file ( TO_NATIVE_PATH "${LLVM_BINARY_DIR}/profiles" LLVM_PROFILE_DATA_DIR )
endif ( )
file ( TO_NATIVE_PATH "${LLVM_PROFILE_DATA_DIR}/%${LLVM_PROFILE_MERGE_POOL_SIZE}m.profraw" LLVM_PROFILE_FILE_PATTERN )
endif ( )
if ( NOT LLVM_CSPROFILE_FILE_PATTERN )
if ( NOT LLVM_CSPROFILE_DATA_DIR )
file ( TO_NATIVE_PATH "${LLVM_BINARY_DIR}/csprofiles" LLVM_CSPROFILE_DATA_DIR )
endif ( )
file ( TO_NATIVE_PATH "${LLVM_CSPROFILE_DATA_DIR}/%${LLVM_PROFILE_MERGE_POOL_SIZE}m.profraw" LLVM_CSPROFILE_FILE_PATTERN )
2019-03-06 19:31:37 +00:00
endif ( )
endif ( )
2016-06-13 23:33:48 +00:00
endif ( )
2016-11-17 11:22:23 +00:00
if ( LLVM_BUILD_STATIC )
set ( CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static" )
2020-08-31 15:11:39 -07:00
# Remove shared library suffixes from use in find_library
foreach ( shared_lib_suffix ${ CMAKE_SHARED_LIBRARY_SUFFIX } ${ CMAKE_IMPORT_LIBRARY_SUFFIX } )
list ( FIND CMAKE_FIND_LIBRARY_SUFFIXES ${ shared_lib_suffix } shared_lib_suffix_idx )
if ( NOT ${ shared_lib_suffix_idx } EQUAL -1 )
list ( REMOVE_AT CMAKE_FIND_LIBRARY_SUFFIXES ${ shared_lib_suffix_idx } )
endif ( )
endforeach ( )
2016-11-17 11:22:23 +00:00
endif ( )
2019-06-02 02:05:01 +00:00
# Use libtool instead of ar if you are both on an Apple host, and targeting Apple.
if ( CMAKE_HOST_APPLE AND APPLE )
include ( UseLibtool )
endif ( )
2017-06-17 03:19:08 +00:00
# Override the default target with an environment variable named by LLVM_TARGET_TRIPLE_ENV.
set ( LLVM_TARGET_TRIPLE_ENV CACHE STRING "The name of environment variable to override default target. Disabled by blank." )
mark_as_advanced ( LLVM_TARGET_TRIPLE_ENV )
2023-02-13 10:31:49 -05:00
if ( CMAKE_SYSTEM_NAME MATCHES "BSD|Linux|OS390" )
2022-06-21 13:13:31 -07:00
set ( LLVM_ENABLE_PER_TARGET_RUNTIME_DIR_default ON )
else ( )
set ( LLVM_ENABLE_PER_TARGET_RUNTIME_DIR_default OFF )
endif ( )
set ( LLVM_ENABLE_PER_TARGET_RUNTIME_DIR ${ LLVM_ENABLE_PER_TARGET_RUNTIME_DIR_default } CACHE BOOL
2018-06-28 03:11:52 +00:00
" E n a b l e p e r - t a r g e t r u n t i m e s d i r e c t o r y " )
2019-09-18 09:43:13 +00:00
set ( LLVM_PROFDATA_FILE "" CACHE FILEPATH
" P r o f i l i n g d a t a f i l e t o u s e w h e n c o m p i l i n g i n o r d e r t o i m p r o v e r u n t i m e p e r f o r m a n c e . " )
2022-08-04 21:04:35 +02:00
if ( LLVM_INCLUDE_TESTS )
2024-06-07 23:18:28 +00:00
# All LLVM Python files should be compatible down to this minimum version.
set ( LLVM_MINIMUM_PYTHON_VERSION 3.8 )
2022-08-04 21:04:35 +02:00
else ( )
# FIXME: it is unknown if this is the actual minimum bound
set ( LLVM_MINIMUM_PYTHON_VERSION 3.0 )
endif ( )
# Find python before including config-ix, since it needs to be able to search
# for python modules.
find_package ( Python3 ${ LLVM_MINIMUM_PYTHON_VERSION } REQUIRED
C O M P O N E N T S I n t e r p r e t e r )
2016-03-28 18:19:32 +00:00
# All options referred to from HandleLLVMOptions have to be specified
# BEFORE this include, otherwise options will not be correctly set on
# first cmake run
include ( config-ix )
# By default, we target the host, but this can be overridden at CMake
2022-01-27 10:09:27 -06:00
# invocation time. Except on 64-bit AIX, where the system toolchain
# expect 32-bit objects by default.
if ( "${LLVM_HOST_TRIPLE}" MATCHES "^powerpc64-ibm-aix" )
2023-09-14 23:44:13 -07:00
string ( REGEX REPLACE "^powerpc64" "powerpc" LLVM_DEFAULT_TARGET_TRIPLE_DEFAULT "${LLVM_HOST_TRIPLE}" )
2022-01-27 10:09:27 -06:00
else ( )
2022-11-04 12:37:07 -07:00
# Only set default triple when native target is enabled.
if ( LLVM_NATIVE_TARGET )
2023-09-14 23:44:13 -07:00
set ( LLVM_DEFAULT_TARGET_TRIPLE_DEFAULT "${LLVM_HOST_TRIPLE}" )
2022-11-04 12:37:07 -07:00
endif ( )
2022-01-27 10:09:27 -06:00
endif ( )
2023-09-14 23:44:13 -07:00
set ( LLVM_DEFAULT_TARGET_TRIPLE "${LLVM_DEFAULT_TARGET_TRIPLE_DEFAULT}" CACHE STRING
" D e f a u l t t a r g e t f o r w h i c h L L V M w i l l g e n e r a t e c o d e . " )
message ( STATUS "LLVM default target triple: ${LLVM_DEFAULT_TARGET_TRIPLE}" )
set ( LLVM_TARGET_TRIPLE "${LLVM_DEFAULT_TARGET_TRIPLE}" )
2016-03-28 18:19:32 +00:00
2019-06-02 15:53:43 +00:00
if ( WIN32 OR CYGWIN )
if ( BUILD_SHARED_LIBS OR LLVM_BUILD_LLVM_DYLIB )
set ( LLVM_ENABLE_PLUGINS_default ON )
else ( )
set ( LLVM_ENABLE_PLUGINS_default OFF )
endif ( )
else ( )
2019-06-04 11:33:49 +00:00
set ( LLVM_ENABLE_PLUGINS_default ${ LLVM_ENABLE_PIC } )
2019-06-02 15:53:43 +00:00
endif ( )
option ( LLVM_ENABLE_PLUGINS "Enable plugin support" ${ LLVM_ENABLE_PLUGINS_default } )
2021-08-26 14:25:31 -07:00
set ( LLVM_ENABLE_NEW_PASS_MANAGER TRUE CACHE BOOL
2021-01-25 11:00:56 -08:00
" E n a b l e t h e n e w p a s s m a n a g e r b y d e f a u l t . " )
2021-08-26 14:25:31 -07:00
if ( NOT LLVM_ENABLE_NEW_PASS_MANAGER )
2022-04-05 15:05:46 +02:00
message ( FATAL_ERROR "Enabling the legacy pass manager on the cmake level is"
" n o l o n g e r s u p p o r t e d . " )
2021-08-26 14:25:31 -07:00
endif ( )
2020-11-24 20:40:47 -08:00
2016-03-28 18:19:32 +00:00
include ( HandleLLVMOptions )
######
# Configure all of the various header file fragments LLVM uses which depend on
# configuration variables.
set ( LLVM_ENUM_TARGETS "" )
set ( LLVM_ENUM_ASM_PRINTERS "" )
set ( LLVM_ENUM_ASM_PARSERS "" )
set ( LLVM_ENUM_DISASSEMBLERS "" )
2021-07-24 20:27:41 -07:00
set ( LLVM_ENUM_TARGETMCAS "" )
2022-09-22 09:02:22 -07:00
set ( LLVM_ENUM_EXEGESIS "" )
2016-03-28 18:19:32 +00:00
foreach ( t ${ LLVM_TARGETS_TO_BUILD } )
set ( td ${ LLVM_MAIN_SRC_DIR } /lib/Target/ ${ t } )
2023-08-14 08:39:10 +00:00
# Make sure that any experimental targets were passed via
2017-12-18 19:15:15 +00:00
# LLVM_EXPERIMENTAL_TARGETS_TO_BUILD, not LLVM_TARGETS_TO_BUILD.
2023-08-14 08:39:10 +00:00
# We allow experimental targets that are not in LLVM_ALL_EXPERIMENTAL_TARGETS,
# as long as they are passed via LLVM_EXPERIMENTAL_TARGETS_TO_BUILD.
2023-11-01 07:34:23 +01:00
if ( NOT "${t}" IN_LIST LLVM_ALL_TARGETS AND NOT "${t}" IN_LIST LLVM_EXPERIMENTAL_TARGETS_TO_BUILD )
if ( "${t}" IN_LIST LLVM_ALL_EXPERIMENTAL_TARGETS )
2023-08-14 08:39:10 +00:00
message ( FATAL_ERROR "The target `${t}' is experimental and must be passed "
" v i a L L V M _ E X P E R I M E N T A L _ T A R G E T S _ T O _ B U I L D . " )
else ( )
message ( FATAL_ERROR "The target `${t}' is not a core tier target. It may be "
" e x p e r i m e n t a l , i f s o i t m u s t b e p a s s e d v i a "
" L L V M _ E X P E R I M E N T A L _ T A R G E T S _ T O _ B U I L D . \ n "
" C o r e t i e r t a r g e t s : $ { L L V M _ A L L _ T A R G E T S } \ n "
" K n o w n e x p e r i m e n t a l t a r g e t s : $ { L L V M _ A L L _ E X P E R I M E N T A L _ T A R G E T S } " )
endif ( )
2016-03-28 18:19:32 +00:00
else ( )
set ( LLVM_ENUM_TARGETS "${LLVM_ENUM_TARGETS}LLVM_TARGET(${t})\n" )
2023-11-03 11:01:40 -07:00
string ( TOUPPER ${ t } T_UPPER )
set ( LLVM_HAS_ ${ T_UPPER } _TARGET 1 )
2016-03-28 18:19:32 +00:00
endif ( )
file ( GLOB asmp_file "${td}/*AsmPrinter.cpp" )
if ( asmp_file )
set ( LLVM_ENUM_ASM_PRINTERS
" $ { L L V M _ E N U M _ A S M _ P R I N T E R S } LLVM_ASM_PRINTER ( ${ t } ) \ n " )
endif ( )
if ( EXISTS ${ td } /AsmParser/CMakeLists.txt )
set ( LLVM_ENUM_ASM_PARSERS
" $ { L L V M _ E N U M _ A S M _ P A R S E R S } LLVM_ASM_PARSER ( ${ t } ) \ n " )
endif ( )
if ( EXISTS ${ td } /Disassembler/CMakeLists.txt )
set ( LLVM_ENUM_DISASSEMBLERS
" $ { L L V M _ E N U M _ D I S A S S E M B L E R S } LLVM_DISASSEMBLER ( ${ t } ) \ n " )
endif ( )
2022-09-22 09:02:22 -07:00
if ( EXISTS ${ td } /MCA/CMakeLists.txt )
2021-07-24 20:27:41 -07:00
set ( LLVM_ENUM_TARGETMCAS
" $ { L L V M _ E N U M _ T A R G E T M C A S } LLVM_TARGETMCA ( ${ t } ) \ n " )
endif ( )
2022-09-22 09:02:22 -07:00
if ( EXISTS ${ LLVM_MAIN_SRC_DIR } /tools/llvm-exegesis/lib/ ${ t } /CMakeLists.txt )
set ( LLVM_ENUM_EXEGESIS
" $ { L L V M _ E N U M _ E X E G E S I S } LLVM_EXEGESIS ( ${ t } ) \ n " )
endif ( )
2016-03-28 18:19:32 +00:00
endforeach ( t )
2021-12-10 11:49:04 -08:00
# Provide an LLVM_ namespaced alias for use in #cmakedefine.
set ( LLVM_BUILD_SHARED_LIBS ${ BUILD_SHARED_LIBS } )
2016-03-28 18:19:32 +00:00
# Produce the target definition files, which provide a way for clients to easily
# include various classes of targets.
configure_file (
$ { L L V M _ M A I N _ I N C L U D E _ D I R } / l l v m / C o n f i g / A s m P r i n t e r s . d e f . i n
$ { L L V M _ I N C L U D E _ D I R } / l l v m / C o n f i g / A s m P r i n t e r s . d e f
)
configure_file (
$ { L L V M _ M A I N _ I N C L U D E _ D I R } / l l v m / C o n f i g / A s m P a r s e r s . d e f . i n
$ { L L V M _ I N C L U D E _ D I R } / l l v m / C o n f i g / A s m P a r s e r s . d e f
)
configure_file (
$ { L L V M _ M A I N _ I N C L U D E _ D I R } / l l v m / C o n f i g / D i s a s s e m b l e r s . d e f . i n
$ { L L V M _ I N C L U D E _ D I R } / l l v m / C o n f i g / D i s a s s e m b l e r s . d e f
)
configure_file (
$ { L L V M _ M A I N _ I N C L U D E _ D I R } / l l v m / C o n f i g / T a r g e t s . d e f . i n
$ { L L V M _ I N C L U D E _ D I R } / l l v m / C o n f i g / T a r g e t s . d e f
)
2021-07-24 20:27:41 -07:00
configure_file (
$ { L L V M _ M A I N _ I N C L U D E _ D I R } / l l v m / C o n f i g / T a r g e t M C A s . d e f . i n
$ { L L V M _ I N C L U D E _ D I R } / l l v m / C o n f i g / T a r g e t M C A s . d e f
)
2022-09-22 09:02:22 -07:00
configure_file (
$ { L L V M _ M A I N _ I N C L U D E _ D I R } / l l v m / C o n f i g / T a r g e t E x e g e s i s . d e f . i n
$ { L L V M _ I N C L U D E _ D I R } / l l v m / C o n f i g / T a r g e t E x e g e s i s . d e f
)
2016-03-28 18:19:32 +00:00
2020-09-28 20:46:22 +00:00
# They are not referenced. See set_output_directory().
2022-09-14 00:12:04 -04:00
set ( CMAKE_RUNTIME_OUTPUT_DIRECTORY ${ LLVM_TOOLS_BINARY_DIR } )
set ( CMAKE_LIBRARY_OUTPUT_DIRECTORY ${ LLVM_LIBRARY_DIR } )
set ( CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${ LLVM_LIBRARY_DIR } )
2020-09-28 20:46:22 +00:00
[mlgo] Use TFLite for 'development' mode.
TLite is a lightweight, statically linkable[1], model evaluator, supporting a
subset of what the full tensorflow library does, sufficient for the
types of scenarios we envision having. It is also faster.
We still use saved models as "source of truth" - 'release' mode's AOT
starts from a saved model; and the ML training side operates in terms of
saved models.
Using TFLite solves the following problems compared to using the full TF
C API:
- a compiler-friendly implementation for runtime-loadable (as opposed
to AOT-embedded) models: it's statically linked; it can be built via
cmake;
- solves an issue we had when building the compiler with both AOT and
full TF C API support, whereby, due to a packaging issue on the TF
side, we needed to have the pip package and the TF C API library at
the same version. We have no such constraints now.
The main liability is it supporting a subset of what the full TF
framework does. We do not expect that to cause an issue, but should that
be the case, we can always revert back to using the full framework
(after also figuring out a way to address the problems that motivated
the move to TFLite).
Details:
This change switches the development mode to TFLite. Models are still
expected to be placed in a directory - i.e. the parameters to clang
don't change; what changes is the directory content: we still need
an `output_spec.json` file; but instead of the saved_model protobuf and
the `variables` directory, we now just have one file, `model.tflite`.
The change includes a utility showing how to take a saved model and
convert it to TFLite, which it uses for testing.
The full TF implementation can still be built (not side-by-side). We
intend to remove it shortly, after patching downstream dependencies. The
build behavior, however, prioritizes TFLite - i.e. trying to enable both
full TF C API and TFLite will just pick TFLite.
[1] thanks to @petrhosek's changes to TFLite's cmake support and its deps!
2022-08-05 20:28:49 -07:00
# For up-to-date instructions for installing the TFLite dependency, refer to
2021-11-03 14:41:24 -05:00
# the bot setup script: https://github.com/google/ml-compiler-opt/blob/main/buildbot/buildbot_init.sh
[mlgo] Use TFLite for 'development' mode.
TLite is a lightweight, statically linkable[1], model evaluator, supporting a
subset of what the full tensorflow library does, sufficient for the
types of scenarios we envision having. It is also faster.
We still use saved models as "source of truth" - 'release' mode's AOT
starts from a saved model; and the ML training side operates in terms of
saved models.
Using TFLite solves the following problems compared to using the full TF
C API:
- a compiler-friendly implementation for runtime-loadable (as opposed
to AOT-embedded) models: it's statically linked; it can be built via
cmake;
- solves an issue we had when building the compiler with both AOT and
full TF C API support, whereby, due to a packaging issue on the TF
side, we needed to have the pip package and the TF C API library at
the same version. We have no such constraints now.
The main liability is it supporting a subset of what the full TF
framework does. We do not expect that to cause an issue, but should that
be the case, we can always revert back to using the full framework
(after also figuring out a way to address the problems that motivated
the move to TFLite).
Details:
This change switches the development mode to TFLite. Models are still
expected to be placed in a directory - i.e. the parameters to clang
don't change; what changes is the directory content: we still need
an `output_spec.json` file; but instead of the saved_model protobuf and
the `variables` directory, we now just have one file, `model.tflite`.
The change includes a utility showing how to take a saved model and
convert it to TFLite, which it uses for testing.
The full TF implementation can still be built (not side-by-side). We
intend to remove it shortly, after patching downstream dependencies. The
build behavior, however, prioritizes TFLite - i.e. trying to enable both
full TF C API and TFLite will just pick TFLite.
[1] thanks to @petrhosek's changes to TFLite's cmake support and its deps!
2022-08-05 20:28:49 -07:00
set ( LLVM_HAVE_TFLITE "" CACHE BOOL "Use tflite" )
if ( LLVM_HAVE_TFLITE )
find_package ( tensorflow-lite REQUIRED )
2020-07-13 22:30:25 -07:00
endif ( )
2020-07-22 11:16:08 -07:00
# For up-to-date instructions for installing the Tensorflow dependency, refer to
2021-11-03 14:41:24 -05:00
# the bot setup script: https://github.com/google/ml-compiler-opt/blob/main/buildbot/buildbot_init.sh
2020-07-22 11:16:08 -07:00
# Specifically, assuming python3 is installed:
# python3 -m pip install --upgrade pip && python3 -m pip install --user tf_nightly==2.3.0.dev20200528
# Then set TENSORFLOW_AOT_PATH to the package install - usually it's ~/.local/lib/python3.7/site-packages/tensorflow
#
set ( TENSORFLOW_AOT_PATH "" CACHE PATH "Path to TensorFlow pip install dir" )
if ( NOT TENSORFLOW_AOT_PATH STREQUAL "" )
set ( LLVM_HAVE_TF_AOT "ON" CACHE BOOL "Tensorflow AOT available" )
set ( TENSORFLOW_AOT_COMPILER
" $ { T E N S O R F L O W _ A O T _ P A T H } / . . / . . / . . / . . / b i n / s a v e d _ m o d e l _ c l i "
C A C H E P A T H " P a t h t o t h e T e n s o r f l o w A O T c o m p i l e r " )
2023-01-13 12:22:20 -08:00
include_directories ( ${ TENSORFLOW_AOT_PATH } /include )
2020-07-22 11:16:08 -07:00
add_subdirectory ( ${ TENSORFLOW_AOT_PATH } /xla_aot_runtime_src
$ { C M A K E _ A R C H I V E _ O U T P U T _ D I R E C T O R Y } / t f _ r u n t i m e )
2021-08-16 12:49:59 -04:00
install ( TARGETS tf_xla_runtime EXPORT LLVMExports
2022-08-18 22:44:46 -04:00
A R C H I V E D E S T I N A T I O N l i b $ { L L V M _ L I B D I R _ S U F F I X } C O M P O N E N T t f _ x l a _ r u n t i m e )
2025-01-27 10:59:07 -08:00
install ( TARGETS tf_xla_runtime EXPORT LLVMDevelopmentExports
A R C H I V E D E S T I N A T I O N l i b $ { L L V M _ L I B D I R _ S U F F I X } C O M P O N E N T t f _ x l a _ r u n t i m e )
2021-04-02 23:45:35 -07:00
set_property ( GLOBAL APPEND PROPERTY LLVM_EXPORTS tf_xla_runtime )
2021-10-13 10:36:08 -07:00
# Once we add more modules, we should handle this more automatically.
2022-01-19 21:19:53 -08:00
if ( DEFINED LLVM_OVERRIDE_MODEL_HEADER_INLINERSIZEMODEL )
set ( LLVM_INLINER_MODEL_PATH "none" )
elseif ( NOT DEFINED LLVM_INLINER_MODEL_PATH
2021-10-13 10:36:08 -07:00
O R " $ { L L V M _ I N L I N E R _ M O D E L _ P A T H } " S T R E Q U A L " "
O R " $ { L L V M _ I N L I N E R _ M O D E L _ P A T H } " S T R E Q U A L " a u t o g e n e r a t e " )
set ( LLVM_INLINER_MODEL_PATH "autogenerate" )
set ( LLVM_INLINER_MODEL_AUTOGENERATED 1 )
endif ( )
2022-01-19 21:19:53 -08:00
if ( DEFINED LLVM_OVERRIDE_MODEL_HEADER_REGALLOCEVICTMODEL )
set ( LLVM_RAEVICT_MODEL_PATH "none" )
elseif ( NOT DEFINED LLVM_RAEVICT_MODEL_PATH
2021-12-22 12:46:06 -08:00
O R " $ { L L V M _ R A E V I C T _ M O D E L _ P A T H } " S T R E Q U A L " "
O R " $ { L L V M _ R A E V I C T _ M O D E L _ P A T H } " S T R E Q U A L " a u t o g e n e r a t e " )
set ( LLVM_RAEVICT_MODEL_PATH "autogenerate" )
set ( LLVM_RAEVICT_MODEL_AUTOGENERATED 1 )
endif ( )
2020-07-22 11:16:08 -07:00
endif ( )
2016-03-28 18:19:32 +00:00
# Configure the three LLVM configuration header files.
configure_file (
$ { L L V M _ M A I N _ I N C L U D E _ D I R } / l l v m / C o n f i g / c o n f i g . h . c m a k e
$ { L L V M _ I N C L U D E _ D I R } / l l v m / C o n f i g / c o n f i g . h )
configure_file (
$ { L L V M _ M A I N _ I N C L U D E _ D I R } / l l v m / C o n f i g / l l v m - c o n f i g . h . c m a k e
$ { L L V M _ I N C L U D E _ D I R } / l l v m / C o n f i g / l l v m - c o n f i g . h )
2016-11-28 22:23:53 +00:00
configure_file (
$ { L L V M _ M A I N _ I N C L U D E _ D I R } / l l v m / C o n f i g / a b i - b r e a k i n g . h . c m a k e
$ { L L V M _ I N C L U D E _ D I R } / l l v m / C o n f i g / a b i - b r e a k i n g . h )
2016-03-28 18:19:32 +00:00
if ( APPLE AND DARWIN_LTO_LIBRARY )
set ( CMAKE_EXE_LINKER_FLAGS
" $ { C M A K E _ E X E _ L I N K E R _ F L A G S } - W l , - l t o _ l i b r a r y - W l , $ { D A R W I N _ L T O _ L I B R A R Y } " )
set ( CMAKE_SHARED_LINKER_FLAGS
" $ { C M A K E _ S H A R E D _ L I N K E R _ F L A G S } - W l , - l t o _ l i b r a r y - W l , $ { D A R W I N _ L T O _ L I B R A R Y } " )
set ( CMAKE_MODULE_LINKER_FLAGS
" $ { C M A K E _ M O D U L E _ L I N K E R _ F L A G S } - W l , - l t o _ l i b r a r y - W l , $ { D A R W I N _ L T O _ L I B R A R Y } " )
endif ( )
2019-06-07 15:45:25 +00:00
# Build with _XOPEN_SOURCE on AIX, as stray macros in _ALL_SOURCE mode tend to
# break things. In this case we need to enable the large-file API as well.
if ( UNIX AND ${ CMAKE_SYSTEM_NAME } MATCHES "AIX" )
2025-03-22 20:56:47 -04:00
add_compile_definitions ( _XOPEN_SOURCE=700 )
add_compile_definitions ( _LARGE_FILE_API )
add_compile_options ( -pthread )
2020-05-08 13:45:44 -04:00
2020-10-23 14:25:22 -04:00
# Modules should be built with -shared -Wl,-G, so we can use runtime linking
# with plugins.
string ( APPEND CMAKE_MODULE_LINKER_FLAGS " -shared -Wl,-G" )
2020-05-08 13:45:44 -04:00
# Also set the correct flags for building shared libraries.
string ( APPEND CMAKE_SHARED_LINKER_FLAGS " -shared" )
2019-06-07 15:45:25 +00:00
endif ( )
2020-07-09 14:17:33 +02:00
# Build with _XOPEN_SOURCE on z/OS.
if ( CMAKE_SYSTEM_NAME MATCHES "OS390" )
2023-01-23 15:04:23 +00:00
add_compile_definitions ( _XOPEN_SOURCE=600 )
add_compile_definitions ( _OPEN_SYS ) # Needed for process information.
add_compile_definitions ( _OPEN_SYS_FILE_EXT ) # Needed for EBCDIC I/O.
2023-12-07 15:04:56 -05:00
add_compile_definitions ( _EXT ) # Needed for file data.
2023-12-08 13:30:16 -05:00
add_compile_definitions ( _UNIX03_THREADS ) # Multithreading support.
2024-05-01 08:13:10 -04:00
# Need to build LLVM as ASCII application.
# This can't be a global setting because other projects may
# need to be built in EBCDIC mode.
append ( "-fzos-le-char-mode=ascii" CMAKE_CXX_FLAGS CMAKE_C_FLAGS )
append ( "-m64" CMAKE_CXX_FLAGS CMAKE_C_FLAGS )
2020-07-09 14:17:33 +02:00
endif ( )
2019-07-30 10:33:20 +00:00
# Build with _FILE_OFFSET_BITS=64 on Solaris to match g++ >= 9.
if ( UNIX AND ${ CMAKE_SYSTEM_NAME } MATCHES "SunOS" )
2023-01-23 15:04:23 +00:00
add_compile_definitions ( _FILE_OFFSET_BITS=64 )
2019-07-30 10:33:20 +00:00
endif ( )
2016-03-28 18:19:32 +00:00
set ( CMAKE_INCLUDE_CURRENT_DIR ON )
include_directories ( ${ LLVM_INCLUDE_DIR } ${ LLVM_MAIN_INCLUDE_DIR } )
# when crosscompiling import the executable targets from a file
if ( LLVM_USE_HOST_TOOLS )
include ( CrossCompile )
2019-07-19 00:10:06 +00:00
llvm_create_cross_target ( LLVM NATIVE "" Release )
2016-03-28 18:19:32 +00:00
endif ( LLVM_USE_HOST_TOOLS )
if ( LLVM_TARGET_IS_CROSSCOMPILE_HOST )
2017-09-29 02:48:07 +00:00
# Dummy use to avoid CMake Warning: Manually-specified variables were not used
2016-03-28 18:19:32 +00:00
# (this is a variable that CrossCompile sets on recursive invocations)
endif ( )
if ( ${ CMAKE_SYSTEM_NAME } MATCHES SunOS )
2017-06-22 13:18:46 +00:00
# special hack for Solaris to handle crazy system sys/regset.h
include_directories ( "${LLVM_MAIN_INCLUDE_DIR}/llvm/Support/Solaris" )
2016-03-28 18:19:32 +00:00
endif ( ${ CMAKE_SYSTEM_NAME } MATCHES SunOS )
# Make sure we don't get -rdynamic in every binary. For those that need it,
2024-08-07 09:12:15 -07:00
# use EXPORT_SYMBOLS argument.
2016-03-28 18:19:32 +00:00
set ( CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS "" )
include ( AddLLVM )
include ( TableGen )
2021-05-18 16:08:42 -07:00
include ( LLVMDistributionSupport )
2018-02-08 07:13:17 +00:00
if ( MINGW AND NOT "${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang" )
2016-03-28 18:19:32 +00:00
# People report that -O3 is unreliable on MinGW. The traditional
# build also uses -O2 for that reason:
llvm_replace_compiler_option ( CMAKE_CXX_FLAGS_RELEASE "-O3" "-O2" )
endif ( )
2022-03-16 19:46:28 +01:00
if ( LLVM_INCLUDE_TESTS )
umbrella_lit_testsuite_begin ( check-all )
endif ( )
2016-03-28 18:19:32 +00:00
# Put this before tblgen. Else we have a circular dependence.
2016-09-06 20:16:19 +00:00
add_subdirectory ( lib/Demangle )
2016-03-28 18:19:32 +00:00
add_subdirectory ( lib/Support )
add_subdirectory ( lib/TableGen )
add_subdirectory ( utils/TableGen )
2023-03-08 20:14:44 -08:00
add_subdirectory ( include )
2016-03-28 18:19:32 +00:00
add_subdirectory ( lib )
if ( LLVM_INCLUDE_UTILS )
add_subdirectory ( utils/FileCheck )
add_subdirectory ( utils/PerfectShuffle )
add_subdirectory ( utils/count )
add_subdirectory ( utils/not )
2022-04-04 12:41:12 +02:00
add_subdirectory ( utils/UnicodeData )
2016-03-28 18:19:32 +00:00
add_subdirectory ( utils/yaml-bench )
2022-08-12 14:16:29 +02:00
add_subdirectory ( utils/split-file )
2024-01-19 17:23:51 -08:00
add_subdirectory ( utils/mlgo-utils )
2022-08-15 09:42:41 -07:00
if ( LLVM_INCLUDE_TESTS )
2024-05-25 13:28:30 +02:00
set ( LLVM_SUBPROJECT_TITLE "Third-Party/Google Test" )
2022-11-09 08:51:34 -08:00
add_subdirectory ( ${ LLVM_THIRD_PARTY_DIR } /unittest ${ CMAKE_CURRENT_BINARY_DIR } /third-party/unittest )
2024-08-07 09:12:15 -07:00
set ( LLVM_SUBPROJECT_TITLE )
2022-08-15 09:42:41 -07:00
endif ( )
2016-03-28 18:19:32 +00:00
else ( )
if ( LLVM_INCLUDE_TESTS )
message ( FATAL_ERROR " Including tests when not building utils will not work.
2018-11-07 02:22:59 +00:00
E i t h e r s e t L L V M _ I N C L U D E _ U T I L S t o O n , o r s e t L L V M _ I N C L U D E _ T E S T S t o O f f . " )
2016-03-28 18:19:32 +00:00
endif ( )
endif ( )
# Use LLVM_ADD_NATIVE_VISUALIZERS_TO_SOLUTION instead of LLVM_INCLUDE_UTILS because it is not really a util
if ( LLVM_ADD_NATIVE_VISUALIZERS_TO_SOLUTION )
add_subdirectory ( utils/LLVMVisualizers )
endif ( )
foreach ( binding ${ LLVM_BINDINGS_LIST } )
if ( EXISTS "${LLVM_MAIN_SRC_DIR}/bindings/${binding}/CMakeLists.txt" )
add_subdirectory ( bindings/ ${ binding } )
endif ( )
endforeach ( )
add_subdirectory ( projects )
if ( LLVM_INCLUDE_TOOLS )
add_subdirectory ( tools )
endif ( )
2017-03-23 22:40:10 +00:00
if ( LLVM_INCLUDE_RUNTIMES )
add_subdirectory ( runtimes )
endif ( )
2016-06-23 22:07:21 +00:00
2016-03-28 18:19:32 +00:00
if ( LLVM_INCLUDE_EXAMPLES )
add_subdirectory ( examples )
endif ( )
if ( LLVM_INCLUDE_TESTS )
2023-10-17 11:15:46 -07:00
set ( LLVM_GTEST_RUN_UNDER
" " C A C H E S T R I N G
" D e f i n e t h e w r a p p e r p r o g r a m t h a t L L V M u n i t t e s t s s h o u l d b e r u n u n d e r . " )
2017-11-21 01:20:28 +00:00
if ( EXISTS ${ LLVM_MAIN_SRC_DIR } /projects/test-suite AND TARGET clang )
2016-03-28 18:19:32 +00:00
include ( LLVMExternalProjectUtils )
2017-11-21 01:20:28 +00:00
llvm_ExternalProject_Add ( test-suite ${ LLVM_MAIN_SRC_DIR } /projects/test-suite
U S E _ T O O L C H A I N
E X C L U D E _ F R O M _ A L L
N O _ I N S T A L L
A L W A Y S _ C L E A N )
2016-03-28 18:19:32 +00:00
endif ( )
2017-08-02 17:16:25 +00:00
add_subdirectory ( utils/lit )
2016-03-28 18:19:32 +00:00
add_subdirectory ( test )
add_subdirectory ( unittests )
2017-06-09 16:37:39 +00:00
2016-12-22 19:11:42 +00:00
if ( WIN32 )
2016-03-28 18:19:32 +00:00
# This utility is used to prevent crashing tests from calling Dr. Watson on
# Windows.
add_subdirectory ( utils/KillTheDoctor )
endif ( )
2022-03-16 19:46:28 +01:00
umbrella_lit_testsuite_end ( check-all )
get_property ( LLVM_ALL_LIT_DEPENDS GLOBAL PROPERTY LLVM_ALL_LIT_DEPENDS )
get_property ( LLVM_ALL_ADDITIONAL_TEST_DEPENDS
G L O B A L P R O P E R T Y L L V M _ A L L _ A D D I T I O N A L _ T E S T _ D E P E N D S )
2024-02-15 00:49:09 +01:00
add_custom_target ( test-depends )
if ( LLVM_ALL_LIT_DEPENDS OR LLVM_ALL_ADDITIONAL_TEST_DEPENDS )
add_dependencies ( test-depends ${ LLVM_ALL_LIT_DEPENDS } ${ LLVM_ALL_ADDITIONAL_TEST_DEPENDS } )
endif ( )
2024-05-25 13:28:30 +02:00
set_target_properties ( test-depends PROPERTIES FOLDER "LLVM/Tests" )
2023-12-13 11:43:40 -08:00
add_dependencies ( check-all test-depends )
2016-03-28 18:19:32 +00:00
endif ( )
if ( LLVM_INCLUDE_DOCS )
add_subdirectory ( docs )
endif ( )
add_subdirectory ( cmake/modules )
2017-09-15 22:10:46 +00:00
# Do this last so that all lit targets have already been created.
if ( LLVM_INCLUDE_UTILS )
add_subdirectory ( utils/llvm-lit )
endif ( )
2016-03-28 18:19:32 +00:00
if ( NOT LLVM_INSTALL_TOOLCHAIN_ONLY )
install ( DIRECTORY include/llvm include/llvm-c
2021-12-11 01:36:24 +00:00
D E S T I N A T I O N " $ { C M A K E _ I N S T A L L _ I N C L U D E D I R } "
2016-03-28 18:19:32 +00:00
C O M P O N E N T l l v m - h e a d e r s
F I L E S _ M A T C H I N G
P A T T E R N " * . d e f "
P A T T E R N " * . h "
P A T T E R N " * . t d "
P A T T E R N " * . i n c "
P A T T E R N " L I C E N S E . T X T "
)
2018-03-21 18:21:57 +00:00
install ( DIRECTORY ${ LLVM_INCLUDE_DIR } /llvm ${ LLVM_INCLUDE_DIR } /llvm-c
2021-12-11 01:36:24 +00:00
D E S T I N A T I O N " $ { C M A K E _ I N S T A L L _ I N C L U D E D I R } "
2016-03-28 18:19:32 +00:00
C O M P O N E N T l l v m - h e a d e r s
F I L E S _ M A T C H I N G
P A T T E R N " * . d e f "
P A T T E R N " * . h "
P A T T E R N " * . g e n "
P A T T E R N " * . i n c "
# Exclude include/llvm/CMakeFiles/intrinsics_gen.dir, matched by "*.def"
P A T T E R N " C M a k e F i l e s " E X C L U D E
P A T T E R N " c o n f i g . h " E X C L U D E
)
[LLVM] Allow modulemap installation
Summary:
Currently we can't install the modulemaps provided by LLVM, since they are not structured to support headers generated as part of the build (ex. `llvm/IR/Attributes.gen`).
This patch restructures the module maps in order to support installation.
Modules containing generated headers are defined in the new `module.extern.modulemap` file, and are referenced from the main `module.modulemap` using `extern module`. There are two versions of the `module.extern.modulemap` file; one used when building and another, `module.install.modulemap`, which is re-named during installation.
Users can opt-into module map installation using `-DLLVM_INSTALL_MODULEMAPS=ON`. The default value is `OFF` due to llvm.org/PR31905.
Reviewers: rsmith, mehdi_amini, bruno, EricWF
Reviewed By: EricWF
Subscribers: tschuett, chapuni, mgorny, llvm-commits
Differential Revision: https://reviews.llvm.org/D53510
llvm-svn: 347420
2018-11-21 20:46:50 +00:00
if ( LLVM_INSTALL_MODULEMAPS )
2023-03-08 20:14:44 -08:00
install ( DIRECTORY include
2021-12-11 01:36:24 +00:00
D E S T I N A T I O N " $ { C M A K E _ I N S T A L L _ I N C L U D E D I R } "
[LLVM] Allow modulemap installation
Summary:
Currently we can't install the modulemaps provided by LLVM, since they are not structured to support headers generated as part of the build (ex. `llvm/IR/Attributes.gen`).
This patch restructures the module maps in order to support installation.
Modules containing generated headers are defined in the new `module.extern.modulemap` file, and are referenced from the main `module.modulemap` using `extern module`. There are two versions of the `module.extern.modulemap` file; one used when building and another, `module.install.modulemap`, which is re-named during installation.
Users can opt-into module map installation using `-DLLVM_INSTALL_MODULEMAPS=ON`. The default value is `OFF` due to llvm.org/PR31905.
Reviewers: rsmith, mehdi_amini, bruno, EricWF
Reviewed By: EricWF
Subscribers: tschuett, chapuni, mgorny, llvm-commits
Differential Revision: https://reviews.llvm.org/D53510
llvm-svn: 347420
2018-11-21 20:46:50 +00:00
C O M P O N E N T l l v m - h e a d e r s
F I L E S _ M A T C H I N G
P A T T E R N " m o d u l e . m o d u l e m a p "
)
2023-03-08 20:14:44 -08:00
install ( FILES include/module.install.modulemap
D E S T I N A T I O N " $ { C M A K E _ I N S T A L L _ I N C L U D E D I R } "
[LLVM] Allow modulemap installation
Summary:
Currently we can't install the modulemaps provided by LLVM, since they are not structured to support headers generated as part of the build (ex. `llvm/IR/Attributes.gen`).
This patch restructures the module maps in order to support installation.
Modules containing generated headers are defined in the new `module.extern.modulemap` file, and are referenced from the main `module.modulemap` using `extern module`. There are two versions of the `module.extern.modulemap` file; one used when building and another, `module.install.modulemap`, which is re-named during installation.
Users can opt-into module map installation using `-DLLVM_INSTALL_MODULEMAPS=ON`. The default value is `OFF` due to llvm.org/PR31905.
Reviewers: rsmith, mehdi_amini, bruno, EricWF
Reviewed By: EricWF
Subscribers: tschuett, chapuni, mgorny, llvm-commits
Differential Revision: https://reviews.llvm.org/D53510
llvm-svn: 347420
2018-11-21 20:46:50 +00:00
C O M P O N E N T l l v m - h e a d e r s
R E N A M E " m o d u l e . e x t e r n . m o d u l e m a p "
)
endif ( LLVM_INSTALL_MODULEMAPS )
2016-10-24 21:58:58 +00:00
# Installing the headers needs to depend on generating any public
# tablegen'd headers.
2020-07-02 07:54:57 -06:00
add_custom_target ( llvm-headers DEPENDS intrinsics_gen omp_gen )
2024-05-25 13:28:30 +02:00
set_target_properties ( llvm-headers PROPERTIES FOLDER "LLVM/Resources" )
2016-10-24 21:58:58 +00:00
2018-10-15 21:20:02 +00:00
if ( NOT LLVM_ENABLE_IDE )
2017-11-30 21:48:26 +00:00
add_llvm_install_targets ( install-llvm-headers
2018-06-11 23:05:28 +00:00
D E P E N D S l l v m - h e a d e r s
2017-11-30 21:48:26 +00:00
C O M P O N E N T l l v m - h e a d e r s )
2016-03-28 18:19:32 +00:00
endif ( )
2018-09-04 19:10:37 +00:00
# Custom target to install all libraries.
add_custom_target ( llvm-libraries )
2024-05-25 13:28:30 +02:00
set_target_properties ( llvm-libraries PROPERTIES FOLDER "LLVM/Resources" )
2018-09-04 19:10:37 +00:00
2018-10-15 21:20:02 +00:00
if ( NOT LLVM_ENABLE_IDE )
2018-09-04 19:10:37 +00:00
add_llvm_install_targets ( install-llvm-libraries
D E P E N D S l l v m - l i b r a r i e s
C O M P O N E N T l l v m - l i b r a r i e s )
endif ( )
get_property ( LLVM_LIBS GLOBAL PROPERTY LLVM_LIBS )
if ( LLVM_LIBS )
list ( REMOVE_DUPLICATES LLVM_LIBS )
foreach ( lib ${ LLVM_LIBS } )
add_dependencies ( llvm-libraries ${ lib } )
2018-10-15 22:36:59 +00:00
if ( NOT LLVM_ENABLE_IDE )
2018-09-04 19:10:37 +00:00
add_dependencies ( install-llvm-libraries install- ${ lib } )
2020-03-20 18:42:09 -07:00
add_dependencies ( install-llvm-libraries-stripped install- ${ lib } -stripped )
2018-09-04 19:10:37 +00:00
endif ( )
endforeach ( )
endif ( )
2016-03-28 18:19:32 +00:00
endif ( )
# This must be at the end of the LLVM root CMakeLists file because it must run
# after all targets are created.
2019-06-14 18:28:57 +00:00
llvm_distribution_add_targets ( )
2020-02-16 09:31:16 +01:00
process_llvm_pass_plugins ( GEN_CONFIG )
2021-08-31 12:20:16 -07:00
include ( CoverageReport )
2017-01-28 07:39:52 +00:00
# This allows us to deploy the Universal CRT DLLs by passing -DCMAKE_INSTALL_UCRT_LIBRARIES=ON to CMake
2018-08-09 08:41:03 +00:00
if ( MSVC AND CMAKE_HOST_SYSTEM_NAME STREQUAL "Windows" AND CMAKE_INSTALL_UCRT_LIBRARIES )
2017-01-28 07:39:52 +00:00
include ( InstallRequiredSystemLibraries )
endif ( )
Pull google/benchmark library to the LLVM tree
This patch pulls google/benchmark v1.4.1 into the LLVM tree so that any
project could use it for benchmark generation. A dummy benchmark is
added to `llvm/benchmarks/DummyYAML.cpp` to validate the correctness of
the build process.
The current version does not utilize LLVM LNT and LLVM CMake
infrastructure, but that might be sufficient for most users. Two
introduced CMake variables:
* `LLVM_INCLUDE_BENCHMARKS` (`ON` by default) generates benchmark
targets
* `LLVM_BUILD_BENCHMARKS` (`OFF` by default) adds generated
benchmark targets to the list of default LLVM targets (i.e. if `ON`
benchmarks will be built upon standard build invocation, e.g. `ninja` or
`make` with no specific targets)
List of modifications:
* `BENCHMARK_ENABLE_TESTING` is disabled
* `BENCHMARK_ENABLE_EXCEPTIONS` is disabled
* `BENCHMARK_ENABLE_INSTALL` is disabled
* `BENCHMARK_ENABLE_GTEST_TESTS` is disabled
* `BENCHMARK_DOWNLOAD_DEPENDENCIES` is disabled
Original discussion can be found here:
http://lists.llvm.org/pipermail/llvm-dev/2018-August/125023.html
Reviewed by: dberris, lebedev.ri
Subscribers: ilya-biryukov, ioeric, EricWF, lebedev.ri, srhines,
dschuff, mgorny, krytarowski, fedor.sergeev, mgrang, jfb, llvm-commits
Differential Revision: https://reviews.llvm.org/D50894
llvm-svn: 340809
2018-08-28 09:42:41 +00:00
if ( LLVM_INCLUDE_BENCHMARKS )
# Override benchmark defaults so that when the library itself is updated these
# modifications are not lost.
set ( BENCHMARK_ENABLE_TESTING OFF CACHE BOOL "Disable benchmark testing" FORCE )
set ( BENCHMARK_ENABLE_EXCEPTIONS OFF CACHE BOOL "Disable benchmark exceptions" FORCE )
set ( BENCHMARK_ENABLE_INSTALL OFF CACHE BOOL "Don't install benchmark" FORCE )
set ( BENCHMARK_DOWNLOAD_DEPENDENCIES OFF CACHE BOOL "Don't download dependencies" FORCE )
set ( BENCHMARK_ENABLE_GTEST_TESTS OFF CACHE BOOL "Disable Google Test in benchmark" FORCE )
2022-04-29 11:42:06 +02:00
set ( BENCHMARK_ENABLE_WERROR ${ LLVM_ENABLE_WERROR } CACHE BOOL
2021-12-13 16:02:02 -08:00
" H a n d l e - W e r r o r f o r G o o g l e B e n c h m a r k b a s e d o n L L V M _ E N A B L E _ W E R R O R " F O R C E )
2018-08-28 14:51:09 +00:00
# Since LLVM requires C++11 it is safe to assume that std::regex is available.
set ( HAVE_STD_REGEX ON CACHE BOOL "OK" FORCE )
2022-04-29 11:42:06 +02:00
add_subdirectory ( ${ LLVM_THIRD_PARTY_DIR } /benchmark
2021-12-07 16:46:55 -08:00
$ { C M A K E _ C U R R E N T _ B I N A R Y _ D I R } / t h i r d - p a r t y / b e n c h m a r k )
2024-05-25 13:28:30 +02:00
set_target_properties ( benchmark PROPERTIES FOLDER "Third-Party/Google Benchmark" )
set_target_properties ( benchmark_main PROPERTIES FOLDER "Third-Party/Google Benchmark" )
Pull google/benchmark library to the LLVM tree
This patch pulls google/benchmark v1.4.1 into the LLVM tree so that any
project could use it for benchmark generation. A dummy benchmark is
added to `llvm/benchmarks/DummyYAML.cpp` to validate the correctness of
the build process.
The current version does not utilize LLVM LNT and LLVM CMake
infrastructure, but that might be sufficient for most users. Two
introduced CMake variables:
* `LLVM_INCLUDE_BENCHMARKS` (`ON` by default) generates benchmark
targets
* `LLVM_BUILD_BENCHMARKS` (`OFF` by default) adds generated
benchmark targets to the list of default LLVM targets (i.e. if `ON`
benchmarks will be built upon standard build invocation, e.g. `ninja` or
`make` with no specific targets)
List of modifications:
* `BENCHMARK_ENABLE_TESTING` is disabled
* `BENCHMARK_ENABLE_EXCEPTIONS` is disabled
* `BENCHMARK_ENABLE_INSTALL` is disabled
* `BENCHMARK_ENABLE_GTEST_TESTS` is disabled
* `BENCHMARK_DOWNLOAD_DEPENDENCIES` is disabled
Original discussion can be found here:
http://lists.llvm.org/pipermail/llvm-dev/2018-August/125023.html
Reviewed by: dberris, lebedev.ri
Subscribers: ilya-biryukov, ioeric, EricWF, lebedev.ri, srhines,
dschuff, mgorny, krytarowski, fedor.sergeev, mgrang, jfb, llvm-commits
Differential Revision: https://reviews.llvm.org/D50894
llvm-svn: 340809
2018-08-28 09:42:41 +00:00
add_subdirectory ( benchmarks )
endif ( )
2019-10-02 07:00:01 +00:00
if ( LLVM_INCLUDE_UTILS AND LLVM_INCLUDE_TOOLS )
add_subdirectory ( utils/llvm-locstats )
endif ( )
2024-07-30 17:17:04 -07:00
if ( XCODE )
# For additional targets that you would like to add schemes, specify e.g:
#
# -DLLVM_XCODE_EXTRA_TARGET_SCHEMES="TargetParserTests;SupportTests"
#
# at CMake configure time.
set ( LLVM_XCODE_EXTRA_TARGET_SCHEMES "" CACHE STRING "Specifies an extra list of targets to turn into schemes" )
foreach ( target ${ LLVM_XCODE_EXTRA_TARGET_SCHEMES } )
set_target_properties ( ${ target } PROPERTIES XCODE_GENERATE_SCHEME ON )
endforeach ( )
endif ( )