Add LLVM_ENABLE_RTTI (default: OFF) to allow linking against Arch Linux extra/{llvm,clang} (-DLLVM_ENABLE_RTTI=ON)

This commit is contained in:
Fangrui Song 2018-08-23 15:18:15 -07:00
parent ec2b893ee4
commit 48c92c05a1

View File

@ -10,6 +10,7 @@ set(CLANG_DOWNLOAD_LOCATION ${CMAKE_BINARY_DIR}
option(SYSTEM_CLANG "Use system installation of Clang instead of \ option(SYSTEM_CLANG "Use system installation of Clang instead of \
downloading Clang" OFF) downloading Clang" OFF)
option(ASAN "Compile with address sanitizers" OFF) option(ASAN "Compile with address sanitizers" OFF)
option(LLVM_ENABLE_RTTI "-fno-rtti if OFF. This should match LLVM libraries" OFF)
option(CLANG_USE_BUNDLED_LIBC++ "Let Clang use bundled libc++" OFF) option(CLANG_USE_BUNDLED_LIBC++ "Let Clang use bundled libc++" OFF)
option(USE_SHARED_LLVM "Link against libLLVM.so instead separate LLVM{Option,Support,...}" OFF) option(USE_SHARED_LLVM "Link against libLLVM.so instead separate LLVM{Option,Support,...}" OFF)
@ -34,8 +35,12 @@ if(NOT CYGWIN)
set_property(TARGET ccls PROPERTY CXX_EXTENSIONS OFF) set_property(TARGET ccls PROPERTY CXX_EXTENSIONS OFF)
endif() endif()
# To link against LLVM libraries (usually compiled with -fno-rtti) if(NOT LLVM_ENABLE_RTTI)
# releases.llvm.org libraries are compiled with -fno-rtti
# The mismatch between lib{clang,LLVM}* and ccls can make libstdc++ std::make_shared return nullptr
# _Sp_counted_ptr_inplace::_M_get_deleter
target_compile_options(ccls PRIVATE -fno-rtti) target_compile_options(ccls PRIVATE -fno-rtti)
endif()
# CMake sets MSVC for both MSVC and Clang(Windows) # CMake sets MSVC for both MSVC and Clang(Windows)
if(MSVC) if(MSVC)