aboutsummaryrefslogtreecommitdiffstats
path: root/configure
diff options
context:
space:
mode:
authorLibravatar Reiner Herrmann <reiner@reiner-h.de>2019-06-21 14:29:11 +0200
committerLibravatar Reiner Herrmann <reiner@reiner-h.de>2019-06-21 14:54:58 +0200
commit2c64d1fdd395e439bfbde415656326ed2c32f79a (patch)
tree68b1aafeb216b4414d63aa32d76ea71ed649b502 /configure
parentimport ax_check_compile_flag macro from autoconf-archive (diff)
downloadfirejail-2c64d1fdd395e439bfbde415656326ed2c32f79a.tar.gz
firejail-2c64d1fdd395e439bfbde415656326ed2c32f79a.tar.zst
firejail-2c64d1fdd395e439bfbde415656326ed2c32f79a.zip
use AX_CHECK_COMPILE_FLAG to check for spectre flags
Fixes #2661
Diffstat (limited to 'configure')
-rwxr-xr-xconfigure86
1 files changed, 61 insertions, 25 deletions
diff --git a/configure b/configure
index d47e0cbb0..c3bca4bb8 100755
--- a/configure
+++ b/configure
@@ -2095,6 +2095,8 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu
2095 2095
2096#AC_CONFIG_HEADERS([config.h]) 2096#AC_CONFIG_HEADERS([config.h])
2097 2097
2098
2099
2098ac_ext=c 2100ac_ext=c
2099ac_cpp='$CPP $CPPFLAGS' 2101ac_cpp='$CPP $CPPFLAGS'
2100ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' 2102ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
@@ -3101,46 +3103,81 @@ fi
3101 3103
3102 3104
3103HAVE_SPECTRE="no" 3105HAVE_SPECTRE="no"
3104{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for Spectre mitigation support in gcc or clang compiler" >&5
3105$as_echo_n "checking for Spectre mitigation support in gcc or clang compiler... " >&6; }
3106if test "$CC" = "gcc"; then :
3107 3106
3108 HAVE_SPECTRE="yes" 3107{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether C compiler accepts -mindirect-branch=thunk" >&5
3109 $CC -mindirect-branch=thunk -c dummy.c || HAVE_SPECTRE="no" 3108$as_echo_n "checking whether C compiler accepts -mindirect-branch=thunk... " >&6; }
3110 rm -f dummy.o 3109if ${ax_cv_check_cflags___mindirect_branch_thunk+:} false; then :
3111 if test "$HAVE_SPECTRE" = "yes"; then : 3110 $as_echo_n "(cached) " >&6
3111else
3112 3112
3113 EXTRA_CFLAGS+=" -mindirect-branch=thunk " 3113 ax_check_save_flags=$CFLAGS
3114 CFLAGS="$CFLAGS -mindirect-branch=thunk"
3115 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
3116/* end confdefs.h. */
3114 3117
3118int
3119main ()
3120{
3121
3122 ;
3123 return 0;
3124}
3125_ACEOF
3126if ac_fn_c_try_compile "$LINENO"; then :
3127 ax_cv_check_cflags___mindirect_branch_thunk=yes
3128else
3129 ax_cv_check_cflags___mindirect_branch_thunk=no
3115fi 3130fi
3131rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
3132 CFLAGS=$ax_check_save_flags
3133fi
3134{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv_check_cflags___mindirect_branch_thunk" >&5
3135$as_echo "$ax_cv_check_cflags___mindirect_branch_thunk" >&6; }
3136if test "x$ax_cv_check_cflags___mindirect_branch_thunk" = xyes; then :
3137 HAVE_SPECTRE="yes" && EXTRA_CFLAGS+=" -mindirect-branch=thunk"
3116 3138
3139else
3140 :
3117fi 3141fi
3118if test "$CC" = "clang"; then :
3119 3142
3120 HAVE_SPECTRE="yes" 3143{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether C compiler accepts -mretpoline" >&5
3121 $CC -mretpoline -c dummy.c || HAVE_SPECTRE="no" 3144$as_echo_n "checking whether C compiler accepts -mretpoline... " >&6; }
3122 rm -f dummy.o 3145if ${ax_cv_check_cflags___mretpoline+:} false; then :
3123 if test "$HAVE_SPECTRE" = "yes"; then : 3146 $as_echo_n "(cached) " >&6
3147else
3124 3148
3125 EXTRA_CFLAGS+=" -mretpoline " 3149 ax_check_save_flags=$CFLAGS
3150 CFLAGS="$CFLAGS -mretpoline"
3151 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
3152/* end confdefs.h. */
3126 3153
3127fi 3154int
3155main ()
3156{
3128 3157
3158 ;
3159 return 0;
3160}
3161_ACEOF
3162if ac_fn_c_try_compile "$LINENO"; then :
3163 ax_cv_check_cflags___mretpoline=yes
3164else
3165 ax_cv_check_cflags___mretpoline=no
3129fi 3166fi
3130if test "$HAVE_SPECTRE" = "yes"; then : 3167rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
3131 3168 CFLAGS=$ax_check_save_flags
3132 { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
3133$as_echo "yes" >&6; }
3134
3135fi 3169fi
3136if test "$HAVE_SPECTRE" = "no"; then : 3170{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv_check_cflags___mretpoline" >&5
3137 3171$as_echo "$ax_cv_check_cflags___mretpoline" >&6; }
3138 { $as_echo "$as_me:${as_lineno-$LINENO}: result: ... not available" >&5 3172if test "x$ax_cv_check_cflags___mretpoline" = xyes; then :
3139$as_echo "... not available" >&6; } 3173 HAVE_SPECTRE="yes" && EXTRA_CFLAGS+=" -mretpoline"
3140 3174
3175else
3176 :
3141fi 3177fi
3142 3178
3143 3179
3180
3144HAVE_APPARMOR="" 3181HAVE_APPARMOR=""
3145# Check whether --enable-apparmor was given. 3182# Check whether --enable-apparmor was given.
3146if test "${enable_apparmor+set}" = set; then : 3183if test "${enable_apparmor+set}" = set; then :
@@ -3154,7 +3191,6 @@ if test "x$enable_apparmor" = "xyes"; then :
3154 3191
3155fi 3192fi
3156 3193
3157
3158ac_ext=c 3194ac_ext=c
3159ac_cpp='$CPP $CPPFLAGS' 3195ac_cpp='$CPP $CPPFLAGS'
3160ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' 3196ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'