Enable building libobjc with Intel CET
authorIgor Tsimbalist <igor.v.tsimbalist@intel.com>
Fri, 17 Nov 2017 22:48:36 +0000 (23:48 +0100)
committerIgor Tsimbalist <itsimbal@gcc.gnu.org>
Fri, 17 Nov 2017 22:48:36 +0000 (23:48 +0100)
libobjc/
* Makefile.in: Regenerate.
* aclocal.m4: Likeiwse.
* configure: Likewise.
* configure.ac: Set CET_FLAGS. Update XCFLAGS.

From-SVN: r254904

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

index b36962c1c847dc0d1594b2f00ccfd3d565db5115..2f9361ffe454b0e0ebfdb101ce9569bfd2e73aa4 100644 (file)
@@ -1,3 +1,10 @@
+2017-11-17  Igor Tsimbalist  <igor.v.tsimbalist@intel.com>
+
+       * Makefile.in: Regenerate.
+       * aclocal.m4: Likeiwse.
+       * configure: Likewise.
+       * configure.ac: Set CET_FLAGS. Update XCFLAGS.
+
 2017-08-30  Richard Sandiford  <richard.sandiford@linaro.org>
            Alan Hayward  <alan.hayward@arm.com>
            David Sherwood  <david.sherwood@arm.com>
index febc92d4b3cc449a71156af57ad1aa051f559d0c..cfbe63ab201a2e34412d038a113f2dd993230571 100644 (file)
@@ -72,8 +72,10 @@ RANLIB = @RANLIB@
 
 CC = @CC@
 CFLAGS = @CFLAGS@
+XCFLAGS = @XCFLAGS@
 WARN_CFLAGS = -W -Wall -Wwrite-strings -Wstrict-prototypes
-ALL_CFLAGS = -I. -I$(srcdir) $(CPPFLAGS) $(DEFS) $(CFLAGS) $(WARN_CFLAGS) \
+ALL_CFLAGS = -I. -I$(srcdir) $(CPPFLAGS) $(DEFS) \
+       $(XCFLAGS) $(CFLAGS) $(WARN_CFLAGS) \
        -DIN_GCC -DIN_TARGET_LIBS -fno-strict-aliasing -fexceptions
 
 # Libtool
@@ -295,6 +297,7 @@ aclocal_deps = \
        $(srcdir)/../ltsugar.m4 \
        $(srcdir)/../ltversion.m4 \
        $(srcdir)/../lt~obsolete.m4 \
+       $(srcdir)/../cet.m4 \
        $(srcdir)/acinclude.m4
 
 $(srcdir)/configure: @MAINT@ configure.ac $(srcdir)/aclocal.m4
index 174f9b7d0d88d1f5042087d27315ec1b0fb87d8d..21273411f19dc9c2dc35aa4ca3f9cc02cba1651f 100644 (file)
@@ -197,6 +197,7 @@ AC_DEFUN([_AM_SUBST_NOTMAKE])
 # Public sister of _AM_SUBST_NOTMAKE.
 AC_DEFUN([AM_SUBST_NOTMAKE], [_AM_SUBST_NOTMAKE($@)])
 
+m4_include([../config/cet.m4])
 m4_include([../config/lthostflags.m4])
 m4_include([../config/multi.m4])
 m4_include([../config/override.m4])
index abf5aed71cfa5a105574dfb2d9d2651aaaad5657..3a2b2e366347f7e8a623e28f4caa96bf24b6a4fb 100755 (executable)
@@ -635,6 +635,7 @@ INSTALL_PROGRAM
 RANLIB
 AR
 AS
+XCFLAGS
 extra_ldflags_libobjc
 lt_host_flags
 OBJEXT
@@ -714,6 +715,7 @@ with_target_subdir
 with_cross_host
 enable_version_specific_runtime_libs
 enable_multilib
+enable_cet
 enable_maintainer_mode
 enable_shared
 enable_static
@@ -1350,6 +1352,8 @@ Optional Features:
   --enable-FEATURE[=ARG]  include FEATURE [ARG=yes]
   --enable-version-specific-runtime-libs    Specify that runtime libraries should be installed in a compiler-specific directory
   --enable-multilib       build many library versions (default)
+  --enable-cet            enable Intel CET in target libraries
+                          [default=default]
   --enable-maintainer-mode  enable make rules and dependencies not useful
                          (and sometimes confusing) to the casual installer
   --enable-shared[=PKGS]  build shared libraries [default=yes]
@@ -3350,6 +3354,77 @@ case "${host}" in
 esac
 
 
+# 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"
+
+
 
 
 if test -n "$ac_tool_prefix"; then
@@ -5980,7 +6055,6 @@ fi
 
 
 
-
 
 
 # Check whether --enable-libtool-lock was given.
@@ -10594,7 +10668,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 10597 "configure"
+#line 10671 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -10700,7 +10774,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 10703 "configure"
+#line 10777 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
index c6d48f787ae10a4dafc956bd27f9605ae5a83915..f24b5da6d576dcc3753558544505a76f8c120ab4 100644 (file)
@@ -151,7 +151,12 @@ case "${host}" in
 esac
 AC_SUBST(extra_ldflags_libobjc)
 
+# Add CET specific flags if CET is enabled
+GCC_CET_FLAGS(CET_FLAGS)
+XCFLAGS="$XCFLAGS $CET_FLAGS"
+
 AC_SUBST(CFLAGS)
+AC_SUBST(XCFLAGS)
 
 AC_CHECK_TOOL(AS, as)
 AC_CHECK_TOOL(AR, ar)