From 2c7befce02e6a7d277c948ddc91055850c636805 Mon Sep 17 00:00:00 2001 From: anonimal Date: Sat, 16 Feb 2019 01:44:59 +0000 Subject: [PATCH 1/2] CMake: add Clang support for Linux --- CMakeLists.txt | 19 ++++++++++++------- contrib/db/CMakeLists.txt | 4 ++-- src/CMakeLists.txt | 2 +- 3 files changed, 15 insertions(+), 10 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 911d69c1..6adb8998 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -45,6 +45,10 @@ if (UNIX AND NOT APPLE) find_package(Threads REQUIRED) endif() +# TODO(unassigned): expand on types and versions, and then refactor. +if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang") + set(CLANG TRUE) +endif() if(MSVC) add_definitions("/bigobj /Zm1000 /Z7 /MP /W3 /GS- /D_CRT_SECURE_NO_WARNINGS /wd4996 /wd4503 /wd4345 /wd4091 /D_WIN32_WINNT=0x0600 /DWIN32_LEAN_AND_MEAN /DGTEST_HAS_TR1_TUPLE=0 /FIinline_c.h /D__SSE4_1__") @@ -66,7 +70,6 @@ else() # if(NOT APPLE) # set(WARNINGS "${WARNINGS} -Werror") # endif() - if(CMAKE_C_COMPILER_ID STREQUAL "Clang") set(WARNINGS "${WARNINGS} -Wno-shift-count-overflow -Wno-error=mismatched-tags -Wno-error=null-conversion -Wno-overloaded-shift-op-parentheses -Wno-error=shift-count-overflow -Wno-error=tautological-constant-out-of-range-compare -Wno-error=unused-private-field -Wno-error=unneeded-internal-declaration") else() @@ -103,13 +106,15 @@ else() else() set(STATIC_ASSERT_FLAG "-Dstatic_assert=_Static_assert") endif() - set(LINUX_LD_GOLD "") - set(LINUX_STATIC_ICU "") - if((NOT APPLE) AND (NOT MSVC)) - set(LINUX_LD_GOLD "-fuse-ld=gold") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c11 -D_GNU_SOURCE ${MINGW_FLAG} ${STATIC_ASSERT_FLAG} ${WARNINGS} ${C_WARNINGS} ${ARCH_FLAG}") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fpermissive -ftemplate-depth-1024 -std=c++11 -D_GNU_SOURCE ${APPLE_FLAG} ${MINGW_FLAG} ${WARNINGS} ${CXX_WARNINGS} ${ARCH_FLAG}") + if (NOT APPLE AND NOT MSVC) + if (CLANG) + set(LLVM_USE_LINKER "gold") + else() + set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fuse-ld=gold") + endif() endif() - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${LINUX_LD_GOLD} -std=c11 -D_GNU_SOURCE ${MINGW_FLAG} ${STATIC_ASSERT_FLAG} ${WARNINGS} ${C_WARNINGS} ${ARCH_FLAG}") - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${LINUX_LD_GOLD} -fpermissive -ftemplate-depth-1024 -std=c++11 -D_GNU_SOURCE ${APPLE_FLAG} ${MINGW_FLAG} ${WARNINGS} ${CXX_WARNINGS} ${ARCH_FLAG}") if(CMAKE_C_COMPILER_ID STREQUAL "GNU" AND NOT (CMAKE_C_COMPILER_VERSION VERSION_LESS 4.8)) set(DEBUG_FLAGS "-g3 -O0") #set(DEBUG_FLAGS "-g3 -Og") else() diff --git a/contrib/db/CMakeLists.txt b/contrib/db/CMakeLists.txt index bdd4381b..eb5c8415 100644 --- a/contrib/db/CMakeLists.txt +++ b/contrib/db/CMakeLists.txt @@ -2,6 +2,6 @@ add_subdirectory(liblmdb) if(MSVC) target_compile_options(lmdb PRIVATE /wd4996 /wd4503 /wd4345 /wd4267 /wd4244 /wd4146 /wd4333 /wd4172) else() - target_compile_options(lmdb PRIVATE -Wno-discarded-qualifiers -Wno-empty-body -Wno-unused-but-set-variable) + # Warnings as used by LMDB itself (LMDB_0.9.23) + target_compile_options(lmdb PRIVATE -Wall -Wno-unused-parameter -Wbad-function-cast -Wuninitialized) endif() - diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 44941fc2..85cb0d56 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -92,7 +92,7 @@ add_library(common ${COMMON}) add_dependencies(common version ${PCH_LIB_NAME}) ENABLE_SHARED_PCH(COMMON) -if(NOT MSVC AND NOT APPLE) +if(NOT MSVC AND NOT APPLE AND NOT CLANG) # TODO(unassigned): do we really need the clang equivalent? target_compile_options(common PRIVATE -fno-var-tracking-assignments) endif() From 4997f1f9136f314155a8cad11e26762393804830 Mon Sep 17 00:00:00 2001 From: anonimal Date: Sat, 16 Feb 2019 01:48:21 +0000 Subject: [PATCH 2/2] README: update compiler type and version support --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index ee524731..8d8c7a58 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,8 @@ Building ### Dependencies | component / version | minimum
(not recommended but may work) | recommended | most recent of what we have ever tested | |--|--|--|--| -| gcc (Linux) | 5.4.0 | 7.2.0 | 7.2.0 | +| gcc (Linux) | 5.4.0 | 7.2.0 | 8.2.1 | +| llvm/clang (Linux) | UNKNOWN | 7.0.1 | 7.0.1 | | [MSVC](https://visualstudio.microsoft.com/downloads/) (Windows) | 2015 (14.0 update 1) | 2015 (14.0 update 3) | 2017 (15.5.7) | | [XCode](https://developer.apple.com/downloads/) (macOS) | 7.3.1 | 9.2 | 9.2 | | [CMake](https://cmake.org/download/) | 2.8.6 | 3.4.1 | 3.11.0 |