Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 5 additions & 20 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ endif

RDYNAMIC?=-rdynamic
# Set the CPPCHK_GLIBCXX_DEBUG flag. This flag is not used in release Makefiles.
# The _GLIBCXX_DEBUG define doesn't work in Cygwin or other Win32 systems.
ifndef COMSPEC
ifeq ($(VERBOSE),1)
$(info COMSPEC not found)
Expand Down Expand Up @@ -74,10 +73,7 @@ ifdef WINNT
ifeq ($(VERBOSE),1)
$(info WINNT found)
endif
#### Maybe Windows
ifndef CPPCHK_GLIBCXX_DEBUG
CPPCHK_GLIBCXX_DEBUG=
endif # !CPPCHK_GLIBCXX_DEBUG
#### May be Windows

ifeq ($(VERBOSE),1)
$(info MSYSTEM=$(MSYSTEM))
Expand All @@ -99,22 +95,14 @@ else # !WINNT
$(info uname_S=$(uname_S))
endif

ifeq ($(uname_S),Linux)
ifndef CPPCHK_GLIBCXX_DEBUG
CPPCHK_GLIBCXX_DEBUG=-D_GLIBCXX_DEBUG
endif # !CPPCHK_GLIBCXX_DEBUG
endif # Linux

ifeq ($(uname_S),GNU/kFreeBSD)
ifndef CPPCHK_GLIBCXX_DEBUG
CPPCHK_GLIBCXX_DEBUG=-D_GLIBCXX_DEBUG
endif # !CPPCHK_GLIBCXX_DEBUG
endif # GNU/kFreeBSD

LDFLAGS+=-pthread

endif # WINNT

ifndef CPPCHK_GLIBCXX_DEBUG
CPPCHK_GLIBCXX_DEBUG=-D_GLIBCXX_DEBUG
endif # !CPPCHK_GLIBCXX_DEBUG

ifdef CYGWIN
ifeq ($(VERBOSE),1)
$(info CYGWIN found)
Expand All @@ -128,9 +116,6 @@ ifndef CXX
CXX=g++
endif

ifeq (clang++, $(findstring clang++,$(CXX)))
CPPCHK_GLIBCXX_DEBUG=
endif
ifndef CXXFLAGS
CXXFLAGS=-pedantic -Wall -Wextra -Wcast-qual -Wfloat-equal -Wmissing-declarations -Wmissing-format-attribute -Wno-long-long -Wpacked -Wredundant-decls -Wundef -Wno-sign-compare -Wno-multichar -Woverloaded-virtual -g
endif
Expand Down
6 changes: 5 additions & 1 deletion cmake/compilerCheck.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,16 @@ if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5.1)
message(ERROR "GCC >= 5.1 required - detected ${CMAKE_CXX_COMPILER_VERSION} not supported")
endif()
elseif(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 3.5)
message(ERROR "Clang >= 3.5 required - detected ${CMAKE_CXX_COMPILER_VERSION} not supported")
endif()
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang")
# TODO: AppleClang versions do not align with Clang versions - add check for proper version
elseif(MSVC)
if(MSVC_VERSION VERSION_LESS 1900)
message(ERROR "Visual Studio >= 2015 (19.0) required - detected ${MSVC_VERSION} not supported")
endif()
else()
message(WARNING "Unknown compiler ${CMAKE_CXX_COMPILER_ID}")
endif()
35 changes: 19 additions & 16 deletions cmake/compilerDefinitions.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -8,27 +8,30 @@ if(MSVC)
add_definitions(-DWIN32_LEAN_MEAN)
endif()

# TODO: this should probably apply to the compiler and not the platform - I think it is only "broken" with MinGW
# TODO: AppleClang only has libc++
# TODO: what about clang-cl and native Win32 clang?
if(CPPCHK_GLIBCXX_DEBUG AND UNIX AND CMAKE_BUILD_TYPE STREQUAL "Debug")
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
if(USE_LIBCXX)
if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 18)
add_definitions(-D_LIBCPP_HARDENING_MODE=_LIBCPP_HARDENING_MODE_DEBUG)
else()
add_definitions(-D_LIBCPP_ENABLE_ASSERTIONS=1)
endif()
# TODO: also add _LIBCPP_ENABLE_THREAD_SAFETY_ANNOTATIONS?
endif()
else()
# TODO: check if this can be enabled again for Clang - also done in Makefile
# libstdc++-specific flags
if(CMAKE_CXX_COMPILER_ID MATCHES "GNU" OR (NOT USE_LIBCXX AND CMAKE_CXX_COMPILER_ID MATCHES "Clang"))
if(CPPCHK_GLIBCXX_DEBUG AND CMAKE_BUILD_TYPE STREQUAL "Debug")
add_definitions(-D_GLIBCXX_DEBUG)
endif()
endif()

