Enable building libbacktrace with Intel CET
authorIgor Tsimbalist <igor.v.tsimbalist@intel.com>
Fri, 17 Nov 2017 21:11:42 +0000 (22:11 +0100)
committerIgor Tsimbalist <itsimbal@gcc.gnu.org>
Fri, 17 Nov 2017 21:11:42 +0000 (22:11 +0100)
libbacktrace/
* configure.ac: Add CET_FLAGS to EXTRA_FLAGS.
* aclocal.m4: Regenerate.
* Makefile.in: Likewise.
* configure: Likewise.

From-SVN: r254892

libbacktrace/ChangeLog
libbacktrace/Makefile.in
libbacktrace/aclocal.m4
libbacktrace/configure
libbacktrace/configure.ac

index 5540530ef4fd5af4bd9c7c300bc3c08ebf1566da..35af7e5c318c5b0896540741102b160b13d5c9c3 100644 (file)
@@ -1,3 +1,10 @@
+2017-11-17  Igor Tsimbalist  <igor.v.tsimbalist@intel.com>
+
+       * configure.ac: Add CET_FLAGS to EXTRA_FLAGS.
+       * aclocal.m4: Regenerate.
+       * Makefile.in: Likewise.
+       * configure: Likewise.
+
 2017-10-06  Ian Lance Taylor  <iant@golang.org>
 
        * ztest.c (test_large): Pass unsigned long *, not size_t *, to
index 407098ab9e02d8a1d1ea494c3e759c3d445eca6f..f7f849bdeaf2da4e440f86b75d1d82c2f5a54713 100644 (file)
@@ -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 \
index 8e84ddd1f10132210a49e7d08ba522e09df3a8ad..7a6ea55fb34e0d89345873cdc910cc36b6c5fcbe 100644 (file)
@@ -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])
index 7ed9509291c0fb5b11e48c3ca8bf18bf6e555af3..8943b0ca7fd8a1a30c92a27a23d91eed55d6752e 100755 (executable)
@@ -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'
index 9bc1d0f84643a715766b67587ff757d7ffb052c4..bca3c818775546e39c56c4bf51c83bdc481d769c 100644 (file)
@@ -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 \