diff --git a/m4/nc_cxx.m4 b/m4/nc_cxx.m4 index b7faa3b..c8538c1 100644 --- a/m4/nc_cxx.m4 +++ b/m4/nc_cxx.m4 @@ -2,7 +2,7 @@ AC_DEFUN([NC_CXX],[ AX_CHECK_COMPILE_FLAG( [-std=c++1z], [AX_APPEND_FLAG([-std=c++1z], [CXXFLAGS])], - [AC_ERROR([Unable to enable c++1z])] + [AC_MSG_ERROR([Unable to enable c++1z])] ) AX_APPEND_COMPILE_FLAGS([-pipe], [], [-Werror]) @@ -14,14 +14,11 @@ AC_DEFUN([NC_CXX],[ AC_C_RESTRICT AC_C_INLINE - AC_COMPILE_IFELSE([AC_LANG_PROGRAM([struct A { virtual void C (void) = 0; }; - struct B : A { void C (void) override; }; ], - [])], - [], [AC_DEFINE([override], [], [Pretend about override keyword support])]) + AC_ARG_ENABLE([libcxx], [AS_HELP_STRING([--enable-libcxx], [use clang's cxx library])]) - AC_COMPILE_IFELSE([AC_LANG_PROGRAM([struct A final { }; ], - [])], - [], [AC_DEFINE([final], [], [Pretend about final keyword support])]) + AS_IF([test "x${enable_libcxx}" == "xyes"], [ + AX_APPEND_COMPILE_FLAGS([-stdlib=libc++]) + ]) AX_APPEND_COMPILE_FLAGS([-fvisibility=hidden], [], [-Werror]) ]) diff --git a/m4/nc_debugging.m4 b/m4/nc_debugging.m4 index fbb0aef..4e5f50f 100644 --- a/m4/nc_debugging.m4 +++ b/m4/nc_debugging.m4 @@ -3,51 +3,19 @@ AC_DEFUN([NC_DEBUGGING],[ AX_REQUIRE_DEFINED([AS_HELP_STRING]) AX_REQUIRE_DEFINED([AX_APPEND_COMPILE_FLAGS]) AX_REQUIRE_DEFINED([AX_APPEND_LINK_FLAGS]) - AX_REQUIRE_DEFINED([NC_APPEND_ONE_COMPILE_FLAG]) ##------------------------------------------------------------------------- AC_ARG_ENABLE([sanitizer], [AS_HELP_STRING([--enable-sanitizer], [enable memory sanitizer])]) AS_IF([test "x$enable_sanitizer" = "xyes"], [ - m4_foreach([NAME], [ - dnl common top-level names. deliberately does not include - dnl 'undefined' due to false positives in some core libraries - dnl (eg, boost::format). - [address], - dnl gcc currently causes segfaults at configure time with [thread], - dnl - dnl gcc specific names. do not use vptr or boost::format will die - [alignment], - [bounds], - [enum], - [float-cast-overflow], - [float-divide-by-zero], - [integer-divide-by-zero], - [leak], - [nonnull-attribute], - [object-size], - [return], - [returns-nonnull-attribute], - [shift], - [signed-integer-overflow], - [unreachable], - [vla-bound], - dnl clang specific names - [integer], - [undefined-trap], - [cfi]dnl - ], [ - AX_APPEND_COMPILE_FLAGS([-fsanitize=[]NAME], [], [-Werror]) - AX_APPEND_LINK_FLAGS([-fsanitize=[]NAME], [], [-Werror]) - ]) + AX_APPEND_COMPILE_FLAGS([-fsanitize=address]) + AX_APPEND_COMPILE_FLAGS([-fsanitize=undefined]) - ## We, and the std library, tend to use unsigned overflow legitimately - AX_APPEND_COMPILE_FLAGS([-fno-sanitize=unsigned-integer-overflow], [], [-Werror]) - AX_APPEND_LINK_FLAGS([-fno-sanitize=unsigned-integer-overflow], [], [-Werror]) - - AX_APPEND_COMPILE_FLAGS([-ftrapv], [], [-Werror]) + AX_APPEND_COMPILE_FLAGS([-ftrapv]) ]) + AM_CONDITIONAL([WITH_SANITIZER], [test "x${enable_sanitizer}" == "xyes"]) + ##------------------------------------------------------------------------- AC_ARG_ENABLE([debugging], [AS_HELP_STRING([--enable-debugging], [enables developer debugging support])]) @@ -55,7 +23,9 @@ AC_DEFUN([NC_DEBUGGING],[ AC_DEFINE([ENABLE_DEBUGGING], [], [Debugging support enabled]) AC_DEFINE([_GLIBCXX_DEBUG], [], [Use glibcxx debugging mode]) - NC_APPEND_ONE_COMPILE_FLAG([-O0]) + AX_APPEND_COMPILE_FLAGS([-O0]) + + AX_APPEND_COMPILE_FLAGS([-fstack-protector]) ], [ AX_APPEND_COMPILE_FLAGS([-O2]) AX_APPEND_COMPILE_FLAGS([-fno-rtti]) @@ -63,6 +33,11 @@ AC_DEFUN([NC_DEBUGGING],[ ]) ##------------------------------------------------------------------------- - AX_APPEND_COMPILE_FLAGS([-g], [], [-Werror]) - AX_APPEND_COMPILE_FLAGS([-ggdb], [], [-Werror]) + AS_CASE([${host_os}], + [mingw*], [AX_APPEND_COMPILE_FLAGS([-gstabs])], + [ + AX_APPEND_COMPILE_FLAGS([-g]) + AX_APPEND_COMPILE_FLAGS([-ggdb]) + ] + ) ]) diff --git a/m4/nc_optimisation.m4 b/m4/nc_optimisation.m4 index 5b674c4..06ca352 100644 --- a/m4/nc_optimisation.m4 +++ b/m4/nc_optimisation.m4 @@ -75,15 +75,25 @@ AC_DEFUN([NC_OPTIMISATION],[ AX_APPEND_COMPILE_FLAGS([-fslp-vectorize-aggressive], [], [-Werror]) # loop hosting/distribution - AX_APPEND_COMPILE_FLAGS([-ftree-loop-distribute-patterns], [], [-Werror]) + AX_APPEND_COMPILE_FLAGS([-floop-nest-optimize], [], [-Werror]) + AX_APPEND_COMPILE_FLAGS([-ftree-loop-distribution], [], [-Werror]) + AX_APPEND_COMPILE_FLAGS([-ftree-loop-distribute-patterns], [], [-Werror]) + AX_APPEND_COMPILE_FLAGS([-ftree-loop-im], [], [-Werror]) AX_APPEND_COMPILE_FLAGS([-ftree-loop-if-convert-stores], [], [-Werror]) - AX_APPEND_COMPILE_FLAGS([-ftree-loop-linear], [], [-Werror]) + + AX_APPEND_COMPILE_FLAGS([-fivopts], [], [-Werror]) AX_APPEND_COMPILE_FLAGS([-funsafe-loop-optimizations], [], [-Werror]) AX_APPEND_COMPILE_FLAGS([-floop-interchange], [], [-Werror]) - # safety removal for performance + AX_APPEND_COMPILE_FLAGS([-fpredictive-commoning], [], [-Werror]) + AX_APPEND_COMPILE_FLAGS([-funswitch-loops], [], [-Werror]) + + # options that require substantial time/memory + AX_APPEND_COMPILE_FLAGS([-fipa-pta]) + + dnl # safety removal for performance AX_APPEND_COMPILE_FLAGS([-fno-stack-protector], [], [-Werror]) ]) diff --git a/m4/nc_platform.m4 b/m4/nc_platform.m4 index e4f9a3e..c4b28a1 100644 --- a/m4/nc_platform.m4 +++ b/m4/nc_platform.m4 @@ -1,8 +1,16 @@ AC_DEFUN([NC_PLATFORM],[ AC_CANONICAL_HOST - AM_CONDITIONAL([PLATFORM_WIN32], [test "x$host_os" = "xmingw32"]) - AM_CONDITIONAL([PLATFORM_LINUX], [test "x$host_os" = "xlinux-gnu"]) + AS_CASE([x${host_os}], + [xmingw*], [nc_cv_platform_win32=yes], + [xlinux*], [nc_cv_platform_linux=yes], + [xfreebsd*], [nc_cv_platform_freebsd=yes], + [AC_MSG_ERROR([unhandled platform ${host_os}])] + ) + + AM_CONDITIONAL([PLATFORM_WIN32], [test "x$nc_cv_platform_win32" = "xyes"]) + AM_CONDITIONAL([PLATFORM_LINUX], [test "x$nc_cv_platform_linux" = "xyes"]) + AM_CONDITIONAL([PLATFORM_FREEBSD], [test "x$nc_cv_platform_freebsd" = "xyes"]) AS_CASE([$host_os], [mingw32], [ @@ -20,7 +28,12 @@ AC_DEFUN([NC_PLATFORM],[ AX_APPEND_LINK_FLAGS([-static-libgcc], [], [-Werror]) ], - [linux-gnu], [ ], + [freebsd*], [ + AX_APPEND_COMPILE_FLAGS([-I/usr/local/include]) + AX_APPEND_LINK_FLAGS([-L/usr/local/lib]) + ], + + [linux*], [:], [AC_MSG_ERROR([Unknown platform])] ) diff --git a/m4/nc_warnings.m4 b/m4/nc_warnings.m4 index 4a141e8..11a66df 100644 --- a/m4/nc_warnings.m4 +++ b/m4/nc_warnings.m4 @@ -1,6 +1,6 @@ AC_DEFUN([NC_WARNINGS],[ - AX_REQUIRE_DEFINED([AX_APPEND_COMPILE_FLAGS]) - AX_REQUIRE_DEFINED([AX_COMPILER_VENDOR]) + AC_REQUIRE([AX_APPEND_COMPILE_FLAGS]) + AC_REQUIRE([AX_COMPILER_VENDOR]) AX_COMPILER_VENDOR @@ -32,8 +32,22 @@ AC_DEFUN([NC_WARNINGS],[ AX_APPEND_COMPILE_FLAGS([-Wunsafe-loop-optimizations], [], [-Werror]) AX_APPEND_COMPILE_FLAGS([-Wunused-but-set-variable], [], [-Werror]) AX_APPEND_COMPILE_FLAGS([-Wunused-parameter], [], [-Werror]) - AX_APPEND_COMPILE_FLAGS([-Wuseless-cast], [], [-Werror]) AX_APPEND_COMPILE_FLAGS([-Wpessimizing-move], [], [-Werror]) + AX_APPEND_COMPILE_FLAGS([-Wswitch-enum], [], [-Werror]) + + dnl gcc-6.1.0 warnings + AX_APPEND_COMPILE_FLAGS([-Wshift-negative-value], [], [-Werror]) + AX_APPEND_COMPILE_FLAGS([-Wnull-dereference], [], [-Werror]) + AX_APPEND_COMPILE_FLAGS([-Wduplicated-cond], [], [-Werror]) + + dnl useless-cast isn't usable on gcc-6.1 due to spurious warnings + dnl see gcc#70844 + AX_APPEND_COMPILE_FLAGS([-Wuseless-cast], [], [-Werror]) + + dnl clang 3.7.1 warnings + AX_APPEND_COMPILE_FLAGS([-Wshorten-64-to-32], [], [-Werror]) + AX_APPEND_COMPILE_FLAGS([-Wdeprecated], [], [-Werror]) + AX_APPEND_COMPILE_FLAGS([-Wcovered-switch-default], [], [-Werror]) # ------------------------------------------------------------------------- # Required extensions @@ -42,9 +56,12 @@ AC_DEFUN([NC_WARNINGS],[ #AX_APPEND_COMPILE_FLAGS([-Wno-vla-extension], [], [-Werror]) AX_APPEND_COMPILE_FLAGS([-Wno-vla], [], [-Werror]) + dnl GCC will happily compile with any "-Wno" argument, so enable GCC-isms + dnl only if we aren't GCC AS_IF([test "x$ax_cv_cxx_compiler_vendor" != "xgnu"], [ AX_APPEND_COMPILE_FLAGS([-Wno-c99-extensions], [], [-Werror]) AX_APPEND_COMPILE_FLAGS([-Wno-flexible-array-extensions], [], [-Werror]) + AX_APPEND_COMPILE_FLAGS([-Wno-gnu-anonymous-struct]) AX_APPEND_COMPILE_FLAGS([-Wno-gnu-conditional-omitted-operand], [], [-Werror]) AX_APPEND_COMPILE_FLAGS([-Wno-gnu-empty-struct], [], [-Werror]) AX_APPEND_COMPILE_FLAGS([-Wno-gnu-flexible-array-union-member], [], [-Werror]) @@ -64,7 +81,6 @@ AC_DEFUN([NC_WARNINGS],[ # ------------------------------------------------------------------------- # Strict warnings - AX_APPEND_COMPILE_FLAGS([-pedantic], [], [-Werror]) # ------------------------------------------------------------------------- # Advisory warnings @@ -77,5 +93,7 @@ AC_DEFUN([NC_WARNINGS],[ AX_APPEND_COMPILE_FLAGS([-Wsuggest-final-types], [], [-Werror]) AX_APPEND_COMPILE_FLAGS([-Wsuggest-final-methods], [], [-Werror]) AX_APPEND_COMPILE_FLAGS([-Wsuggest-override], [], [-Werror]) + AX_APPEND_COMPILE_FLAGS([-Wweak-vtables], [], [-Werror]) + AX_APPEND_COMPILE_FLAGS([-Wpadded], [], [-Werror]) ], []) ])