0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-05-18 02:43:53 +02:00

configure: Disable all __assert_fail() overrides unless explicit --with-assert option.

This commit is contained in:
Jason Volk 2020-04-11 13:35:15 -07:00
parent 8050d6d66b
commit 21d9f4792b
5 changed files with 21 additions and 22 deletions

View file

@ -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
])

View file

@ -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

View file

@ -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<void>(0))

View file

@ -10,7 +10,7 @@
#include <RB_INC_SIGNAL_H
#if defined(IRCD_ASSERT_OVERRIDE) && !defined(RB_ASSERT_INTRINSIC)
#if defined(RB_ASSERT) && !defined(RB_ASSERT_INTRINSIC)
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wunreachable-code"

View file

@ -8,7 +8,7 @@
// copyright notice and this permission notice is present in all copies. The
// full license for this software is available in the LICENSE file.
#include <util/params.h>
#include <ircd/util/params.h>
using namespace ircd;