2014-02-05 08:02:37 +08:00
|
|
|
# This CMake module is responsible for setting the standard library to libc++
|
|
|
|
# if the user has requested it.
|
|
|
|
|
2015-09-29 22:33:58 +08:00
|
|
|
include(DetermineGCCCompatible)
|
|
|
|
|
2014-02-05 08:02:37 +08:00
|
|
|
if(NOT DEFINED LLVM_STDLIB_HANDLED)
|
|
|
|
set(LLVM_STDLIB_HANDLED ON)
|
|
|
|
|
2015-03-07 18:30:34 +08:00
|
|
|
function(append value)
|
|
|
|
foreach(variable ${ARGN})
|
|
|
|
set(${variable} "${${variable}} ${value}" PARENT_SCOPE)
|
|
|
|
endforeach(variable)
|
2014-02-05 08:02:37 +08:00
|
|
|
endfunction()
|
|
|
|
|
|
|
|
include(CheckCXXCompilerFlag)
|
2021-04-03 14:51:17 +08:00
|
|
|
include(LLVMCheckLinkerFlag)
|
Add libc++ to link XRay test cases if libc++ is used to build CLANG
Summary: When libc++ is used to build CLANG, its XRay libraries libclang_rt.xray-*.a have dependencies on libc++. Therefore, libc++ is needed to link and run XRay test cases. For Linux -rpath is also needed to specify where to load libc++. This change sets macro LLVM_LIBCXX_USED to 1 if libc++ is actually used in the build. XRay tests then check the flag and add -L<llvm_shlib_dir> -lc++ and -Wl,-rpath=<llvm_shlib_dir> if needed.
Reviewers: hubert.reinterpretcast, amyk, dberris, jasonliu, sfertile, EricWF
Subscribers: dberris, mgorny, jsji, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D61016
llvm-svn: 360060
2019-05-07 01:45:21 +08:00
|
|
|
set(LLVM_LIBCXX_USED 0)
|
2014-02-05 08:02:37 +08:00
|
|
|
if(LLVM_ENABLE_LIBCXX)
|
|
|
|
if(LLVM_COMPILER_IS_GCC_COMPATIBLE)
|
2018-04-25 03:47:39 +08:00
|
|
|
check_cxx_compiler_flag("-stdlib=libc++" CXX_COMPILER_SUPPORTS_STDLIB)
|
2021-04-03 14:51:17 +08:00
|
|
|
llvm_check_linker_flag(CXX "-stdlib=libc++" CXX_LINKER_SUPPORTS_STDLIB)
|
2018-04-25 03:47:39 +08:00
|
|
|
if(CXX_COMPILER_SUPPORTS_STDLIB AND CXX_LINKER_SUPPORTS_STDLIB)
|
2015-03-07 18:30:34 +08:00
|
|
|
append("-stdlib=libc++"
|
|
|
|
CMAKE_CXX_FLAGS CMAKE_EXE_LINKER_FLAGS CMAKE_SHARED_LINKER_FLAGS
|
|
|
|
CMAKE_MODULE_LINKER_FLAGS)
|
Add libc++ to link XRay test cases if libc++ is used to build CLANG
Summary: When libc++ is used to build CLANG, its XRay libraries libclang_rt.xray-*.a have dependencies on libc++. Therefore, libc++ is needed to link and run XRay test cases. For Linux -rpath is also needed to specify where to load libc++. This change sets macro LLVM_LIBCXX_USED to 1 if libc++ is actually used in the build. XRay tests then check the flag and add -L<llvm_shlib_dir> -lc++ and -Wl,-rpath=<llvm_shlib_dir> if needed.
Reviewers: hubert.reinterpretcast, amyk, dberris, jasonliu, sfertile, EricWF
Subscribers: dberris, mgorny, jsji, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D61016
llvm-svn: 360060
2019-05-07 01:45:21 +08:00
|
|
|
set(LLVM_LIBCXX_USED 1)
|
2015-03-07 18:30:34 +08:00
|
|
|
else()
|
|
|
|
message(WARNING "Can't specify libc++ with '-stdlib='")
|
|
|
|
endif()
|
2014-02-05 08:02:37 +08:00
|
|
|
else()
|
|
|
|
message(WARNING "Not sure how to specify libc++ for this compiler")
|
|
|
|
endif()
|
|
|
|
endif()
|
2019-08-15 03:55:59 +08:00
|
|
|
|
|
|
|
if(LLVM_STATIC_LINK_CXX_STDLIB)
|
|
|
|
if(LLVM_COMPILER_IS_GCC_COMPATIBLE)
|
|
|
|
check_cxx_compiler_flag("-static-libstdc++"
|
|
|
|
CXX_COMPILER_SUPPORTS_STATIC_STDLIB)
|
2021-04-03 14:51:17 +08:00
|
|
|
llvm_check_linker_flag(CXX "-static-libstdc++" CXX_LINKER_SUPPORTS_STATIC_STDLIB)
|
2019-08-15 03:55:59 +08:00
|
|
|
if(CXX_COMPILER_SUPPORTS_STATIC_STDLIB AND
|
|
|
|
CXX_LINKER_SUPPORTS_STATIC_STDLIB)
|
|
|
|
append("-static-libstdc++"
|
|
|
|
CMAKE_EXE_LINKER_FLAGS CMAKE_SHARED_LINKER_FLAGS
|
|
|
|
CMAKE_MODULE_LINKER_FLAGS)
|
|
|
|
else()
|
|
|
|
message(WARNING
|
|
|
|
"Can't specify static linking for the C++ standard library")
|
|
|
|
endif()
|
|
|
|
else()
|
|
|
|
message(WARNING "Not sure how to specify static linking of C++ standard "
|
|
|
|
"library for this compiler")
|
|
|
|
endif()
|
|
|
|
endif()
|
2014-02-05 08:02:37 +08:00
|
|
|
endif()
|