add_definitions(-D_LIBCPP_DISABLE_NEW_DELETE_DEFINITIONS)
endif()
+if (LIBCXX_HAS_COMMENT_LIB_PRAGMA)
+ add_definitions(-D_LIBCPP_HAS_COMMENT_LIB_PRAGMA)
+endif()
+
# Warning flags ===============================================================
add_definitions(-D_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
add_compile_flags_if_supported(
include(CheckLibraryExists)
include(CheckCCompilerFlag)
include(CheckCXXCompilerFlag)
+include(CheckCSourceCompiles)
if(WIN32 AND NOT MINGW)
# NOTE(compnerd) this is technically a lie, there is msvcrt, but for now, lets
endif ()
endif ()
+# Check compiler pragmas
+if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
+ check_c_source_compiles("
+#pragma comment(lib, \"c\")
+int main() { return 0; }
+" LIBCXX_HAS_COMMENT_LIB_PRAGMA)
+endif()
+
if(NOT WIN32 OR MINGW)
include(CheckLibcxxAtomic)
endif()
check_cxx_compiler_flag(/EHa- LIBCXX_HAS_NO_EHA_FLAG)
check_cxx_compiler_flag(/GR- LIBCXX_HAS_NO_GR_FLAG)
-
# Check libraries
if(WIN32 AND NOT MINGW)
# TODO(compnerd) do we want to support an emulation layer that allows for the
#include "random"
#ifndef _LIBCPP_HAS_NO_THREADS
#include "mutex"
-#if defined(__unix__) && defined(__ELF__) && defined(__clang__)
+#if defined(__unix__) && defined(__ELF__) && defined(_LIBCPP_HAS_COMMENT_LIB_PRAGMA)
#pragma comment(lib, "pthread")
#endif
#endif
#endif
#endif
-#if defined(__unix__) && defined(__ELF__) && defined(__clang__)
+#if defined(__unix__) && defined(__ELF__) && defined(_LIBCPP_HAS_COMMENT_LIB_PRAGMA)
#pragma comment(lib, "rt")
#endif
#include "__hash_table"
#ifndef _LIBCPP_HAS_NO_THREADS
#include "mutex"
-#if defined(__unix__) && defined(__ELF__) && defined(__clang__)
+#if defined(__unix__) && defined(__ELF__) && defined(_LIBCPP_HAS_COMMENT_LIB_PRAGMA)
#pragma comment(lib, "pthread")
#endif
#endif
#include "atomic"
#elif !defined(_LIBCPP_HAS_NO_THREADS)
#include "mutex"
-#if defined(__unix__) && defined(__ELF__) && defined(__clang__)
+#if defined(__unix__) && defined(__ELF__) && defined(_LIBCPP_HAS_COMMENT_LIB_PRAGMA)
#pragma comment(lib, "pthread")
#endif
#endif
#include <sys/time.h> // for gettimeofday and timeval
#endif // !defined(CLOCK_REALTIME)
-#if defined(__unix__) && defined(__ELF__) && defined(__clang__)
+#if defined(__unix__) && defined(__ELF__) && defined(_LIBCPP_HAS_COMMENT_LIB_PRAGMA)
#pragma comment(lib, "rt")
#endif
#include "__undef_macros"
#ifndef _LIBCPP_HAS_NO_THREADS
-#if defined(__unix__) && defined(__ELF__) && defined(__clang__)
+#if defined(__unix__) && defined(__ELF__) && defined(_LIBCPP_HAS_COMMENT_LIB_PRAGMA)
#pragma comment(lib, "pthread")
#endif
#endif
#ifndef _LIBCPP_HAS_NO_THREADS
#include "shared_mutex"
-#if defined(__unix__) && defined(__ELF__) && defined(__clang__)
+#if defined(__unix__) && defined(__ELF__) && defined(_LIBCPP_HAS_COMMENT_LIB_PRAGMA)
#pragma comment(lib, "pthread")
#endif
#include <windows.h>
#endif
-#if defined(__unix__) && defined(__ELF__) && defined(__clang__)
+#if defined(__unix__) && defined(__ELF__) && defined(_LIBCPP_HAS_COMMENT_LIB_PRAGMA)
#pragma comment(lib, "pthread")
#endif
add_definitions(-DLIBCXXABI_BAREMETAL)
endif()
+if (LIBCXXABI_HAS_COMMENT_LIB_PRAGMA)
+ add_definitions(-D_LIBCXXABI_HAS_COMMENT_LIB_PRAGMA)
+endif()
+
string(REPLACE ";" " " LIBCXXABI_CXX_FLAGS "${LIBCXXABI_CXX_FLAGS}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${LIBCXXABI_CXX_FLAGS}")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${LIBCXXABI_C_FLAGS}")
include(CheckLibraryExists)
include(CheckCCompilerFlag)
include(CheckCXXCompilerFlag)
+include(CheckCSourceCompiles)
check_library_exists(c fopen "" LIBCXXABI_HAS_C_LIB)
if (NOT LIBCXXABI_USE_COMPILER_RT)
endif ()
endif ()
+# Check compiler pragmas
+if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
+ check_c_source_compiles("
+#pragma comment(lib, \"c\")
+int main() { return 0; }
+" LIBCXXABI_HAS_COMMENT_LIB_PRAGMA)
+endif()
+
# Check compiler flags
check_c_compiler_flag(-funwind-tables LIBCXXABI_HAS_FUNWIND_TABLES)
check_cxx_compiler_flag(-fno-exceptions LIBCXXABI_HAS_NO_EXCEPTIONS_FLAG)
#include "abort_message.h"
#include "fallback_malloc.h"
+#if defined(__unix__) && defined(__ELF__) && defined(_LIBCXXABI_HAS_COMMENT_LIB_PRAGMA)
+#pragma comment(lib, "pthread")
+#endif
+
// In general, we treat all threading errors as fatal.
// We cannot call std::terminate() because that will in turn
// call __cxa_get_globals() and cause infinite recursion.
#include <stdlib.h>
#include <__threading_support>
#ifndef _LIBCXXABI_HAS_NO_THREADS
-#if defined(__unix__) && defined(__ELF__) && defined(__clang__)
+#if defined(__unix__) && defined(__ELF__) && defined(_LIBCXXABI_HAS_COMMENT_LIB_PRAGMA)
#pragma comment(lib, "pthread")
#endif
#endif
#include "cxxabi.h"
#include <__threading_support>
#ifndef _LIBCXXABI_HAS_NO_THREADS
-#if defined(__unix__) && defined(__ELF__) && defined(__clang__)
+#if defined(__unix__) && defined(__ELF__) && defined(_LIBCXXABI_HAS_COMMENT_LIB_PRAGMA)
#pragma comment(lib, "pthread")
#endif
#endif
#include <__threading_support>
#ifndef _LIBCXXABI_HAS_NO_THREADS
-#if defined(__unix__) && defined(__ELF__) && defined(__clang__)
+#if defined(__unix__) && defined(__ELF__) && defined(_LIBCXXABI_HAS_COMMENT_LIB_PRAGMA)
#pragma comment(lib, "pthread")
#endif
#endif
add_definitions(-D_LIBUNWIND_DISABLE_VISIBILITY_ANNOTATIONS)
endif()
+if (LIBUNWIND_HAS_COMMENT_LIB_PRAGMA)
+ add_definitions(-D_LIBUNWIND_HAS_COMMENT_LIB_PRAGMA)
+endif()
+
#===============================================================================
# Setup Source Code
#===============================================================================
-
include(CheckCCompilerFlag)
include(CheckCXXCompilerFlag)
include(CheckLibraryExists)
+include(CheckCSourceCompiles)
check_library_exists(c fopen "" LIBUNWIND_HAS_C_LIB)
endif ()
endif ()
+# Check compiler pragmas
+if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
+ check_c_source_compiles("
+#pragma comment(lib, \"c\")
+int main() { return 0; }
+" LIBUNWIND_HAS_COMMENT_LIB_PRAGMA)
+endif()
+
# Check compiler flags
check_c_compiler_flag(-funwind-tables LIBUNWIND_HAS_FUNWIND_TABLES)
check_cxx_compiler_flag(-fno-exceptions LIBUNWIND_HAS_NO_EXCEPTIONS_FLAG)
check_library_exists(dl dladdr "" LIBUNWIND_HAS_DL_LIB)
check_library_exists(pthread pthread_once "" LIBUNWIND_HAS_PTHREAD_LIB)
-
#if _LIBUNWIND_USE_DLADDR
#include <dlfcn.h>
-#if defined(__unix__) && defined(__ELF__) && defined(__clang__)
+#if defined(__unix__) && defined(__ELF__) && defined(_LIBUNWIND_HAS_COMMENT_LIB_PRAGMA)
#pragma comment(lib, "dl")
#endif
#endif
#include <windows.h>
#elif !defined(_LIBUNWIND_HAS_NO_THREADS)
#include <pthread.h>
-#if defined(__unix__) && defined(__ELF__) && defined(__clang__)
+#if defined(__unix__) && defined(__ELF__) && defined(_LIBUNWIND_HAS_COMMENT_LIB_PRAGMA)
#pragma comment(lib, "pthread")
#endif
#endif