diff options
author | Zbigniew Sarbinowski <zibi@ca.ibm.com> | 2021-02-16 18:02:22 +0000 |
---|---|---|
committer | Zbigniew Sarbinowski <zibi@ca.ibm.com> | 2021-02-16 18:42:14 +0000 |
commit | 5f9be2c3e37c0428ba56876dd84af04b8d9d8915 (patch) | |
tree | 41df36f6b4ce0362390396f1a85dd3f3f420c67e /libunwind/cmake | |
parent | 6c05005238a805a699d9dec39a61971affd1cab4 (diff) | |
download | llvm-5f9be2c3e37c0428ba56876dd84af04b8d9d8915.tar.gz |
[SystemZ][ZOS] Prefer -nostdlib++ as opposed to -nodefaultlibs when building c++ libraries
Let's use -nostdlib++ rather than -nodefaultlibs when building libc++/libc++abi/libunwind libraries. The default is -nostdlib++ if supported by a build compiler like it is the case with clang, otherwise -nodefaultlibs is used as before.
This change is needed to avoid additional changes at the link step and not to increase the maintenance costs. If clang with -nodefaultlibs is used all the libraries which are removed but required would have to be manually added in. This set of libraries are unique and will send out.
The propose change will allow to make the link step simple for other platforms as well.
Reviewed By: #libc, #libc_abi, ldionne
Differential Revision: https://reviews.llvm.org/D95875
Diffstat (limited to 'libunwind/cmake')
-rw-r--r-- | libunwind/cmake/config-ix.cmake | 24 |
1 files changed, 17 insertions, 7 deletions
diff --git a/libunwind/cmake/config-ix.cmake b/libunwind/cmake/config-ix.cmake index 3e42818882b3..4ca6bdd8e95d 100644 --- a/libunwind/cmake/config-ix.cmake +++ b/libunwind/cmake/config-ix.cmake @@ -16,16 +16,26 @@ if (NOT LIBUNWIND_USE_COMPILER_RT) endif () endif() -# libunwind is built with -nodefaultlibs, so we want all our checks to also -# use this option, otherwise we may end up with an inconsistency between +# libunwind is using -nostdlib++ at the link step when available, +# otherwise -nodefaultlibs is used. We want all our checks to also +# use one of these options, otherwise we may end up with an inconsistency between # the flags we think we require during configuration (if the checks are -# performed without -nodefaultlibs) and the flags that are actually -# required during compilation (which has the -nodefaultlibs). libc is +# performed without one of those options) and the flags that are actually +# required during compilation (which has the -nostdlib++ or -nodefaultlibs). libc is # required for the link to go through. We remove sanitizers from the # configuration checks to avoid spurious link errors. -check_c_compiler_flag(-nodefaultlibs LIBUNWIND_HAS_NODEFAULTLIBS_FLAG) -if (LIBUNWIND_HAS_NODEFAULTLIBS_FLAG) - set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -nodefaultlibs") + +check_c_compiler_flag(-nostdlib++ LIBUNWIND_SUPPORTS_NOSTDLIBXX_FLAG) +if (LIBUNWIND_SUPPORTS_NOSTDLIBXX_FLAG) + set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -nostdlib++") +else() + check_c_compiler_flag(-nodefaultlibs LIBUNWIND_SUPPORTS_NODEFAULTLIBS_FLAG) + if (LIBUNWIND_SUPPORTS_NODEFAULTLIBS_FLAG) + set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -nodefaultlibs") + endif() +endif() + +if (LIBUNWIND_SUPPORTS_NOSTDLIBXX_FLAG OR LIBUNWIND_SUPPORTS_NODEFAULTLIBS_FLAG) if (LIBUNWIND_HAS_C_LIB) list(APPEND CMAKE_REQUIRED_LIBRARIES c) endif () |