2017-06-01 08:09:20 +08:00
# See www/CMake.html for instructions on how to build libcxxabi with CMake.
2020-03-13 06:01:20 +08:00
if ( NOT IS_DIRECTORY "${CMAKE_CURRENT_LIST_DIR}/../libcxx" )
message ( FATAL_ERROR "libc++abi now requires being built in a monorepo layout with libcxx available" )
endif ( )
2014-07-04 03:35:48 +08:00
#===============================================================================
# Setup Project
#===============================================================================
2020-04-22 23:15:05 +08:00
cmake_minimum_required ( VERSION 3.13.4 )
2014-07-04 03:35:48 +08:00
2022-01-01 15:03:31 +08:00
set ( LLVM_COMMON_CMAKE_UTILS "${CMAKE_CURRENT_SOURCE_DIR}/../cmake" )
2017-04-08 04:10:41 +08:00
# Add path for custom modules
2022-01-01 15:03:31 +08:00
list ( INSERT CMAKE_MODULE_PATH 0
2017-04-08 04:10:41 +08: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-01 15:03:31 +08:00
" $ { L L V M _ C O M M O N _ C M A K E _ U T I L S } "
" $ { 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 "
2017-04-08 04:10:41 +08:00
)
2021-01-25 16:50:03 +08:00
set ( CMAKE_FOLDER "libc++" )
2020-08-24 17:01:05 +08:00
set ( LIBCXXABI_SOURCE_DIR ${ CMAKE_CURRENT_SOURCE_DIR } )
set ( LIBCXXABI_BINARY_DIR ${ CMAKE_CURRENT_BINARY_DIR } )
set ( LIBCXXABI_LIBCXX_PATH "${CMAKE_CURRENT_LIST_DIR}/../libcxx" CACHE PATH
" S p e c i f y p a t h t o l i b c + + s o u r c e . " )
2019-02-17 20:16:20 +08:00
if ( CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR OR LIBCXXABI_STANDALONE_BUILD )
2017-06-01 08:09:20 +08:00
project ( libcxxabi CXX C )
2014-07-04 03:35:48 +08:00
set ( PACKAGE_NAME libcxxabi )
2020-01-31 04:18:24 +08:00
set ( PACKAGE_VERSION 11.0.0git )
2014-07-04 03:35:48 +08:00
set ( PACKAGE_STRING "${PACKAGE_NAME} ${PACKAGE_VERSION}" )
2015-08-05 12:01:26 +08:00
set ( PACKAGE_BUGREPORT "llvm-bugs@lists.llvm.org" )
2014-07-04 03:35:48 +08:00
2022-01-19 14:45:07 +08:00
set ( LIBCXXABI_STANDALONE_BUILD TRUE )
2020-08-24 17:01:05 +08:00
# In a standalone build, we don't have llvm to automatically generate the
# llvm-lit script for us. So we need to provide an explicit directory that
# the configurator should write the script into.
set ( LLVM_LIT_OUTPUT_DIR "${LIBCXXABI_BINARY_DIR}/bin" )
2022-01-19 14:45:07 +08:00
endif ( )
2020-08-24 17:01:05 +08:00
2022-01-19 14:45:07 +08:00
# Must go below project(..)
include ( GNUInstallDirs )
if ( LIBCXXABI_STANDALONE_BUILD )
2017-06-01 08:09:20 +08:00
# Find the LLVM sources and simulate LLVM CMake options.
include ( HandleOutOfTreeLLVM )
2014-07-04 03:35:48 +08:00
2020-10-27 02:25:49 +08:00
find_package ( Python3 COMPONENTS Interpreter )
if ( NOT Python3_Interpreter_FOUND )
message ( WARNING "Python3 not found, using python2 as a fallback" )
find_package ( Python2 COMPONENTS Interpreter REQUIRED )
if ( Python2_VERSION VERSION_LESS 2.7 )
message ( SEND_ERROR "Python 2.7 or newer is required" )
endif ( )
# Treat python2 as python3
add_executable ( Python3::Interpreter IMPORTED )
set_target_properties ( Python3::Interpreter PROPERTIES
I M P O R T E D _ L O C A T I O N $ { P y t h o n 2 _ E X E C U T A B L E } )
set ( Python3_EXECUTABLE ${ Python2_EXECUTABLE } )
endif ( )
endif ( )
2017-06-01 08:09:20 +08:00
# Require out of source build.
include ( MacroEnsureOutOfSourceBuild )
MACRO_ENSURE_OUT_OF_SOURCE_BUILD (
" $ { P R O J E C T _ N A M E } r e q u i r e s a n o u t o f s o u r c e b u i l d . P l e a s e c r e a t e a s e p a r a t e
b u i l d d i r e c t o r y a n d r u n ' c m a k e / p a t h / t o / $ { P R O J E C T _ N A M E } [ o p t i o n s ] ' t h e r e . "
)
2014-07-04 03:35:48 +08:00
#===============================================================================
# Setup CMake Options
#===============================================================================
2017-06-01 08:09:20 +08:00
include ( CMakeDependentOption )
2017-04-08 04:10:41 +08:00
include ( HandleCompilerRT )
2014-07-04 03:35:48 +08:00
# Define options.
2019-07-13 03:10:59 +08:00
option ( LIBCXXABI_ENABLE_EXCEPTIONS
" P r o v i d e s u p p o r t f o r e x c e p t i o n s i n t h e r u n t i m e .
W h e n d i s a b l e d , l i b c + + a b i d o e s n o t s u p p o r t s t a c k u n w i n d i n g a n d o t h e r e x c e p t i o n s - r e l a t e d f e a t u r e s . " O N )
2014-07-04 03:35:48 +08:00
option ( LIBCXXABI_ENABLE_ASSERTIONS "Enable assertions independent of build mode." ON )
option ( LIBCXXABI_ENABLE_PEDANTIC "Compile with pedantic enabled." ON )
option ( LIBCXXABI_ENABLE_WERROR "Fail and stop if a warning is triggered." OFF )
2015-04-28 10:09:53 +08:00
option ( LIBCXXABI_USE_LLVM_UNWINDER "Build and use the LLVM unwinder." OFF )
2017-02-09 10:19:30 +08:00
option ( LIBCXXABI_ENABLE_STATIC_UNWINDER "Statically link the LLVM unwinder." OFF )
2016-07-15 08:49:42 +08:00
option ( LIBCXXABI_USE_COMPILER_RT "Use compiler-rt instead of libgcc" OFF )
2014-11-25 06:42:03 +08:00
option ( LIBCXXABI_ENABLE_THREADS "Build with threads enabled" ON )
2016-05-26 01:37:38 +08:00
option ( LIBCXXABI_HAS_PTHREAD_API "Ignore auto-detection and force use of pthread API" OFF )
2021-03-05 22:30:13 +08:00
option ( LIBCXXABI_HAS_WIN32_THREAD_API "Ignore auto-detection and force use of win32 thread API" OFF )
2017-01-03 20:58:34 +08:00
option ( LIBCXXABI_HAS_EXTERNAL_THREAD_API
" B u i l d l i b c + + a b i w i t h a n e x t e r n a l i z e d t h r e a d i n g A P I .
T h i s o p t i o n m a y o n l y b e s e t t o O N w h e n L I B C X X A B I _ E N A B L E _ T H R E A D S = O N . " O F F )
2017-01-09 19:57:21 +08:00
option ( LIBCXXABI_BUILD_EXTERNAL_THREAD_LIBRARY
" B u i l d l i b c + + a b i w i t h a n e x t e r n a l i z e d t h r e a d i n g l i b r a r y .
T h i s o p t i o n m a y o n l y b e s e t t o O N w h e n L I B C X X A B I _ E N A B L E _ T H R E A D S = O N " O F F )
2020-04-23 04:17:58 +08:00
option ( LIBCXXABI_ENABLE_FORGIVING_DYNAMIC_CAST
" M a k e d y n a m i c _ c a s t m o r e f o r g i v i n g w h e n t y p e _ i n f o ' s m i s t a k e n l y h a v e h i d d e n \
v i s i b i l i t y , a n d t h u s m u l t i p l e t y p e _ i n f o s c a n e x i s t f o r a s i n g l e t y p e . \
W h e n t h e d y n a m i c _ c a s t w o u l d n o r m a l l y f a i l , t h i s o p t i o n w i l l c a u s e t h e \
l i b r a r y t o t r y c o m p a r i n g t h e t y p e _ i n f o n a m e s t o s e e i f t h e y a r e e q u a l \
i n s t e a d . " O F F )
2017-03-03 05:55:17 +08:00
2017-03-03 03:34:35 +08:00
option ( LIBCXXABI_ENABLE_NEW_DELETE_DEFINITIONS
[libc++] Define new/delete in libc++abi only by default
Previously, we would define new/delete in both libc++ and libc++abi.
Not only does this cause code bloat, but also it's technically an ODR
violation since we don't know which operator will be selected. Furthermore,
since those are weak definitions, we should strive to have as few of them
as possible (to improve load times).
My preferred choice would have been to put the operators in libc++ only
by default, however that would create a circular dependency between
libc++ and libc++abi, which GNU linkers don't handle.
Folks who want to ship new/delete in libc++ instead of libc++abi are
free to do so by turning on LIBCXX_ENABLE_NEW_DELETE_DEFINITIONS at
CMake configure time.
On Apple platforms, this shouldn't be an ABI break because we re-export
the new/delete symbols from libc++abi. This change actually makes libc++
behave closer to the system libc++ shipped on Apple platforms.
On other platforms, this is an ABI break for people linking against libc++
but not libc++abi. However, vendors have been consulted in D68269 and no
objection was raised. Furthermore, the definitions can be controlled to
appear in libc++ instead with the CMake option.
Differential Revision: https://reviews.llvm.org/D68269
2019-10-01 21:34:58 +08:00
" B u i l d l i b c + + a b i w i t h d e f i n i t i o n s f o r o p e r a t o r n e w / d e l e t e . T h e s e a r e n o r m a l l y
d e f i n e d i n l i b c + + a b i , b u t i t i s a l s o p o s s i b l e t o d e f i n e t h e m i n l i b c + + , i n
w h i c h c a s e t h e d e f i n i t i o n i n l i b c + + a b i s h o u l d b e t u r n e d o f f . " O N )
2021-11-24 05:34:09 +08:00
option ( LIBCXXABI_BUILD_32_BITS "Build 32 bit multilib libc++abi. This option is not supported anymore when building the runtimes. Please specify a full triple instead." ${ LLVM_BUILD_32_BITS } )
if ( LIBCXXABI_BUILD_32_BITS )
2021-12-02 01:57:30 +08:00
message ( FATAL_ERROR "LIBCXXABI_BUILD_32_BITS is not supported anymore when building the runtimes, please specify a full triple instead." )
2021-11-24 05:34:09 +08:00
endif ( )
2017-01-08 06:14:04 +08:00
option ( LIBCXXABI_INCLUDE_TESTS "Generate build targets for the libc++abi unit tests." ${ LLVM_INCLUDE_TESTS } )
2017-06-13 16:16:44 +08:00
set ( LIBCXXABI_LIBDIR_SUFFIX "${LLVM_LIBDIR_SUFFIX}" CACHE STRING
" D e f i n e s u f f i x o f l i b r a r y d i r e c t o r y name ( 32/64 ) " )
2017-11-18 07:25:09 +08:00
option ( LIBCXXABI_INSTALL_LIBRARY "Install the libc++abi library." ON )
2021-10-13 03:59:08 +08:00
if ( CMAKE_CXX_COMPILER_TARGET )
set ( LIBCXXABI_DEFAULT_TARGET_TRIPLE "${CMAKE_CXX_COMPILER_TARGET}" )
else ( )
set ( LIBCXXABI_DEFAULT_TARGET_TRIPLE "${LLVM_DEFAULT_TARGET_TRIPLE}" )
endif ( )
set ( LIBCXXABI_TARGET_TRIPLE "${LIBCXXABI_DEFAULT_TARGET_TRIPLE}" CACHE STRING "Target triple for cross compiling." )
set ( LIBCXXABI_GCC_TOOLCHAIN "${CMAKE_CXX_COMPILER_EXTERNAL_TOOLCHAIN}" CACHE PATH "GCC toolchain for cross compiling." )
set ( LIBCXXABI_SYSROOT "${CMAKE_SYSROOT}" CACHE PATH "Sysroot for cross compiling." )
2016-06-01 20:50:30 +08:00
set ( LIBCXXABI_LIBCXX_LIBRARY_PATH "" CACHE PATH "The path to libc++ library." )
2019-10-08 03:22:04 +08:00
set ( LIBCXXABI_LIBRARY_VERSION "1.0" CACHE STRING
" V e r s i o n o f l i b c + + a b i . T h i s w i l l b e r e f l e c t e d i n t h e n a m e o f t h e s h a r e d \
l i b r a r y p r o d u c e d . F o r e x a m p l e , - D L I B C X X A B I _ L I B R A R Y _ V E R S I O N = x . y w i l l \
r e s u l t i n t h e l i b r a r y b e i n g n a m e d l i b c + + a b i . x . y . d y l i b , a l o n g w i t h t h e \
u s u a l s y m l i n k s p o i n t i n g t o t h a t . " )
2014-07-10 10:20:11 +08:00
# Default to building a shared library so that the default options still test
# the libc++abi that is being built. There are two problems with testing a
# static libc++abi. In the case of a standalone build, the tests will link the
# system's libc++, which might not have been built against our libc++abi. In the
# case of an in tree build, libc++ will prefer a dynamic libc++abi from the
# system over a static libc++abi from the output directory.
option ( LIBCXXABI_ENABLE_SHARED "Build libc++abi as a shared library." ON )
2015-03-03 23:59:09 +08:00
option ( LIBCXXABI_ENABLE_STATIC "Build libc++abi as a static library." ON )
2018-07-26 07:13:00 +08:00
cmake_dependent_option ( LIBCXXABI_INSTALL_STATIC_LIBRARY
" I n s t a l l t h e s t a t i c l i b c + + a b i l i b r a r y . " O N
" L I B C X X A B I _ E N A B L E _ S T A T I C ; L I B C X X A B I _ I N S T A L L _ L I B R A R Y " O F F )
cmake_dependent_option ( LIBCXXABI_INSTALL_SHARED_LIBRARY
" I n s t a l l t h e s h a r e d l i b c + + a b i l i b r a r y . " O N
" L I B C X X A B I _ E N A B L E _ S H A R E D ; L I B C X X A B I _ I N S T A L L _ L I B R A R Y " O F F )
2018-07-24 15:06:17 +08:00
cmake_dependent_option ( LIBCXXABI_STATICALLY_LINK_UNWINDER_IN_STATIC_LIBRARY
" S t a t i c a l l y l i n k t h e L L V M u n w i n d e r t o s t a t i c l i b r a r y " O N
" L I B C X X A B I _ E N A B L E _ S T A T I C _ U N W I N D E R ; L I B C X X A B I _ E N A B L E _ S T A T I C " O F F )
cmake_dependent_option ( LIBCXXABI_STATICALLY_LINK_UNWINDER_IN_SHARED_LIBRARY
" S t a t i c a l l y l i n k t h e L L V M u n w i n d e r t o s h a r e d l i b r a r y " O N
" L I B C X X A B I _ E N A B L E _ S T A T I C _ U N W I N D E R ; L I B C X X A B I _ E N A B L E _ S H A R E D " O F F )
2017-03-01 19:42:01 +08:00
option ( LIBCXXABI_BAREMETAL "Build libc++abi for baremetal targets." OFF )
# The default terminate handler attempts to demangle uncaught exceptions, which
# causes extra I/O and demangling code to be pulled in.
option ( LIBCXXABI_SILENT_TERMINATE "Set this to make the terminate handler default to a silent alternative" OFF )
2021-01-22 05:27:14 +08:00
option ( LIBCXXABI_NON_DEMANGLING_TERMINATE " Set this to make the terminate handler
a v o i d d e m a n g l i n g " O F F )
2017-03-01 19:42:01 +08:00
2015-03-03 23:59:09 +08:00
if ( NOT LIBCXXABI_ENABLE_SHARED AND NOT LIBCXXABI_ENABLE_STATIC )
message ( FATAL_ERROR "libc++abi must be built as either a shared or static library." )
endif ( )
2014-07-10 10:20:11 +08:00
2021-03-11 03:21:41 +08:00
# TODO: This is a workaround for the fact that Standalone builds can't use
# targets from the other runtimes (so the cxx-headers target doesn't exist).
set ( LIBCXXABI_LIBCXX_INCLUDES "" CACHE PATH
2020-10-23 21:32:50 +08:00
" S p e c i f y p a t h t o l i b c + + i n c l u d e s . " )
2021-03-11 03:21:41 +08:00
if ( LIBCXXABI_STANDALONE_BUILD )
if ( NOT IS_DIRECTORY ${ LIBCXXABI_LIBCXX_INCLUDES } )
message ( FATAL_ERROR
" L I B C X X A B I _ L I B C X X _ I N C L U D E S = $ { L I B C X X A B I _ L I B C X X _ I N C L U D E S } i s n o t a v a l i d d i r e c t o r y . "
" P l e a s e p r o v i d e t h e p a t h t o w h e r e t h e l i b c + + h e a d e r s h a v e b e e n i n s t a l l e d . " )
endif ( )
add_library ( cxx-headers INTERFACE )
if ( "${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC" OR "${CMAKE_CXX_SIMULATE_ID}" STREQUAL "MSVC" )
target_compile_options ( cxx-headers INTERFACE /I "${LIBCXXABI_LIBCXX_INCLUDES}" )
else ( )
target_compile_options ( cxx-headers INTERFACE -I "${LIBCXXABI_LIBCXX_INCLUDES}" )
endif ( )
endif ( )
2020-10-23 07:11:33 +08:00
2019-01-24 11:18:29 +08:00
option ( LIBCXXABI_HERMETIC_STATIC_LIBRARY
" D o n o t e x p o r t a n y s y m b o l s f r o m t h e s t a t i c l i b r a r y . " O F F )
2020-06-25 23:46:00 +08:00
set ( LIBCXXABI_TEST_CONFIG "${CMAKE_CURRENT_SOURCE_DIR}/test/lit.site.cfg.in" CACHE STRING
2021-09-30 03:26:05 +08:00
" T h e p a t h t o t h e L i t t e s t i n g c o n f i g u r a t i o n t o u s e w h e n r u n n i n g t h e t e s t s .
2021-10-13 05:45:45 +08:00
I f a r e l a t i v e p a t h i s p r o v i d e d , i t i s a s s u m e d t o b e r e l a t i v e t o ' < m o n o r e p o > / l i b c x x a b i / t e s t / c o n f i g s ' . " )
2021-09-30 03:26:05 +08:00
if ( NOT IS_ABSOLUTE "${LIBCXXABI_TEST_CONFIG}" )
2021-10-13 05:45:45 +08:00
set ( LIBCXXABI_TEST_CONFIG "${CMAKE_CURRENT_SOURCE_DIR}/test/configs/${LIBCXXABI_TEST_CONFIG}" )
2021-09-30 03:26:05 +08:00
endif ( )
2020-07-09 23:54:09 +08:00
set ( LIBCXXABI_TEST_PARAMS "" CACHE STRING
" A l i s t o f p a r a m e t e r s t o r u n t h e L i t t e s t s u i t e w i t h . " )
2020-06-25 23:46:00 +08:00
2014-07-04 03:35:48 +08:00
#===============================================================================
# Configure System
#===============================================================================
# Add path for custom modules
set ( CMAKE_MODULE_PATH
" $ { 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 "
$ { C M A K E _ M O D U L E _ P A T H }
)
2022-01-16 14:00:29 +08:00
set ( LIBCXXABI_INSTALL_RUNTIME_DIR "${CMAKE_INSTALL_BINDIR}" CACHE PATH
2022-01-11 11:03:21 +08:00
" P a t h w h e r e b u i l t l i b c + + a b i r u n t i m e l i b r a r i e s s h o u l d b e i n s t a l l e d . " )
2018-06-28 11:11:52 +08:00
if ( LLVM_ENABLE_PER_TARGET_RUNTIME_DIR AND NOT APPLE )
2021-03-11 03:21:41 +08:00
set ( LIBCXXABI_HEADER_DIR ${ LLVM_BINARY_DIR } )
2021-04-17 12:33:18 +08:00
set ( LIBCXXABI_LIBRARY_DIR ${ LLVM_LIBRARY_OUTPUT_INTDIR } / ${ LLVM_DEFAULT_TARGET_TRIPLE } )
Prepare Compiler-RT for GnuInstallDirs, matching libcxx, document all
This is a second attempt at D101497, which landed as
9a9bc76c0eb72f0f2732c729a460abbd5239c2e3 but had to be reverted in
8cf7ddbdd4e5af966a369e170c73250f2e3920e7.
This issue was that in the case that `COMPILER_RT_INSTALL_PATH` is
empty, expressions like "${COMPILER_RT_INSTALL_PATH}/bin" evaluated to
"/bin" not "bin" as intended and as was originally.
One solution is to make `COMPILER_RT_INSTALL_PATH` always non-empty,
defaulting it to `CMAKE_INSTALL_PREFIX`. D99636 adopted that approach.
But, I think it is more ergonomic to allow those project-specific paths
to be relative the global ones. Also, making install paths absolute by
default inhibits the proper behavior of functions like
`GNUInstallDirs_get_absolute_install_dir` which make relative install
paths absolute in a more complicated way.
Given all this, I will define a function like the one asked for in
https://gitlab.kitware.com/cmake/cmake/-/issues/19568 (and needed for a
similar use-case).
---
Original message:
Instead of using `COMPILER_RT_INSTALL_PATH` through the CMake for
complier-rt, just use it to define variables for the subdirs which
themselves are used.
This preserves compatibility, but later on we might consider getting rid
of `COMPILER_RT_INSTALL_PATH` and just changing the defaults for the
subdir variables directly.
---
There was a seaming bug where the (non-Apple) per-target libdir was
`${target}` not `lib/${target}`. I suspect that has to do with the docs
on `COMPILER_RT_INSTALL_PATH` saying was the library dir when that's no
longer true, so I just went ahead and fixed it, allowing me to define
fewer and more sensible variables.
That last part should be the only behavior changes; everything else
should be a pure refactoring.
---
I added some documentation of these variables too. In particular, I
wanted to highlight the gotcha where `-DSomeCachePath=...` without the
`:PATH` will lead CMake to make the path absolute. See [1] for
discussion of the problem, and [2] for the brief official documentation
they added as a result.
[1]: https://cmake.org/pipermail/cmake/2015-March/060204.html
[2]: https://cmake.org/cmake/help/latest/manual/cmake.1.html#options
In 38b2dec37ee735d5409148e71ecba278caf0f969 the problem was somewhat
misidentified and so `:STRING` was used, but `:PATH` is better as it
sets the correct type from the get-go.
---
D99484 is the main thrust of the `GnuInstallDirs` work. Once this lands,
it should be feasible to follow both of these up with a simple patch for
compiler-rt analogous to the one for libcxx.
Reviewed By: phosek, #libc_abi, #libunwind
Differential Revision: https://reviews.llvm.org/D105765
2021-04-29 06:36:47 +08:00
set ( LIBCXXABI_INSTALL_LIBRARY_DIR lib ${ LLVM_LIBDIR_SUFFIX } / ${ LLVM_DEFAULT_TARGET_TRIPLE } CACHE PATH
" P a t h w h e r e b u i l t l i b c + + a b i l i b r a r i e s s h o u l d b e i n s t a l l e d . " )
2019-05-23 05:08:33 +08:00
if ( LIBCXX_LIBDIR_SUBDIR )
string ( APPEND LIBCXXABI_LIBRARY_DIR / ${ LIBCXXABI_LIBDIR_SUBDIR } )
string ( APPEND LIBCXXABI_INSTALL_LIBRARY_DIR / ${ LIBCXXABI_LIBDIR_SUBDIR } )
endif ( )
2017-05-04 14:04:49 +08:00
else ( )
2022-01-11 11:03:21 +08:00
if ( LLVM_LIBRARY_OUTPUT_INTDIR )
set ( LIBCXXABI_HEADER_DIR ${ LLVM_BINARY_DIR } )
set ( LIBCXXABI_LIBRARY_DIR ${ LLVM_LIBRARY_OUTPUT_INTDIR } )
else ( )
set ( LIBCXXABI_HEADER_DIR ${ CMAKE_BINARY_DIR } )
set ( LIBCXXABI_LIBRARY_DIR ${ CMAKE_BINARY_DIR } /lib ${ LIBCXXABI_LIBDIR_SUFFIX } )
endif ( )
Prepare Compiler-RT for GnuInstallDirs, matching libcxx, document all
This is a second attempt at D101497, which landed as
9a9bc76c0eb72f0f2732c729a460abbd5239c2e3 but had to be reverted in
8cf7ddbdd4e5af966a369e170c73250f2e3920e7.
This issue was that in the case that `COMPILER_RT_INSTALL_PATH` is
empty, expressions like "${COMPILER_RT_INSTALL_PATH}/bin" evaluated to
"/bin" not "bin" as intended and as was originally.
One solution is to make `COMPILER_RT_INSTALL_PATH` always non-empty,
defaulting it to `CMAKE_INSTALL_PREFIX`. D99636 adopted that approach.
But, I think it is more ergonomic to allow those project-specific paths
to be relative the global ones. Also, making install paths absolute by
default inhibits the proper behavior of functions like
`GNUInstallDirs_get_absolute_install_dir` which make relative install
paths absolute in a more complicated way.
Given all this, I will define a function like the one asked for in
https://gitlab.kitware.com/cmake/cmake/-/issues/19568 (and needed for a
similar use-case).
---
Original message:
Instead of using `COMPILER_RT_INSTALL_PATH` through the CMake for
complier-rt, just use it to define variables for the subdirs which
themselves are used.
This preserves compatibility, but later on we might consider getting rid
of `COMPILER_RT_INSTALL_PATH` and just changing the defaults for the
subdir variables directly.
---
There was a seaming bug where the (non-Apple) per-target libdir was
`${target}` not `lib/${target}`. I suspect that has to do with the docs
on `COMPILER_RT_INSTALL_PATH` saying was the library dir when that's no
longer true, so I just went ahead and fixed it, allowing me to define
fewer and more sensible variables.
That last part should be the only behavior changes; everything else
should be a pure refactoring.
---
I added some documentation of these variables too. In particular, I
wanted to highlight the gotcha where `-DSomeCachePath=...` without the
`:PATH` will lead CMake to make the path absolute. See [1] for
discussion of the problem, and [2] for the brief official documentation
they added as a result.
[1]: https://cmake.org/pipermail/cmake/2015-March/060204.html
[2]: https://cmake.org/cmake/help/latest/manual/cmake.1.html#options
In 38b2dec37ee735d5409148e71ecba278caf0f969 the problem was somewhat
misidentified and so `:STRING` was used, but `:PATH` is better as it
sets the correct type from the get-go.
---
D99484 is the main thrust of the `GnuInstallDirs` work. Once this lands,
it should be feasible to follow both of these up with a simple patch for
compiler-rt analogous to the one for libcxx.
Reviewed By: phosek, #libc_abi, #libunwind
Differential Revision: https://reviews.llvm.org/D105765
2021-04-29 06:36:47 +08:00
set ( LIBCXXABI_INSTALL_LIBRARY_DIR lib ${ LIBCXXABI_LIBDIR_SUFFIX } CACHE PATH
" P a t h w h e r e b u i l t l i b c + + a b i l i b r a r i e s s h o u l d b e i n s t a l l e d . " )
2017-05-04 14:04:49 +08:00
endif ( )
2014-12-29 20:22:04 +08:00
2016-04-18 21:30:38 +08:00
set ( CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${ LIBCXXABI_LIBRARY_DIR } )
set ( CMAKE_LIBRARY_OUTPUT_DIRECTORY ${ LIBCXXABI_LIBRARY_DIR } )
2017-06-01 08:09:20 +08:00
set ( CMAKE_RUNTIME_OUTPUT_DIRECTORY ${ LIBCXXABI_LIBRARY_DIR } )
2016-04-18 21:30:38 +08:00
2016-06-01 20:50:30 +08:00
# By default, for non-standalone builds, libcxx and libcxxabi share a library
# directory.
if ( NOT LIBCXXABI_LIBCXX_LIBRARY_PATH )
set ( LIBCXXABI_LIBCXX_LIBRARY_PATH "${LIBCXXABI_LIBRARY_DIR}" CACHE PATH
[libcxxabi] Allow tests to link with static libc++abi/libc++ even if the shared version is present
Summary:
Right now the only way to force libc++abi tests to link with the static version of libc++abi is to set `LIBCXXABI_ENABLE_SHARED` to `OFF`. However, this doesn't work when libc++abi is built as standalone project because of [this](https://github.com/llvm/llvm-project/blob/54c522420347e58aa7bae1892cf5c5672b57c875/libcxxabi/CMakeLists.txt#L503-L519).
This change allows specifying the version of the library for tests to link with.
This is useful for remote testing, for example, with `SSHExecutor`, where we _have_ to link with libc++abi statically.
Two new CMake options are introduced here: `LIBCXXABI_LINK_TESTS_WITH_SHARED_LIBCXXABI` and `LIBCXXABI_LINK_TESTS_WITH_SHARED_LIBCXX`. They can be set to `OFF` to tell the test utility to link tests with the static libraries.
It shouldn't break anything, because the default values of these options are set such that the test utility will behave the same way.
Reviewers: EricWF, mclow.lists, phosek, mehdi_amini, ldionne, jroelofs, bcraig
Subscribers: mgorny, christof, ldionne, libcxx-commits
Tags: #libc
Differential Revision: https://reviews.llvm.org/D71894
2019-12-26 17:28:39 +08:00
" T h e p a t h t o l i b c + + l i b r a r y . " F O R C E )
2016-08-09 01:59:02 +08:00
endif ( )
2016-06-02 10:18:31 +08:00
2017-06-01 08:09:20 +08:00
# Declare libc++abi configuration variables.
# They are intended for use as follows:
# LIBCXXABI_C_FLAGS: General flags for both the c++ compiler and linker.
# LIBCXXABI_CXX_FLAGS: General flags for both the c++ compiler and linker.
# LIBCXXABI_COMPILE_FLAGS: Compile only flags.
# LIBCXXABI_LINK_FLAGS: Linker only flags.
# LIBCXXABI_LIBRARIES: libraries libc++abi is linked to.
2016-06-02 10:18:31 +08:00
2015-01-22 21:39:08 +08:00
set ( LIBCXXABI_C_FLAGS "" )
2014-11-19 04:37:53 +08:00
set ( LIBCXXABI_CXX_FLAGS "" )
set ( LIBCXXABI_COMPILE_FLAGS "" )
set ( LIBCXXABI_LINK_FLAGS "" )
2017-06-01 08:09:20 +08:00
set ( LIBCXXABI_LIBRARIES "" )
# Include macros for adding and removing libc++abi flags.
include ( HandleLibcxxabiFlags )
#===============================================================================
# Setup Compiler Flags
#===============================================================================
2014-11-19 04:37:53 +08:00
2016-06-02 10:18:31 +08:00
# Configure target flags
2022-01-15 00:35:53 +08:00
if ( ZOS )
add_target_flags_if_supported ( "-fzos-le-char-mode=ebcdic" )
endif ( )
[CMake] Support CMake variables for setting target, sysroot and toolchain
CMake has a standard way of setting target triple, sysroot and external
toolchain through CMAKE_<LANG>_COMPILER_TARGET, CMAKE_SYSROOT and
CMAKE_<LANG>_COMPILER_EXTERNAL_TOOLCHAIN. These are turned into
corresponding --target=, --sysroot= and --gcc-toolchain= variables add
included appended to CMAKE_<LANG>_FLAGS.
libunwind, libc++abi, libc++ provides their own mechanism through
<PROJECT>_TARGET_TRIPLE, <PROJECT>_SYSROOT and <PROJECT>_GCC_TOOLCHAIN
variables. These are also passed to lit via lit.site.cfg, and lit config
uses these to set the corresponding compiler flags when building tessts.
This means that there are two different ways of setting target, sysroot
and toolchain, but only one is properly supported in lit. This change
extends CMake build for libunwind, libc++abi and libc++ to also support
the CMake variables in addition to project specific ones in lit.
Differential Revision: https://reviews.llvm.org/D57670
llvm-svn: 353084
2019-02-05 04:02:26 +08:00
if ( LIBCXXABI_TARGET_TRIPLE )
2021-07-16 01:02:43 +08:00
add_target_flags_if_supported ( "--target=${LIBCXXABI_TARGET_TRIPLE}" )
[CMake] Support CMake variables for setting target, sysroot and toolchain
CMake has a standard way of setting target triple, sysroot and external
toolchain through CMAKE_<LANG>_COMPILER_TARGET, CMAKE_SYSROOT and
CMAKE_<LANG>_COMPILER_EXTERNAL_TOOLCHAIN. These are turned into
corresponding --target=, --sysroot= and --gcc-toolchain= variables add
included appended to CMAKE_<LANG>_FLAGS.
libunwind, libc++abi, libc++ provides their own mechanism through
<PROJECT>_TARGET_TRIPLE, <PROJECT>_SYSROOT and <PROJECT>_GCC_TOOLCHAIN
variables. These are also passed to lit via lit.site.cfg, and lit config
uses these to set the corresponding compiler flags when building tessts.
This means that there are two different ways of setting target, sysroot
and toolchain, but only one is properly supported in lit. This change
extends CMake build for libunwind, libc++abi and libc++ to also support
the CMake variables in addition to project specific ones in lit.
Differential Revision: https://reviews.llvm.org/D57670
llvm-svn: 353084
2019-02-05 04:02:26 +08:00
endif ( )
2021-10-13 03:59:08 +08:00
if ( LIBCXXABI_GCC_TOOLCHAIN )
2021-07-16 01:02:43 +08:00
add_target_flags_if_supported ( "--gcc-toolchain=${LIBCXXABI_GCC_TOOLCHAIN}" )
[CMake] Support CMake variables for setting target, sysroot and toolchain
CMake has a standard way of setting target triple, sysroot and external
toolchain through CMAKE_<LANG>_COMPILER_TARGET, CMAKE_SYSROOT and
CMAKE_<LANG>_COMPILER_EXTERNAL_TOOLCHAIN. These are turned into
corresponding --target=, --sysroot= and --gcc-toolchain= variables add
included appended to CMAKE_<LANG>_FLAGS.
libunwind, libc++abi, libc++ provides their own mechanism through
<PROJECT>_TARGET_TRIPLE, <PROJECT>_SYSROOT and <PROJECT>_GCC_TOOLCHAIN
variables. These are also passed to lit via lit.site.cfg, and lit config
uses these to set the corresponding compiler flags when building tessts.
This means that there are two different ways of setting target, sysroot
and toolchain, but only one is properly supported in lit. This change
extends CMake build for libunwind, libc++abi and libc++ to also support
the CMake variables in addition to project specific ones in lit.
Differential Revision: https://reviews.llvm.org/D57670
llvm-svn: 353084
2019-02-05 04:02:26 +08:00
endif ( )
if ( LIBCXXABI_SYSROOT )
2021-07-16 01:02:43 +08:00
add_target_flags_if_supported ( "--sysroot=${LIBCXXABI_SYSROOT}" )
[CMake] Support CMake variables for setting target, sysroot and toolchain
CMake has a standard way of setting target triple, sysroot and external
toolchain through CMAKE_<LANG>_COMPILER_TARGET, CMAKE_SYSROOT and
CMAKE_<LANG>_COMPILER_EXTERNAL_TOOLCHAIN. These are turned into
corresponding --target=, --sysroot= and --gcc-toolchain= variables add
included appended to CMAKE_<LANG>_FLAGS.
libunwind, libc++abi, libc++ provides their own mechanism through
<PROJECT>_TARGET_TRIPLE, <PROJECT>_SYSROOT and <PROJECT>_GCC_TOOLCHAIN
variables. These are also passed to lit via lit.site.cfg, and lit config
uses these to set the corresponding compiler flags when building tessts.
This means that there are two different ways of setting target, sysroot
and toolchain, but only one is properly supported in lit. This change
extends CMake build for libunwind, libc++abi and libc++ to also support
the CMake variables in addition to project specific ones in lit.
Differential Revision: https://reviews.llvm.org/D57670
llvm-svn: 353084
2019-02-05 04:02:26 +08:00
endif ( )
2016-06-02 10:18:31 +08:00
# Configure compiler. Must happen after setting the target flags.
include ( config-ix )
2014-11-19 04:37:53 +08:00
2014-07-04 03:35:48 +08:00
if ( LIBCXXABI_HAS_NOSTDINCXX_FLAG )
2014-11-19 04:37:53 +08:00
list ( APPEND LIBCXXABI_COMPILE_FLAGS -nostdinc++ )
2019-11-08 06:51:25 +08:00
# cmake 3.14 and above remove system include paths that are explicitly
# passed on the command line. We build with -nostdinc++ and explicitly add
# just the libcxx system include paths with -I on the command line.
# Setting CMAKE_CXX_IMPLICIT_INCLUDE_DIRECTORIES effectively prevents cmake
# from removing these.
# See: https://gitlab.kitware.com/cmake/cmake/issues/19227
set ( CMAKE_CXX_IMPLICIT_INCLUDE_DIRECTORIES "" )
2014-11-19 04:37:53 +08:00
# Remove -stdlib flags to prevent them from causing an unused flag warning.
2020-10-13 22:05:00 +08:00
string ( REPLACE "--stdlib=libc++" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}" )
string ( REPLACE "--stdlib=libstdc++" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}" )
2014-11-19 04:37:53 +08:00
string ( REPLACE "-stdlib=libc++" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}" )
string ( REPLACE "-stdlib=libstdc++" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}" )
2014-07-04 03:35:48 +08:00
endif ( )
2016-09-27 11:44:09 +08:00
# Let the library headers know they are currently being used to build the
# library.
add_definitions ( -D_LIBCXXABI_BUILDING_LIBRARY )
2020-10-31 01:11:23 +08:00
# libcxxabi needs to, for various reasons, include the libcpp headers as if
# it is being built as part of libcxx.
add_definitions ( -D_LIBCPP_BUILDING_LIBRARY )
2016-09-27 11:44:09 +08:00
# Disable DLL annotations on Windows for static builds.
if ( WIN32 AND LIBCXXABI_ENABLE_STATIC AND NOT LIBCXXABI_ENABLE_SHARED )
2020-10-23 15:54:02 +08:00
if ( LIBCXX_ENABLE_SHARED AND LIBCXX_ENABLE_STATIC_ABI_LIBRARY )
# Building libcxxabi statically, but intending for it to be statically
# linked into a shared libcxx; keep dllexport enabled within libcxxabi,
# as the symbols will need to be exported from libcxx.
else ( )
# Regular static build; disable dllexports.
add_definitions ( -D_LIBCXXABI_DISABLE_VISIBILITY_ANNOTATIONS )
endif ( )
2016-09-27 11:44:09 +08:00
endif ( )
2017-06-01 08:09:20 +08:00
add_compile_flags_if_supported ( -Werror=return-type )
2014-07-04 03:35:48 +08:00
# Get warning flags
2017-06-01 08:09:20 +08:00
add_compile_flags_if_supported ( -W )
add_compile_flags_if_supported ( -Wall )
add_compile_flags_if_supported ( -Wchar-subscripts )
add_compile_flags_if_supported ( -Wconversion )
add_compile_flags_if_supported ( -Wmismatched-tags )
add_compile_flags_if_supported ( -Wmissing-braces )
add_compile_flags_if_supported ( -Wnewline-eof )
add_compile_flags_if_supported ( -Wunused-function )
add_compile_flags_if_supported ( -Wshadow )
add_compile_flags_if_supported ( -Wshorten-64-to-32 )
add_compile_flags_if_supported ( -Wsign-compare )
add_compile_flags_if_supported ( -Wsign-conversion )
add_compile_flags_if_supported ( -Wstrict-aliasing=2 )
add_compile_flags_if_supported ( -Wstrict-overflow=4 )
add_compile_flags_if_supported ( -Wunused-parameter )
add_compile_flags_if_supported ( -Wunused-variable )
add_compile_flags_if_supported ( -Wwrite-strings )
add_compile_flags_if_supported ( -Wundef )
2014-07-11 06:23:03 +08:00
2020-07-23 08:44:52 +08:00
add_compile_flags_if_supported ( -Wno-suggest-override )
2014-07-04 03:35:48 +08:00
if ( LIBCXXABI_ENABLE_WERROR )
2017-06-01 08:09:20 +08:00
add_compile_flags_if_supported ( -Werror )
add_compile_flags_if_supported ( -WX )
2014-07-04 03:35:48 +08:00
else ( )
2017-06-01 08:09:20 +08:00
add_compile_flags_if_supported ( -Wno-error )
add_compile_flags_if_supported ( -WX- )
2014-07-04 03:35:48 +08:00
endif ( )
if ( LIBCXXABI_ENABLE_PEDANTIC )
2017-06-01 08:09:20 +08:00
add_compile_flags_if_supported ( -pedantic )
2014-07-04 03:35:48 +08:00
endif ( )
# Get feature flags.
2017-06-01 08:09:20 +08:00
add_compile_flags_if_supported ( -fstrict-aliasing )
2014-07-04 03:35:48 +08:00
2016-05-31 20:01:32 +08:00
# Exceptions
if ( LIBCXXABI_ENABLE_EXCEPTIONS )
# Catches C++ exceptions only and tells the compiler to assume that extern C
# functions never throw a C++ exception.
2017-06-01 08:09:20 +08:00
add_compile_flags_if_supported ( -EHsc )
# Do we really need to be run through the C compiler ?
add_c_compile_flags_if_supported ( -funwind-tables )
2016-05-31 20:01:32 +08:00
else ( )
2017-06-01 08:09:20 +08:00
add_compile_flags_if_supported ( -fno-exceptions )
add_compile_flags_if_supported ( -EHs- )
add_compile_flags_if_supported ( -EHa- )
2016-05-31 20:01:32 +08:00
endif ( )
2015-01-22 21:39:08 +08:00
2014-07-04 03:35:48 +08:00
# Assert
string ( TOUPPER "${CMAKE_BUILD_TYPE}" uppercase_CMAKE_BUILD_TYPE )
if ( LIBCXXABI_ENABLE_ASSERTIONS )
# MSVC doesn't like _DEBUG on release builds. See PR 4379.
if ( NOT MSVC )
2014-11-19 04:37:53 +08:00
list ( APPEND LIBCXXABI_COMPILE_FLAGS -D_DEBUG )
2014-07-04 03:35:48 +08:00
endif ( )
# On Release builds cmake automatically defines NDEBUG, so we
# explicitly undefine it:
if ( uppercase_CMAKE_BUILD_TYPE STREQUAL "RELEASE" )
2014-11-19 04:37:53 +08:00
list ( APPEND LIBCXXABI_COMPILE_FLAGS -UNDEBUG )
2014-07-04 03:35:48 +08:00
endif ( )
else ( )
if ( NOT uppercase_CMAKE_BUILD_TYPE STREQUAL "RELEASE" )
2014-11-19 04:37:53 +08:00
list ( APPEND LIBCXXABI_COMPILE_FLAGS -DNDEBUG )
2014-07-04 03:35:48 +08:00
endif ( )
endif ( )
2017-01-03 20:58:34 +08:00
# Threading
2014-11-25 06:42:03 +08:00
if ( NOT LIBCXXABI_ENABLE_THREADS )
2016-05-26 01:37:38 +08:00
if ( LIBCXXABI_HAS_PTHREAD_API )
message ( FATAL_ERROR "LIBCXXABI_HAS_PTHREAD_API can only"
" b e s e t t o O N w h e n L I B C X X A B I _ E N A B L E _ T H R E A D S "
" i s a l s o s e t t o O N . " )
endif ( )
2021-03-05 22:30:13 +08:00
if ( LIBCXXABI_HAS_WIN32_THREAD_API )
message ( FATAL_ERROR "LIBCXXABI_HAS_WIN32_THREAD_API can only"
" b e s e t t o O N w h e n L I B C X X A B I _ E N A B L E _ T H R E A D S "
" i s a l s o s e t t o O N . " )
endif ( )
2017-01-03 20:58:34 +08:00
if ( LIBCXXABI_HAS_EXTERNAL_THREAD_API )
message ( FATAL_ERROR "LIBCXXABI_HAS_EXTERNAL_THREAD_API can only"
" b e s e t t o O N w h e n L I B C X X A B I _ E N A B L E _ T H R E A D S "
" i s a l s o s e t t o O N . " )
endif ( )
2017-01-09 19:57:21 +08:00
if ( LIBCXXABI_BUILD_EXTERNAL_THREAD_LIBRARY )
message ( FATAL_ERROR "LIBCXXABI_BUILD_EXTERNAL_THREAD_LIBRARY can only"
" b e s e t t o O N w h e n L I B C X X A B I _ E N A B L E _ T H R E A D S "
" i s a l s o s e t t o O N . " )
endif ( )
2016-09-21 17:09:32 +08:00
add_definitions ( -D_LIBCXXABI_HAS_NO_THREADS )
2014-11-25 06:42:03 +08:00
endif ( )
2017-01-09 19:57:21 +08:00
if ( LIBCXXABI_HAS_EXTERNAL_THREAD_API )
if ( LIBCXXABI_HAS_PTHREAD_API )
message ( FATAL_ERROR "The options LIBCXXABI_HAS_EXTERNAL_THREAD_API"
" a n d L I B C X X A B I _ H A S _ P T H R E A D _ A P I c a n n o t b e b o t h "
" s e t t o O N a t t h e s a m e t i m e . " )
endif ( )
2021-03-05 22:30:13 +08:00
if ( LIBCXXABI_HAS_WIN32_THREAD_API )
message ( FATAL_ERROR "The options LIBCXXABI_HAS_EXTERNAL_THREAD_API"
" a n d L I B C X X A B I _ H A S _ W I N 3 2 _ T H R E A D _ A P I c a n n o t b e b o t h "
" s e t t o O N a t t h e s a m e t i m e . " )
endif ( )
2017-01-09 19:57:21 +08:00
if ( LIBCXXABI_BUILD_EXTERNAL_THREAD_LIBRARY )
message ( FATAL_ERROR "The options LIBCXXABI_BUILD_EXTERNAL_THREAD_LIBRARY"
" a n d L I B C X X A B I _ H A S _ E X T E R N A L _ T H R E A D _ A P I c a n n o t b e b o t h "
" s e t t o O N a t t h e s a m e t i m e . " )
endif ( )
2017-01-03 20:58:34 +08:00
endif ( )
2021-03-05 22:30:13 +08:00
if ( LIBCXXABI_HAS_PTHREAD_API )
if ( LIBCXXABI_HAS_WIN32_THREAD_API )
message ( FATAL_ERROR "The options LIBCXXABI_HAS_PTHREAD_API"
" a n d L I B C X X A B I _ H A S _ W I N 3 2 _ T H R E A D _ A P I c a n n o t b e b o t h "
" s e t t o O N a t t h e s a m e t i m e . " )
endif ( )
endif ( )
2017-07-31 17:35:08 +08:00
if ( LLVM_ENABLE_MODULES )
# Ignore that the rest of the modules flags are now unused.
add_compile_flags_if_supported ( -Wno-unused-command-line-argument )
add_compile_flags ( -fno-modules )
endif ( )
2017-03-04 10:15:37 +08:00
set ( LIBCXXABI_HAS_UNDEFINED_SYMBOLS OFF )
if ( ( NOT LIBCXXABI_ENABLE_NEW_DELETE_DEFINITIONS )
2017-05-11 11:49:48 +08:00
OR ( LIBCXXABI_BUILD_EXTERNAL_THREAD_LIBRARY AND LIBCXXABI_ENABLE_SHARED )
O R MINGW )
2017-03-04 10:15:37 +08:00
set ( LIBCXXABI_HAS_UNDEFINED_SYMBOLS ON )
endif ( )
2017-03-03 03:34:35 +08:00
if ( LIBCXXABI_HAS_UNDEFINED_SYMBOLS )
2017-01-03 20:58:34 +08:00
# Need to allow unresolved symbols if this is to work with shared library builds
if ( APPLE )
2017-03-04 10:15:37 +08:00
list ( APPEND LIBCXXABI_LINK_FLAGS "-undefined dynamic_lookup" )
2017-01-03 20:58:34 +08:00
else ( )
# Relax this restriction from HandleLLVMOptions
string ( REPLACE "-Wl,-z,defs" "" CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS}" )
endif ( )
endif ( )
2016-05-26 01:37:38 +08:00
if ( LIBCXXABI_HAS_PTHREAD_API )
add_definitions ( -D_LIBCPP_HAS_THREAD_API_PTHREAD )
endif ( )
2021-03-05 22:30:13 +08:00
if ( LIBCXXABI_HAS_WIN32_THREAD_API )
add_definitions ( -D_LIBCPP_HAS_THREAD_API_WIN32 )
endif ( )
2017-01-03 20:58:34 +08:00
if ( LIBCXXABI_HAS_EXTERNAL_THREAD_API )
2017-01-09 19:57:21 +08:00
add_definitions ( -D_LIBCPP_HAS_THREAD_API_EXTERNAL )
endif ( )
if ( LIBCXXABI_BUILD_EXTERNAL_THREAD_LIBRARY )
add_definitions ( -D_LIBCPP_HAS_THREAD_LIBRARY_EXTERNAL )
2017-01-03 20:58:34 +08:00
endif ( )
2017-05-11 05:52:39 +08:00
# Prevent libc++abi from having library dependencies on libc++
add_definitions ( -D_LIBCPP_DISABLE_EXTERN_TEMPLATE )
2014-07-04 03:35:48 +08:00
if ( MSVC )
add_definitions ( -D_CRT_SECURE_NO_WARNINGS )
endif ( )
2015-01-22 21:27:36 +08:00
# Define LIBCXXABI_USE_LLVM_UNWINDER for conditional compilation.
2016-11-13 22:42:15 +08:00
if ( LIBCXXABI_USE_LLVM_UNWINDER )
2017-03-01 19:42:01 +08:00
add_definitions ( -DLIBCXXABI_USE_LLVM_UNWINDER )
2015-01-22 21:27:36 +08:00
endif ( )
2017-01-14 03:22:26 +08:00
if ( LIBCXXABI_SILENT_TERMINATE )
2017-03-01 19:42:01 +08:00
add_definitions ( -DLIBCXXABI_SILENT_TERMINATE )
endif ( )
2021-01-22 05:27:14 +08:00
if ( LIBCXXABI_NON_DEMANGLING_TERMINATE )
add_definitions ( -DLIBCXXABI_NON_DEMANGLING_TERMINATE )
endif ( )
2017-03-01 19:42:01 +08:00
if ( LIBCXXABI_BAREMETAL )
add_definitions ( -DLIBCXXABI_BAREMETAL )
2017-01-14 03:22:26 +08:00
endif ( )
2019-05-30 12:40:21 +08:00
if ( LIBCXXABI_HAS_COMMENT_LIB_PRAGMA )
2019-12-02 18:49:20 +08:00
if ( LIBCXXABI_HAS_PTHREAD_LIB )
add_definitions ( -D_LIBCXXABI_LINK_PTHREAD_LIB )
endif ( )
2019-05-30 12:40:21 +08:00
endif ( )
2014-11-19 04:37:53 +08:00
string ( REPLACE ";" " " LIBCXXABI_CXX_FLAGS "${LIBCXXABI_CXX_FLAGS}" )
set ( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${LIBCXXABI_CXX_FLAGS}" )
2015-01-22 21:39:08 +08:00
set ( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${LIBCXXABI_C_FLAGS}" )
2014-07-04 03:35:48 +08:00
2021-11-10 01:44:44 +08:00
# On AIX, avoid picking up VMX extensions(i.e. vec_malloc) which would change
# the default alignment of the allocators here.
if ( UNIX AND ${ CMAKE_SYSTEM_NAME } MATCHES "AIX" )
add_definitions ( "-D_XOPEN_SOURCE=700" )
endif ( )
2014-07-04 03:35:48 +08:00
#===============================================================================
# Setup Source Code
#===============================================================================
2015-05-09 00:10:11 +08:00
set ( LIBCXXABI_LIBUNWIND_INCLUDES "${LIBCXXABI_LIBUNWIND_INCLUDES}" CACHE PATH
" S p e c i f y p a t h t o l i b u n w i n d i n c l u d e s . " F O R C E )
set ( LIBCXXABI_LIBUNWIND_PATH "${LIBCXXABI_LIBUNWIND_PATH}" CACHE PATH
" S p e c i f y p a t h t o l i b u n w i n d s o u r c e . " F O R C E )
2014-07-04 03:35:48 +08:00
include_directories ( include )
2015-04-29 23:53:03 +08:00
if ( LIBCXXABI_USE_LLVM_UNWINDER OR LLVM_NATIVE_ARCH MATCHES ARM )
2019-05-03 01:29:39 +08:00
find_path ( LIBCXXABI_LIBUNWIND_INCLUDES_INTERNAL libunwind.h
2015-05-09 00:10:11 +08:00
P A T H S $ { L I B C X X A B I _ L I B U N W I N D _ I N C L U D E S }
$ { L I B C X X A B I _ L I B U N W I N D _ P A T H } / i n c l u d e
$ { C M A K E _ B I N A R Y _ D I R } / $ { L I B C X X A B I _ L I B U N W I N D _ I N C L U D E S }
$ { L L V M _ M A I N _ S R C _ D I R } / p r o j e c t s / l i b u n w i n d / i n c l u d e
2016-11-12 03:12:58 +08:00
$ { L L V M _ M A I N _ S R C _ D I R } / r u n t i m e s / l i b u n w i n d / i n c l u d e
2018-04-05 01:40:59 +08:00
$ { L L V M _ M A I N _ S R C _ D I R } / . . / l i b u n w i n d / i n c l u d e
2015-05-10 05:03:01 +08:00
N O _ D E F A U L T _ P A T H
2018-01-23 03:41:05 +08:00
N O _ C M A K E _ F I N D _ R O O T _ P A T H
2015-05-09 00:10:11 +08:00
)
2017-04-04 22:03:54 +08:00
if ( LIBCXXABI_LIBUNWIND_INCLUDES_INTERNAL STREQUAL "LIBCXXABI_LIBUNWIND_INCLUDES_INTERNAL-NOTFOUND" )
set ( LIBCXXABI_LIBUNWIND_INCLUDES_INTERNAL "" )
endif ( )
if ( NOT LIBCXXABI_LIBUNWIND_INCLUDES_INTERNAL STREQUAL "" )
2017-01-15 01:05:16 +08:00
include_directories ( "${LIBCXXABI_LIBUNWIND_INCLUDES_INTERNAL}" )
endif ( )
2016-08-09 01:59:02 +08:00
endif ( )
2014-07-04 03:35:48 +08:00
# Add source code. This also contains all of the logic for deciding linker flags
# soname, etc...
add_subdirectory ( src )
2014-07-10 10:20:11 +08:00
2018-01-19 02:29:36 +08:00
if ( LIBCXXABI_INCLUDE_TESTS )
2020-08-24 17:01:05 +08:00
add_subdirectory ( test )
add_subdirectory ( fuzz )
2014-07-10 10:20:11 +08:00
endif ( )