From e5fd86f9c8a90b063a53611576afb6bcdcac4327 Mon Sep 17 00:00:00 2001 From: Mika Rautio Date: Mon, 20 Nov 2017 19:23:15 +0200 Subject: [PATCH] Add support for building with Apple LLVM clang version < 8.0 (#82) * Add support for building with pre 2016 Apple LLVM clang * Automatically detect Apple clang that do not support thread_local * Clarify clang thread_local support code comment --- CMakeLists.txt | 2 +- easy_profiler_core/CMakeLists.txt | 4 ++++ easy_profiler_core/include/easy/easy_compiler_support.h | 4 ++-- easy_profiler_core/nonscoped_block.cpp | 3 ++- easy_profiler_core/stack_buffer.h | 1 + 5 files changed, 10 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 8b71367..4fe44a4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 2.8.12.1) +cmake_minimum_required(VERSION 3.0) project(easy_profiler CXX) set_property(GLOBAL PROPERTY USE_FOLDERS ON) diff --git a/easy_profiler_core/CMakeLists.txt b/easy_profiler_core/CMakeLists.txt index 4b87e79..17f405c 100644 --- a/easy_profiler_core/CMakeLists.txt +++ b/easy_profiler_core/CMakeLists.txt @@ -15,6 +15,10 @@ if (NOT WIN32) if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS "3.3") set(NO_CXX11_THREAD_LOCAL_SUPPORT TRUE) endif () + elseif (CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang") + if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS "8.0") + set(NO_CXX11_THREAD_LOCAL_SUPPORT TRUE) + endif () endif () # TODO: Check thread_local keyword support for other compilers for Unix diff --git a/easy_profiler_core/include/easy/easy_compiler_support.h b/easy_profiler_core/include/easy/easy_compiler_support.h index 41b667e..7f9719b 100644 --- a/easy_profiler_core/include/easy/easy_compiler_support.h +++ b/easy_profiler_core/include/easy/easy_compiler_support.h @@ -88,8 +88,8 @@ ////////////////////////////////////////////////////////////////////////// // Clang Compiler -# if (__clang_major__ == 3 && __clang_minor__ < 3) || (__clang_major__ < 3) -// There is no support for C++11 thread_local keyword prior to clang 3.3. Use __thread instead. +# if (__clang_major__ == 3 && __clang_minor__ < 3) || (__clang_major__ < 3) || (defined __APPLE_CC__ && __APPLE_CC__ < 8000) +// There is no support for C++11 thread_local keyword prior to clang 3.3 and Apple LLVM clang 8.0. Use __thread instead. # define EASY_THREAD_LOCAL __thread # endif diff --git a/easy_profiler_core/nonscoped_block.cpp b/easy_profiler_core/nonscoped_block.cpp index f94ae51..6fa5d77 100644 --- a/easy_profiler_core/nonscoped_block.cpp +++ b/easy_profiler_core/nonscoped_block.cpp @@ -41,7 +41,8 @@ The Apache License, Version 2.0 (the "License"); **/ #include "nonscoped_block.h" -#include +#include +#include NonscopedBlock::NonscopedBlock(const profiler::BaseBlockDescriptor* _desc, const char* _runtimeName, bool) : profiler::Block(_desc, _runtimeName, false), m_runtimeName(nullptr) diff --git a/easy_profiler_core/stack_buffer.h b/easy_profiler_core/stack_buffer.h index b3bc4d3..1425887 100644 --- a/easy_profiler_core/stack_buffer.h +++ b/easy_profiler_core/stack_buffer.h @@ -46,6 +46,7 @@ The Apache License, Version 2.0 (the "License"); #include "nonscoped_block.h" #include #include +#include #ifdef max #undef max