aboutsummaryrefslogtreecommitdiff
path: root/libdecnumber
diff options
context:
space:
mode:
Diffstat (limited to 'libdecnumber')
-rw-r--r--libdecnumber/ChangeLog10
-rw-r--r--libdecnumber/Makefile.in3
-rw-r--r--libdecnumber/aclocal.m42
-rwxr-xr-xlibdecnumber/configure154
-rw-r--r--libdecnumber/configure.ac12
5 files changed, 180 insertions, 1 deletions
diff --git a/libdecnumber/ChangeLog b/libdecnumber/ChangeLog
index 9fe1464..6bdc757 100644
--- a/libdecnumber/ChangeLog
+++ b/libdecnumber/ChangeLog
@@ -1,3 +1,13 @@
+2020-05-12 H.J. Lu <hongjiu.lu@intel.com>
+
+ * Makefile.in (CET_HOST_FLAGS): New.
+ (COMPILER): Add $(CET_HOST_FLAGS).
+ * configure.ac: Add GCC_CET_HOST_FLAGS(CET_HOST_FLAGS) and
+ AC_SUBST(CET_HOST_FLAGS). Clear CET_HOST_FLAGS if jit isn't
+ enabled.
+ * aclocal.m4: Regenerated.
+ * configure: Likewise.
+
2020-01-01 Jakub Jelinek <jakub@redhat.com>
Update copyright years.
diff --git a/libdecnumber/Makefile.in b/libdecnumber/Makefile.in
index a97aa0b..9260b48 100644
--- a/libdecnumber/Makefile.in
+++ b/libdecnumber/Makefile.in
@@ -41,6 +41,7 @@ LDFLAGS = @LDFLAGS@
LIBICONV = @LIBICONV@
PACKAGE = @PACKAGE@
PICFLAG = @PICFLAG@
+CET_HOST_FLAGS = @CET_HOST_FLAGS@
RANLIB = @RANLIB@
SHELL = @SHELL@
objext = @OBJEXT@
@@ -60,7 +61,7 @@ enable_decimal_float= @enable_decimal_float@
INCLUDES = -I$(srcdir) -I.
ALL_CFLAGS = $(CFLAGS) $(WARN_CFLAGS) $(NOLTO_FLAGS) $(INCLUDES) $(CPPFLAGS) \
- $(PICFLAG)
+ $(PICFLAG) $(CET_HOST_FLAGS)
bid_OBJS = bid2dpd_dpd2bid.$(objext) host-ieee32.$(objext) \
host-ieee64.$(objext) host-ieee128.$(objext)
diff --git a/libdecnumber/aclocal.m4 b/libdecnumber/aclocal.m4
index 749c903..fe9f8b4 100644
--- a/libdecnumber/aclocal.m4
+++ b/libdecnumber/aclocal.m4
@@ -12,6 +12,8 @@
# PARTICULAR PURPOSE.
m4_ifndef([AC_CONFIG_MACRO_DIRS], [m4_defun([_AM_CONFIG_MACRO_DIRS], [])m4_defun([AC_CONFIG_MACRO_DIRS], [_AM_CONFIG_MACRO_DIRS($@)])])
+m4_include([../config/cet.m4])
m4_include([../config/dfp.m4])
+m4_include([../config/enable.m4])
m4_include([../config/stdint.m4])
m4_include([../config/warnings.m4])
diff --git a/libdecnumber/configure b/libdecnumber/configure
index 14c103a..b454278 100755
--- a/libdecnumber/configure
+++ b/libdecnumber/configure
@@ -624,6 +624,7 @@ ac_includes_default="\
ac_subst_vars='LTLIBOBJS
LIBOBJS
+CET_HOST_FLAGS
PICFLAG
ADDITIONAL_OBJS
enable_decimal_float
@@ -704,6 +705,7 @@ enable_werror_always
enable_maintainer_mode
enable_decimal_float
enable_host_shared
+enable_cet
'
ac_precious_vars='build_alias
host_alias
@@ -1335,6 +1337,7 @@ Optional Features:
or 'dpd' choses which decimal floating point format
to use
--enable-host-shared build host code as shared libraries
+ --enable-cet enable Intel CET in host libraries [default=auto]
Some influential environment variables:
CC C compiler command
@@ -5050,6 +5053,157 @@ fi
+# Enable Intel CET on Intel CET enabled host if jit 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; }
+
+case "$host" in
+ i[34567]86-*-linux* | x86_64-*-linux*)
+ may_have_cet=yes
+ save_CFLAGS="$CFLAGS"
+ CFLAGS="$CFLAGS -fcf-protection"
+ case "$enable_cet" in
+ auto)
+ # Check if target supports multi-byte NOPs
+ # and if assembler supports CET insn.
+ 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
+ ;;
+ 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
+ CFLAGS="$save_CFLAGS"
+ ;;
+ *)
+ may_have_cet=no
+ enable_cet=no
+ ;;
+esac
+
+if test x$may_have_cet = xyes; then
+ save_LDFLAGS="$LDFLAGS"
+ LDFLAGS="$LDFLAGS -Wl,-z,ibt,-z,shstk"
+ if test "$cross_compiling" = yes; then :
+ { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+as_fn_error $? "cannot run test program while cross compiling
+See \`config.log' for more details" "$LINENO" 5; }
+else
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+
+static void
+foo (void)
+{
+}
+
+static void
+__attribute__ ((noinline, noclone))
+xxx (void (*f) (void))
+{
+ f ();
+}
+
+static void
+__attribute__ ((noinline, noclone))
+bar (void)
+{
+ xxx (foo);
+}
+
+int
+main ()
+{
+ bar ();
+ return 0;
+}
+
+_ACEOF
+if ac_fn_c_try_run "$LINENO"; then :
+ have_cet=no
+else
+ have_cet=yes
+fi
+rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
+ conftest.$ac_objext conftest.beam conftest.$ac_ext
+fi
+
+ LDFLAGS="$save_LDFLAGS"
+ if test x$enable_cet = xno -a x$have_cet = xyes; then
+ as_fn_error $? "Intel CET must be enabled on Intel CET enabled host" "$LINENO" 5
+ fi
+fi
+if test x$enable_cet = xyes; then
+ CET_HOST_FLAGS="-fcf-protection"
+ { $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
+
+case x$enable_languages in
+*jit*)
+ ;;
+*)
+ CET_HOST_FLAGS=
+ ;;
+esac
+
+
+
# Output.
ac_config_headers="$ac_config_headers config.h:config.in"
diff --git a/libdecnumber/configure.ac b/libdecnumber/configure.ac
index 45449cd..de7e008 100644
--- a/libdecnumber/configure.ac
+++ b/libdecnumber/configure.ac
@@ -103,6 +103,18 @@ AC_ARG_ENABLE(host-shared,
[PICFLAG=-fPIC], [PICFLAG=])
AC_SUBST(PICFLAG)
+# Enable Intel CET on Intel CET enabled host if jit is enabled.
+GCC_CET_HOST_FLAGS(CET_HOST_FLAGS)
+case x$enable_languages in
+*jit*)
+ ;;
+*)
+ CET_HOST_FLAGS=
+ ;;
+esac
+AC_SUBST(CET_HOST_FLAGS)
+
+
# Output.
AC_CONFIG_HEADERS(config.h:config.in, [echo timestamp > stamp-h1])