From 21d9f4792bb59f5657ae5c94e1bf52a8288b247d Mon Sep 17 00:00:00 2001 From: Jason Volk Date: Sat, 11 Apr 2020 13:35:15 -0700 Subject: [PATCH] configure: Disable all __assert_fail() overrides unless explicit --with-assert option. --- configure.ac | 32 ++++++++++++++++---------------- include/ircd/assert.h | 5 ++--- include/ircd/portable.h | 2 +- ircd/assert.cc | 2 +- modules/m_command.cc | 2 +- 5 files changed, 21 insertions(+), 22 deletions(-) diff --git a/configure.ac b/configure.ac index a83f776c7..88e3604f1 100644 --- a/configure.ac +++ b/configure.ac @@ -61,6 +61,11 @@ AC_CONFIG_FILES(\ AM_INIT_AUTOMAKE([subdir-objects]) +dnl If this is not (un)set, paths are added such as -I../include/ircd to every +dnl build command and that isn't nice because it makes our headers conflict +dnl with standard library/path headers which we don't want or need. +AC_SUBST(DEFAULT_INCLUDES, []) + dnl dnl Recursive local targets (clean-local is implied) dnl @@ -181,32 +186,27 @@ dnl Switch to control the action of assert() dnl AC_MSG_CHECKING(whether to change the behavior of assertions) -AC_ARG_WITH(assert, AC_HELP_STRING([--with-assert[[[=trap]]]], [Soften assertion behavior]), +AC_ARG_WITH(assert, AC_HELP_STRING([--with-assert[[[=abort]]]], [Soften assertion behavior]), [ assert_type=$withval - AC_MSG_RESULT([yes]) + AC_MSG_RESULT([yes, "$assert_type"]) AC_SUBST(ASSERT_TYPE, $assert_type) ], [ - AM_COND_IF(DEBUG, - [ - assert_type="trap" - AC_MSG_RESULT([no, defaulting to "$assert_type"]) - AC_SUBST(ASSERT_TYPE, $assert_type) - ], [ - assert_type="abort" - AC_MSG_RESULT([no]) - AC_SUBST(ASSERT_TYPE, $assert_type) - ]) + AC_MSG_RESULT([no]) ]) AM_COND_IF(ASSERT, [ if [[ ! -z "$assert_type" ]]; then - RB_DEFINE_UNQUOTED([ASSERT], ["$assert_type"], [Assertion behavior]) - fi - if [[ "$assert_type" == "trap" ]]; then - RB_DEFINE([ASSERT_INTRINSIC], [1], [Intrinsic assertion behavior]) + if [[ "$assert_type" != "abort" ]]; then + RB_DEFINE_UNQUOTED([ASSERT], ["$assert_type"], [Assertion behavior]) + fi + + if [[ "$assert_type" == "trap" ]]; then + RB_DEFINE([ASSERT_INTRINSIC], [1], [Intrinsic assertion behavior]) + fi + fi ]) diff --git a/include/ircd/assert.h b/include/ircd/assert.h index bfd795eea..12ec29c06 100644 --- a/include/ircd/assert.h +++ b/include/ircd/assert.h @@ -27,7 +27,6 @@ /// Define an indicator for whether we override standard assert() behavior in /// this build if the conditions are appropriate. #if defined(RB_ASSERT) && !defined(NDEBUG) - #define IRCD_ASSERT_OVERRIDE #define _ASSERT_H_DECLS #endif @@ -43,7 +42,7 @@ namespace ircd /// actions as defined in our internal assert.cc unit. When trapping assert /// is disabled this path will be used instead. /// -#if defined(IRCD_ASSERT_OVERRIDE) && !defined(RB_ASSERT_INTRINSIC) +#if defined(RB_ASSERT) && !defined(RB_ASSERT_INTRINSIC) extern "C" void __attribute__((visibility("default"))) __assert_fail(const char *__assertion, @@ -55,7 +54,7 @@ __assert_fail(const char *__assertion, /// Override the standard assert behavior, if enabled, to trap into the /// debugger as close as possible to the offending site. /// -#if defined(IRCD_ASSERT_OVERRIDE) && defined(RB_ASSERT_INTRINSIC) +#if defined(RB_ASSERT) && defined(RB_ASSERT_INTRINSIC) extern "C" // for clang { extern inline void diff --git a/include/ircd/portable.h b/include/ircd/portable.h index 622e498a7..1e13093a4 100644 --- a/include/ircd/portable.h +++ b/include/ircd/portable.h @@ -57,7 +57,7 @@ namespace ircd // Trouble; clang w/ our custom assert // -#if defined(__clang__) && !defined(assert) +#if defined(RB_ASSERT) && defined(__clang__) && !defined(assert) #ifdef NDEBUG #define assert(expr) \ (static_cast(0)) diff --git a/ircd/assert.cc b/ircd/assert.cc index 4b8b59caa..691459b2e 100644 --- a/ircd/assert.cc +++ b/ircd/assert.cc @@ -10,7 +10,7 @@ #include +#include using namespace ircd;