From b794b3606f86cb7ef6d78e29f507af3436281954 Mon Sep 17 00:00:00 2001 From: Fangrui Song Date: Thu, 23 Aug 2018 15:18:15 -0700 Subject: [PATCH] Add LLVM_ENABLE_RTTI (default: OFF) to allow linking against Arch Linux extra/{llvm,clang} (-DLLVM_ENABLE_RTTI=ON) --- CMakeLists.txt | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index faa640b1..b202db78 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -10,6 +10,7 @@ set(CLANG_DOWNLOAD_LOCATION ${CMAKE_BINARY_DIR} option(SYSTEM_CLANG "Use system installation of Clang instead of \ downloading Clang" 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(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) endif() -# To link against LLVM libraries (usually compiled with -fno-rtti) -target_compile_options(ccls PRIVATE -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) +endif() # CMake sets MSVC for both MSVC and Clang(Windows) if(MSVC)