From 08c1d39d3a822dfe7d91524ec290e0f230504242 Mon Sep 17 00:00:00 2001 From: "H.J. Lu" Date: Fri, 8 May 2020 15:11:24 -0700 Subject: libphobos: Add --enable-cet to configure When --enable-cet is used to configure GCC, enable Intel CET in libphobos. * Makefile.am (AM_MAKEFLAGS): Add $(CET_FLAGS) to GCC FLAGS. * configure.ac (CET_FLAGS): Add GCC_CET_FLAGS and AC_SUBST. * Makefile.in: Regenerated. * aclocal.m4: Likewise. * configure.ac: Likewise. --- libphobos/ChangeLog | 8 +++++ libphobos/Makefile.am | 10 +++--- libphobos/Makefile.in | 11 +++--- libphobos/aclocal.m4 | 2 ++ libphobos/configure | 91 ++++++++++++++++++++++++++++++++++++++++++++++++-- libphobos/configure.ac | 4 +++ 6 files changed, 114 insertions(+), 12 deletions(-) (limited to 'libphobos') diff --git a/libphobos/ChangeLog b/libphobos/ChangeLog index 1ba53705b51..6a174beda75 100644 --- a/libphobos/ChangeLog +++ b/libphobos/ChangeLog @@ -1,3 +1,11 @@ +2020-05-08 H.J. Lu + + * Makefile.am (AM_MAKEFLAGS): Add $(CET_FLAGS) to GCC FLAGS. + * configure.ac (CET_FLAGS): Add GCC_CET_FLAGS and AC_SUBST. + * Makefile.in: Regenerated. + * aclocal.m4: Likewise. + * configure.ac: Likewise. + 2020-04-30 Iain Buclaw * libdruntime/Makefile.am (DRUNTIME_SOURCES_CONFIGURED): Remove diff --git a/libphobos/Makefile.am b/libphobos/Makefile.am index 874b3a25d02..84d80016025 100644 --- a/libphobos/Makefile.am +++ b/libphobos/Makefile.am @@ -33,14 +33,14 @@ AM_MAKEFLAGS = \ "AR_FLAGS=$(AR_FLAGS)" \ "CC_FOR_BUILD=$(CC_FOR_BUILD)" \ "CC_FOR_TARGET=$(CC_FOR_TARGET)" \ - "CCASFLAGS=$(CCASFLAGS)" \ - "CFLAGS=$(CFLAGS)" \ - "CXXFLAGS=$(CXXFLAGS)" \ + "CCASFLAGS=$(CCASFLAGS) $(CET_FLAGS)" \ + "CFLAGS=$(CFLAGS) $(CET_FLAGS)" \ + "CXXFLAGS=$(CXXFLAGS) $(CET_FLAGS)" \ "CFLAGS_FOR_BUILD=$(CFLAGS_FOR_BUILD)" \ - "CFLAGS_FOR_TARGET=$(CFLAGS_FOR_TARGET)" \ + "CFLAGS_FOR_TARGET=$(CFLAGS_FOR_TARGET) $(CET_FLAGS)" \ "GDC_FOR_TARGET=$(GDC_FOR_TARGET)" \ "GDC=$(GDC)" \ - "GDCFLAGS=$(GDCFLAGS)" \ + "GDCFLAGS=$(GDCFLAGS) $(CET_FLAGS)" \ "INSTALL=$(INSTALL)" \ "INSTALL_DATA=$(INSTALL_DATA)" \ "INSTALL_PROGRAM=$(INSTALL_PROGRAM)" \ diff --git a/libphobos/Makefile.in b/libphobos/Makefile.in index e51c2158b20..4806f69f406 100644 --- a/libphobos/Makefile.in +++ b/libphobos/Makefile.in @@ -205,6 +205,7 @@ CC = @CC@ CCAS = @CCAS@ CCASFLAGS = @CCASFLAGS@ CC_FOR_BUILD = @CC_FOR_BUILD@ +CET_FLAGS = @CET_FLAGS@ CFLAGS = @CFLAGS@ CFLAGS_FOR_BUILD = @CFLAGS_FOR_BUILD@ CHECKING_DFLAGS = @CHECKING_DFLAGS@ @@ -351,14 +352,14 @@ AM_MAKEFLAGS = \ "AR_FLAGS=$(AR_FLAGS)" \ "CC_FOR_BUILD=$(CC_FOR_BUILD)" \ "CC_FOR_TARGET=$(CC_FOR_TARGET)" \ - "CCASFLAGS=$(CCASFLAGS)" \ - "CFLAGS=$(CFLAGS)" \ - "CXXFLAGS=$(CXXFLAGS)" \ + "CCASFLAGS=$(CCASFLAGS) $(CET_FLAGS)" \ + "CFLAGS=$(CFLAGS) $(CET_FLAGS)" \ + "CXXFLAGS=$(CXXFLAGS) $(CET_FLAGS)" \ "CFLAGS_FOR_BUILD=$(CFLAGS_FOR_BUILD)" \ - "CFLAGS_FOR_TARGET=$(CFLAGS_FOR_TARGET)" \ + "CFLAGS_FOR_TARGET=$(CFLAGS_FOR_TARGET) $(CET_FLAGS)" \ "GDC_FOR_TARGET=$(GDC_FOR_TARGET)" \ "GDC=$(GDC)" \ - "GDCFLAGS=$(GDCFLAGS)" \ + "GDCFLAGS=$(GDCFLAGS) $(CET_FLAGS)" \ "INSTALL=$(INSTALL)" \ "INSTALL_DATA=$(INSTALL_DATA)" \ "INSTALL_PROGRAM=$(INSTALL_PROGRAM)" \ diff --git a/libphobos/aclocal.m4 b/libphobos/aclocal.m4 index 899592de394..b2e1cbf0197 100644 --- a/libphobos/aclocal.m4 +++ b/libphobos/aclocal.m4 @@ -873,6 +873,8 @@ AC_SUBST([am__untar]) ]) # _AM_PROG_TAR m4_include([../config/acx.m4]) +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/libphobos/configure b/libphobos/configure index e461c7442b2..c8137d4d572 100755 --- a/libphobos/configure +++ b/libphobos/configure @@ -722,6 +722,7 @@ LIBTOOL CFLAGS_FOR_BUILD CC_FOR_BUILD AR +CET_FLAGS RANLIB MAINT MAINTAINER_MODE_FALSE @@ -824,6 +825,7 @@ enable_option_checking enable_multilib enable_silent_rules enable_maintainer_mode +enable_cet enable_shared enable_static with_pic @@ -1476,6 +1478,7 @@ Optional Features: --enable-maintainer-mode enable make rules and dependencies not useful (and sometimes confusing) to the casual installer + --enable-cet enable Intel CET in target libraries [default=no] --enable-shared[=PKGS] build shared libraries [default=yes] --enable-static[=PKGS] build static libraries [default=yes] --enable-fast-install[=PKGS] @@ -5560,6 +5563,90 @@ $as_echo "no" >&6; } 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|auto) ;; + *) as_fn_error $? "Unknown argument to enable/disable cet" "$LINENO" 5 ;; + esac + +else + enable_cet=no +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*) + 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 + ;; + *) + enable_cet=no + ;; +esac +if test x$enable_cet = xyes; then + CET_FLAGS="-fcf-protection -mshstk" + { $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 + + + # This should be inherited in the recursive make, but ensure it is defined. test "$AR" || AR=ar @@ -11647,7 +11734,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 11650 "configure" +#line 11737 "configure" #include "confdefs.h" #if HAVE_DLFCN_H @@ -11753,7 +11840,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 11756 "configure" +#line 11843 "configure" #include "confdefs.h" #if HAVE_DLFCN_H diff --git a/libphobos/configure.ac b/libphobos/configure.ac index c21da5908d0..ec8a30ea511 100644 --- a/libphobos/configure.ac +++ b/libphobos/configure.ac @@ -65,6 +65,10 @@ AC_PROG_RANLIB AC_PROG_INSTALL AC_PROG_MAKE_SET +# Add CET specific flags if CET is enabled +GCC_CET_FLAGS(CET_FLAGS) +AC_SUBST(CET_FLAGS) + # This should be inherited in the recursive make, but ensure it is defined. test "$AR" || AR=ar AC_SUBST(AR) -- cgit v1.2.3