Enable building libatomic with Intel CET
authorIgor Tsimbalist <igor.v.tsimbalist@intel.com>
Fri, 17 Nov 2017 21:18:15 +0000 (22:18 +0100)
committerIgor Tsimbalist <itsimbal@gcc.gnu.org>
Fri, 17 Nov 2017 21:18:15 +0000 (22:18 +0100)
libatomic/
* configure.ac: Set CET_FLAGS, update XCFLAGS.
* acinclude.m4: Add cet.m4 and enable.m4.
* configure: Regenerate.
* Makefile.in: Likewise.
* testsuite/Makefile.in: Likewise.

From-SVN: r254893

libatomic/ChangeLog
libatomic/Makefile.in
libatomic/acinclude.m4
libatomic/configure
libatomic/configure.ac
libatomic/testsuite/Makefile.in

index eed12e63a6880f50e69417c458d13e10dce87159..bc254ece628c549610e8762f32075db44b326193 100644 (file)
@@ -1,3 +1,11 @@
+2017-11-17  Igor Tsimbalist  <igor.v.tsimbalist@intel.com>
+
+       * configure.ac: Set CET_FLAGS, update XCFLAGS.
+       * acinclude.m4: Add cet.m4 and enable.m4.
+       * configure: Regenerate.
+       * Makefile.in: Likewise.
+       * testsuite/Makefile.in: Likewise.
+
 2017-10-20  Richard Earnshaw  <rearnsha@arm.com>
 
        * Makefile.am: (IFUNC_OPTIONS): Set the architecture to
index 0f0382e0713f33eac0525c37717dc4427e9c5bf7..fac9bae6e1ff6a37507e0b23b9253a9536c1d0da 100644 (file)
@@ -75,7 +75,8 @@ am__aclocal_m4_deps = $(top_srcdir)/../config/acx.m4 \
        $(top_srcdir)/../ltoptions.m4 $(top_srcdir)/../ltsugar.m4 \
        $(top_srcdir)/../ltversion.m4 $(top_srcdir)/../lt~obsolete.m4 \
        $(top_srcdir)/acinclude.m4 $(top_srcdir)/../libtool.m4 \
-       $(top_srcdir)/configure.ac
+       $(top_srcdir)/../config/enable.m4 \
+       $(top_srcdir)/../config/cet.m4 $(top_srcdir)/configure.ac
 am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
        $(ACLOCAL_M4)
 am__CONFIG_DISTCLEAN_FILES = config.status config.cache config.log \
index 383218f933f0a0e7bd901137c59bba709ad214ef..bb6308bfa4fd621e91560780f167ce24e159622f 100644 (file)
@@ -632,6 +632,8 @@ AC_MSG_NOTICE(versioning on shared library symbols is $enable_symvers)
 
 dnl ----------------------------------------------------------------------
 sinclude(../libtool.m4)
+sinclude(../config/enable.m4)
+sinclude(../config/cet.m4)
 dnl The lines below arrange for aclocal not to bring an installed
 dnl libtool.m4 into aclocal.m4, while still arranging for automake to
 dnl add a definition of LIBTOOL to Makefile.in.
index e88a7b8c55316ddd414569dc806c654626093e9b..e49313fbf929373f60ee77793a1ecb24fd4a7afa 100755 (executable)
@@ -764,6 +764,7 @@ with_gnu_ld
 enable_libtool_lock
 enable_maintainer_mode
 enable_symvers
+enable_cet
 with_gcc_major_version_only
 '
       ac_precious_vars='build_alias
@@ -1410,6 +1411,8 @@ Optional Features:
                          (and sometimes confusing) to the casual installer
   --enable-symvers=STYLE  enables symbol versioning of the shared library
                           [default=yes]
+  --enable-cet            enable Intel CET in target libraries
+                          [default=default]
 
 Optional Packages:
   --with-PACKAGE[=ARG]    use PACKAGE [ARG=yes]
@@ -11115,7 +11118,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 11118 "configure"
+#line 11121 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -11221,7 +11224,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 11224 "configure"
+#line 11227 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -15225,6 +15228,75 @@ if test "x$GCC" = "xyes"; then
   XCFLAGS="$XCFLAGS -Wall -Werror"
 fi
 
+# 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|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
+
+XCFLAGS="$XCFLAGS $CET_FLAGS"
+
 XCFLAGS="$XCFLAGS $XPCFLAGS"
 
 
index 023f1727b1e9b64f99a43a4ce83574974e43a3d1..bf7315e78d1b6c3cc26c7fd598e89fe829199418 100644 (file)
@@ -238,6 +238,10 @@ if test "x$GCC" = "xyes"; then
   XCFLAGS="$XCFLAGS -Wall -Werror"
 fi
 
+# Add CET specific flags if CET is enabled
+GCC_CET_FLAGS(CET_FLAGS)
+XCFLAGS="$XCFLAGS $CET_FLAGS"
+
 XCFLAGS="$XCFLAGS $XPCFLAGS"
 
 AC_SUBST(config_path)
index adfc231484a6c81a3ea9bac8a6efce276e610647..a95e3ca8e8ab9a18e537984d9455fb266cb6a734 100644 (file)
@@ -64,7 +64,8 @@ am__aclocal_m4_deps = $(top_srcdir)/../config/acx.m4 \
        $(top_srcdir)/../ltoptions.m4 $(top_srcdir)/../ltsugar.m4 \
        $(top_srcdir)/../ltversion.m4 $(top_srcdir)/../lt~obsolete.m4 \
        $(top_srcdir)/acinclude.m4 $(top_srcdir)/../libtool.m4 \
-       $(top_srcdir)/configure.ac
+       $(top_srcdir)/../config/enable.m4 \
+       $(top_srcdir)/../config/cet.m4 $(top_srcdir)/configure.ac
 am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
        $(ACLOCAL_M4)
 mkinstalldirs = $(SHELL) $(top_srcdir)/../mkinstalldirs