if(CMAKE_CXX_COMPILER_ID MATCHES "Clang" AND USE_LIBCXX)
# TODO: what about clang-cl?
# libc++-specific flags - AppleClang only has libc++
if ((USE_LIBCXX AND CMAKE_CXX_COMPILER_ID MATCHES "Clang") OR CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang")
add_definitions(-D_LIBCPP_REMOVE_TRANSITIVE_INCLUDES)

if(CPPCHK_GLIBCXX_DEBUG AND CMAKE_BUILD_TYPE STREQUAL "Debug")
# TODO: AppleClang versions do not align with Clang versions - add check for proper version
if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 18)
add_definitions(-D_LIBCPP_HARDENING_MODE=_LIBCPP_HARDENING_MODE_DEBUG)
else()
add_definitions(-D_LIBCPP_ENABLE_ASSERTIONS=1)
endif()
# TODO: also add _LIBCPP_ENABLE_THREAD_SAFETY_ANNOTATIONS?
else()
# TODO: check if this can be enabled again for Clang - also done in Makefile
add_definitions(-D_GLIBCXX_DEBUG)
endif()
endif()

if(HAVE_RULES)
Expand Down
4 changes: 4 additions & 0 deletions cmake/options.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,10 @@ if (NOT USE_BOOST AND USE_BOOST_INT128)
endif()
option(USE_LIBCXX "Use libc++ instead of libstdc++" OFF)

if(USE_LIBCXX AND NOT CMAKE_CXX_COMPILER_ID MATCHES "Clang")
message(FATAL_ERROR "libc++ can only be used with a Clang-based compiler")
endif()

option(NO_UNIX_SIGNAL_HANDLING "Disable usage of Unix Signal Handling" OFF)
option(NO_UNIX_BACKTRACE_SUPPORT "Disable usage of Unix Backtrace support" OFF)
option(NO_WINDOWS_SEH "Disable usage of Windows SEH" OFF)
Expand Down
2 changes: 2 additions & 0 deletions lib/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@
# define UNUSED
#endif

// TODO: AppleClang versions do not align with Clang versions - add check for proper version
// warn_unused
#if __has_cpp_attribute (gnu::warn_unused) || \
(defined(__clang__) && (__clang_major__ >= 15))
Expand All @@ -115,6 +116,7 @@
# define DEPRECATED
#endif

// TODO: AppleClang versions do not align with Clang versions - add check for proper version
// returns_nonnull
#if __has_cpp_attribute (gnu::returns_nonnull)
# define RET_NONNULL [[gnu::returns_nonnull]]
Expand Down
26 changes: 5 additions & 21 deletions tools/dmake/dmake.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -638,7 +638,6 @@ int main(int argc, char **argv)

// The _GLIBCXX_DEBUG doesn't work in cygwin or other Win32 systems.
fout << "# Set the CPPCHK_GLIBCXX_DEBUG flag. This flag is not used in release Makefiles.\n"
<< "# The _GLIBCXX_DEBUG define doesn't work in Cygwin or other Win32 systems.\n"
<< "ifndef COMSPEC\n"
<< " ifeq ($(VERBOSE),1)\n"
<< " $(info COMSPEC not found)\n"
Expand Down Expand Up @@ -667,10 +666,7 @@ int main(int argc, char **argv)
<< " ifeq ($(VERBOSE),1)\n"
<< " $(info WINNT found)\n"
<< " endif\n"
<< " #### Maybe Windows\n"
<< " ifndef CPPCHK_GLIBCXX_DEBUG\n"
<< " CPPCHK_GLIBCXX_DEBUG=\n"
<< " endif # !CPPCHK_GLIBCXX_DEBUG\n"
<< " #### May be Windows\n"
<< "\n"
<< " ifeq ($(VERBOSE),1)\n"
<< " $(info MSYSTEM=$(MSYSTEM))\n"
Expand All @@ -692,21 +688,13 @@ int main(int argc, char **argv)
<< " $(info uname_S=$(uname_S))\n"
<< " endif\n"
<< "\n"
<< " ifeq ($(uname_S),Linux)\n"
<< " ifndef CPPCHK_GLIBCXX_DEBUG\n"
<< " CPPCHK_GLIBCXX_DEBUG=-D_GLIBCXX_DEBUG\n"
<< " endif # !CPPCHK_GLIBCXX_DEBUG\n"
<< " endif # Linux\n"
<< "\n"
<< " ifeq ($(uname_S),GNU/kFreeBSD)\n"
<< " ifndef CPPCHK_GLIBCXX_DEBUG\n"
<< " CPPCHK_GLIBCXX_DEBUG=-D_GLIBCXX_DEBUG\n"
<< " endif # !CPPCHK_GLIBCXX_DEBUG\n"
<< " endif # GNU/kFreeBSD\n"
<< "\n"
<< " LDFLAGS+=-pthread\n"
<< "\n"
<< "endif # WINNT\n"
<< "\n"
<< "ifndef CPPCHK_GLIBCXX_DEBUG\n"
<< " CPPCHK_GLIBCXX_DEBUG=-D_GLIBCXX_DEBUG\n"
<< "endif # !CPPCHK_GLIBCXX_DEBUG\n"
<< "\n";

fout << "ifdef CYGWIN\n"
Expand All @@ -719,11 +707,7 @@ int main(int argc, char **argv)
<< "endif # CYGWIN\n"
<< "\n";

// skip "-D_GLIBCXX_DEBUG" if clang, since it breaks the build
makeConditionalVariable(fout, "CXX", "g++");
fout << "ifeq (clang++, $(findstring clang++,$(CXX)))\n"
<< " CPPCHK_GLIBCXX_DEBUG=\n"
<< "endif\n";

// Makefile settings..
if (release) {
Expand Down