Skip to content

Commit f6894a3

Browse files
add compileharden flag
1 parent c4fcd5f commit f6894a3

File tree

1 file changed

+24
-17
lines changed

1 file changed

+24
-17
lines changed

configure.ac

Lines changed: 24 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -178,23 +178,6 @@ DEBUG_CFLAGS="-g -DDEBUG -DDEBUG_WOLFSSL"
178178
LIB_ADD=
179179
LIB_STATIC_ADD=
180180

181-
CAN_USE_32B_BOUNDARIES_FLAG=no
182-
AX_CHECK_COMPILE_FLAG([-Wa,-mbranches-within-32B-boundaries],
183-
[CAN_USE_32B_BOUNDARIES_FLAG=yes],
184-
[CAN_USE_32B_BOUNDARIES_FLAG=no],
185-
[-Werror],[])
186-
187-
if test "$CAN_USE_32B_BOUNDARIES_FLAG" = "yes"
188-
then
189-
EXTRA_OPTS_CFLAGS=
190-
if test "$host_cpu" = "x86_64"
191-
then
192-
if test "$GCC" = "yes" || test "$CC" = "icc"
193-
then
194-
EXTRA_OPTS_CFLAGS="$EXTRA_OPTS_CFLAGS -Wa,-mbranches-within-32B-boundaries -falign-loops=64"
195-
fi
196-
fi
197-
fi
198181
OPTIMIZE_CFLAGS="$OPTIMIZE_CFLAGS $EXTRA_OPTS_CFLAGS"
199182
OPTIMIZE_FAST_CFLAGS="$OPTIMIZE_FAST_CFLAGS $EXTRA_OPTS_CFLAGS"
200183
OPTIMIZE_HUGE_CFLAGS="$OPTIMIZE_HUGE_CFLAGS $EXTRA_OPTS_CFLAGS"
@@ -2535,6 +2518,30 @@ then
25352518
AM_CFLAGS="$AM_CFLAGS -DWOLFSSL_CHECK_SIG_FAULTS -DWOLFSSL_CHECK_VER_FAULTS"
25362519
fi
25372520

2521+
AC_ARG_ENABLE([compileharden],
2522+
[AS_HELP_STRING([--enable-compileharden],[Enable extra hardening compile flags (default: disabled)])],
2523+
[ENABLED_COMPILEHARDEN=$enableval],
2524+
[ENABLED_COMPILEHARDEN=no])
2525+
2526+
EXTRA_OPTS_CFLAGS=
2527+
if test "$ENABLED_COMPILEHARDEN" = "yes"
2528+
then
2529+
CAN_USE_32B_BOUNDARIES_FLAG=no
2530+
AX_CHECK_COMPILE_FLAG([-Wa,-mbranches-within-32B-boundaries],
2531+
[CAN_USE_32B_BOUNDARIES_FLAG=yes],
2532+
[CAN_USE_32B_BOUNDARIES_FLAG=no],
2533+
[-Werror],[])
2534+
2535+
if test "$CAN_USE_32B_BOUNDARIES_FLAG" = "yes"
2536+
then
2537+
EXTRA_OPTS_CFLAGS="$EXTRA_OPTS_CFLAGS -Wa,-mbranches-within-32B-boundaries -falign-loops=64"
2538+
else
2539+
AC_MSG_ERROR([compiler does not accept -mbranches-within-32B-boundaries flag])
2540+
fi
2541+
fi
2542+
2543+
2544+
25382545
# IPv6 Test Apps
25392546
AC_ARG_ENABLE([ipv6],
25402547
[AS_HELP_STRING([--enable-ipv6],[Enable testing of IPV6 (default: disabled)])],

0 commit comments

Comments
 (0)