diff options
author | H.J. Lu <hjl.tools@gmail.com> | 2021-11-04 07:17:44 -0700 |
---|---|---|
committer | H.J. Lu <hjl.tools@gmail.com> | 2021-11-04 07:19:22 -0700 |
commit | 333efaea633971912f2208d37b7b62992759d400 (patch) | |
tree | 826f932bb3c1d656a2c8d5663e533d14dd0f6725 /libffi/configure | |
parent | af1bfcc04ca1c80af4fc1cda75c6c1d8509c8bd0 (diff) | |
download | gcc-333efaea633971912f2208d37b7b62992759d400.zip gcc-333efaea633971912f2208d37b7b62992759d400.tar.gz gcc-333efaea633971912f2208d37b7b62992759d400.tar.bz2 |
libffi: Add --enable-cet to configure
When --enable-cet is used to configure GCC, enable Intel CET in libffi.
* Makefile.am (AM_CFLAGS): Add $(CET_FLAGS).
(AM_CCASFLAGS): Likewise.
* configure.ac (CET_FLAGS): Add GCC_CET_FLAGS and AC_SUBST.
* Makefile.in: Regenerate.
* aclocal.m4: Likewise.
* configure: Likewise.
* include/Makefile.in: Likewise.
* man/Makefile.in: Likewise.
* testsuite/Makefile.in: Likewise.
Diffstat (limited to 'libffi/configure')
-rwxr-xr-x | libffi/configure | 97 |
1 files changed, 94 insertions, 3 deletions
diff --git a/libffi/configure b/libffi/configure index 4bababb..575641c 100755 --- a/libffi/configure +++ b/libffi/configure @@ -692,6 +692,7 @@ am__fastdepCCAS_TRUE CCASDEPMODE CCASFLAGS CCAS +CET_FLAGS am__fastdepCXX_FALSE am__fastdepCXX_TRUE CXXDEPMODE @@ -802,6 +803,7 @@ enable_multilib enable_silent_rules enable_generated_files_in_srcdir enable_dependency_tracking +enable_cet enable_shared enable_static with_pic @@ -1457,6 +1459,7 @@ Optional Features: do not reject slow dependency extractors --disable-dependency-tracking speeds up one-time build + --enable-cet enable Intel CET in target libraries [default=auto] --enable-shared[=PKGS] build shared libraries [default=yes] --enable-static[=PKGS] build static libraries [default=yes] --enable-fast-install[=PKGS] @@ -4877,6 +4880,95 @@ CFLAGS=$save_CFLAGS +# Add CET specific flags if CET is enabled + + # Check whether --enable-cet was given. +if test "${enable_cet+set}" = set; then : + enableval=$enable_cet; + case "$enableval" in + yes|no|auto) ;; + *) as_fn_error $? "Unknown argument to enable/disable cet" "$LINENO" 5 ;; + esac + +else + enable_cet=auto +fi + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for CET support" >&5 +$as_echo_n "checking for CET support... " >&6; } + +# NB: Avoid nested save_CFLAGS and save_LDFLAGS. +case "$host" in + i[34567]86-*-linux* | x86_64-*-linux*) + case "$enable_cet" in + auto) + # Check if target supports multi-byte NOPs + # and if compiler and assembler support CET insn. + cet_save_CFLAGS="$CFLAGS" + CFLAGS="$CFLAGS -fcf-protection" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + +#if !defined(__SSE2__) +#error target does not support multi-byte NOPs +#else +asm ("setssbsy"); +#endif + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + enable_cet=yes +else + enable_cet=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + CFLAGS="$cet_save_CFLAGS" + ;; + yes) + # Check if assembler supports CET. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ +asm ("setssbsy"); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + +else + as_fn_error $? "assembler with CET support is required for --enable-cet" "$LINENO" 5 +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + ;; + esac + ;; + *) + enable_cet=no + ;; +esac +if test x$enable_cet = xyes; then + CET_FLAGS="-fcf-protection -mshstk" + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + + # By default we simply use the C compiler to build assembly code. test "${CCAS+set}" = set || CCAS=$CC @@ -6903,7 +6995,6 @@ fi - # Check whether --enable-libtool-lock was given. if test "${enable_libtool_lock+set}" = set; then : enableval=$enable_libtool_lock; @@ -11481,7 +11572,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 11484 "configure" +#line 11575 "configure" #include "confdefs.h" #if HAVE_DLFCN_H @@ -11587,7 +11678,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 11590 "configure" +#line 11681 "configure" #include "confdefs.h" #if HAVE_DLFCN_H |