From: Igor Tsimbalist Date: Fri, 17 Nov 2017 21:11:42 +0000 (+0100) Subject: Enable building libbacktrace with Intel CET X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=44685d378f723f8cd54770a445b6dfeab085ac99;p=gcc.git Enable building libbacktrace with Intel CET libbacktrace/ * configure.ac: Add CET_FLAGS to EXTRA_FLAGS. * aclocal.m4: Regenerate. * Makefile.in: Likewise. * configure: Likewise. From-SVN: r254892 --- diff --git a/libbacktrace/ChangeLog b/libbacktrace/ChangeLog index 5540530ef4f..35af7e5c318 100644 --- a/libbacktrace/ChangeLog +++ b/libbacktrace/ChangeLog @@ -1,3 +1,10 @@ +2017-11-17 Igor Tsimbalist + + * configure.ac: Add CET_FLAGS to EXTRA_FLAGS. + * aclocal.m4: Regenerate. + * Makefile.in: Likewise. + * configure: Likewise. + 2017-10-06 Ian Lance Taylor * ztest.c (test_large): Pass unsigned long *, not size_t *, to diff --git a/libbacktrace/Makefile.in b/libbacktrace/Makefile.in index 407098ab9e0..f7f849bdeaf 100644 --- a/libbacktrace/Makefile.in +++ b/libbacktrace/Makefile.in @@ -95,7 +95,9 @@ DIST_COMMON = README ChangeLog $(srcdir)/Makefile.in \ $(am__configure_deps) $(srcdir)/config.h.in \ $(srcdir)/../mkinstalldirs $(srcdir)/backtrace-supported.h.in ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 -am__aclocal_m4_deps = $(top_srcdir)/../config/lead-dot.m4 \ +am__aclocal_m4_deps = $(top_srcdir)/../config/cet.m4 \ + $(top_srcdir)/../config/enable.m4 \ + $(top_srcdir)/../config/lead-dot.m4 \ $(top_srcdir)/../config/multi.m4 \ $(top_srcdir)/../config/override.m4 \ $(top_srcdir)/../config/stdint.m4 \ diff --git a/libbacktrace/aclocal.m4 b/libbacktrace/aclocal.m4 index 8e84ddd1f10..7a6ea55fb34 100644 --- a/libbacktrace/aclocal.m4 +++ b/libbacktrace/aclocal.m4 @@ -670,6 +670,8 @@ AC_SUBST([am__tar]) AC_SUBST([am__untar]) ]) # _AM_PROG_TAR +m4_include([../config/cet.m4]) +m4_include([../config/enable.m4]) m4_include([../config/lead-dot.m4]) m4_include([../config/multi.m4]) m4_include([../config/override.m4]) diff --git a/libbacktrace/configure b/libbacktrace/configure index 7ed9509291c..8943b0ca7fd 100755 --- a/libbacktrace/configure +++ b/libbacktrace/configure @@ -743,6 +743,7 @@ enable_fast_install with_gnu_ld enable_libtool_lock enable_largefile +enable_cet with_system_libunwind enable_host_shared ' @@ -1385,6 +1386,8 @@ Optional Features: optimize for fast installation [default=yes] --disable-libtool-lock avoid locking (might break parallel builds) --disable-largefile omit support for large files + --enable-cet enable Intel CET in target libraries + [default=default] --enable-host-shared build host code as shared libraries Optional Packages: @@ -11146,7 +11149,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 11149 "configure" +#line 11152 "configure" #include "confdefs.h" #if HAVE_DLFCN_H @@ -11252,7 +11255,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 11255 "configure" +#line 11258 "configure" #include "confdefs.h" #if HAVE_DLFCN_H @@ -11784,6 +11787,77 @@ $as_echo "$libbacktrace_cv_c_random_seed_string" >&6; } fi fi +if test -n "${with_target_subdir}"; then + # Add CET specific flags is Intel CET is enabled. + # Check whether --enable-cet was given. +if test "${enable_cet+set}" = set; then : + enableval=$enable_cet; + case "$enableval" in + yes|no|default) ;; + *) as_fn_error "Unknown argument to enable/disable cet" "$LINENO" 5 ;; + esac + +else + enable_cet=default +fi + + +case "$host" in + i[34567]86-*-linux* | x86_64-*-linux*) + case "$enable_cet" in + default) + # 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 : + enable_cet=yes +else + enable_cet=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + ;; + 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 -mcet" +fi + + EXTRA_FLAGS="$EXTRA_FLAGS $CET_FLAGS" +fi + ac_ext=c ac_cpp='$CPP $CPPFLAGS' diff --git a/libbacktrace/configure.ac b/libbacktrace/configure.ac index 9bc1d0f8464..bca3c818775 100644 --- a/libbacktrace/configure.ac +++ b/libbacktrace/configure.ac @@ -130,6 +130,12 @@ else EXTRA_FLAGS="$EXTRA_FLAGS -frandom-seed=\$@" fi fi + +if test -n "${with_target_subdir}"; then + # Add CET specific flags is Intel CET is enabled. + GCC_CET_FLAGS(CET_FLAGS) + EXTRA_FLAGS="$EXTRA_FLAGS $CET_FLAGS" +fi AC_SUBST(EXTRA_FLAGS) ACX_PROG_CC_WARNING_OPTS([-W -Wall -Wwrite-strings -Wstrict-prototypes \