x86: Also check if -fcf-protection works

Message ID 20200515131638.282949-1-hjl.tools@gmail.com
State New
Headers show
Series
  • x86: Also check if -fcf-protection works
Related show

Commit Message

Christophe Lyon via Gcc-patches May 15, 2020, 1:16 p.m.
When defaulting CET run-time support to auto, check if -fcf-protection
works.  Even if the stage1 GCC doesn't support -fcf-protection, since
the final GCC does, CET run-time support will be enabled by default if
binutils support CET.

config/

	PR bootstrap/95147
	* cet.m4 (GCC_CET_FLAGS): Also check if -fcf-protection works
	when defaulting to auto.

libatomic/

	PR bootstrap/95147
	* configure: Regenerated.

libbacktrace/

	PR bootstrap/95147
	* configure: Regenerated.

libgcc/

	PR bootstrap/95147
	* configure: Regenerated.

libgfortran/

	PR bootstrap/95147
	* configure: Regenerated.

libgomp/

	PR bootstrap/95147
	* configure: Regenerated.

libitm/

	PR bootstrap/95147
	* configure: Regenerated.

libobjc/

	PR bootstrap/95147
	* configure: Regenerated.

libphobos/

	PR bootstrap/95147
	* configure: Regenerated.

libquadmath/

	PR bootstrap/95147
	* configure: Regenerated.

libsanitizer/

	PR bootstrap/95147
	* configure: Regenerated.

libssp/

	PR bootstrap/95147
	* configure: Regenerated.

libstdc++-v3/

	PR bootstrap/95147
	* configure: Regenerated.

libvtv/

	PR bootstrap/95147
	* configure: Regenerated.

zlib/

	PR bootstrap/95147
	* configure: Regenerated.
---
 config/cet.m4          |  3 +++
 libatomic/configure    |  3 +++
 libbacktrace/configure |  3 +++
 libgcc/configure       |  3 +++
 libgfortran/configure  |  7 +++++--
 libgomp/configure      |  3 +++
 libitm/configure       |  3 +++
 libobjc/configure      |  7 +++++--
 libphobos/configure    | 11 +++++++----
 libquadmath/configure  |  3 +++
 libsanitizer/configure |  3 +++
 libssp/configure       |  7 +++++--
 libstdc++-v3/configure |  3 +++
 libvtv/configure       |  3 +++
 zlib/configure         |  7 +++++--
 15 files changed, 57 insertions(+), 12 deletions(-)

-- 
2.26.2

Comments

Richard Biener May 15, 2020, 3:33 p.m. | #1
On May 15, 2020 3:16:38 PM GMT+02:00, "H.J. Lu" <hjl.tools@gmail.com> wrote:
>When defaulting CET run-time support to auto, check if -fcf-protection

>works.  Even if the stage1 GCC doesn't support -fcf-protection, since

>the final GCC does, CET run-time support will be enabled by default if

>binutils support CET.


OK. 

Richard. 

>config/

>

>	PR bootstrap/95147

>	* cet.m4 (GCC_CET_FLAGS): Also check if -fcf-protection works

>	when defaulting to auto.

>

>libatomic/

>

>	PR bootstrap/95147

>	* configure: Regenerated.

>

>libbacktrace/

>

>	PR bootstrap/95147

>	* configure: Regenerated.

>

>libgcc/

>

>	PR bootstrap/95147

>	* configure: Regenerated.

>

>libgfortran/

>

>	PR bootstrap/95147

>	* configure: Regenerated.

>

>libgomp/

>

>	PR bootstrap/95147

>	* configure: Regenerated.

>

>libitm/

>

>	PR bootstrap/95147

>	* configure: Regenerated.

>

>libobjc/

>

>	PR bootstrap/95147

>	* configure: Regenerated.

>

>libphobos/

>

>	PR bootstrap/95147

>	* configure: Regenerated.

>

>libquadmath/

>

>	PR bootstrap/95147

>	* configure: Regenerated.

>

>libsanitizer/

>

>	PR bootstrap/95147

>	* configure: Regenerated.

>

>libssp/

>

>	PR bootstrap/95147

>	* configure: Regenerated.

>

>libstdc++-v3/

>

>	PR bootstrap/95147

>	* configure: Regenerated.

>

>libvtv/

>

>	PR bootstrap/95147

>	* configure: Regenerated.

>

>zlib/

>

>	PR bootstrap/95147

>	* configure: Regenerated.

>---

> config/cet.m4          |  3 +++

> libatomic/configure    |  3 +++

> libbacktrace/configure |  3 +++

> libgcc/configure       |  3 +++

> libgfortran/configure  |  7 +++++--

> libgomp/configure      |  3 +++

> libitm/configure       |  3 +++

> libobjc/configure      |  7 +++++--

> libphobos/configure    | 11 +++++++----

> libquadmath/configure  |  3 +++

> libsanitizer/configure |  3 +++

> libssp/configure       |  7 +++++--

> libstdc++-v3/configure |  3 +++

> libvtv/configure       |  3 +++

> zlib/configure         |  7 +++++--

> 15 files changed, 57 insertions(+), 12 deletions(-)

>

>diff --git a/config/cet.m4 b/config/cet.m4

>index 63c6ea9ee02..2bb2c8a95ac 100644

>--- a/config/cet.m4

>+++ b/config/cet.m4

>@@ -13,6 +13,8 @@ case "$host" in

>       auto)

> 	# Check if target supports multi-byte NOPs

> 	# and if assembler supports CET insn.

>+	save_CFLAGS="$CFLAGS"

>+	CFLAGS="$CFLAGS -fcf-protection"

> 	AC_COMPILE_IFELSE(

> 	 [AC_LANG_PROGRAM(

> 	  [],

>@@ -25,6 +27,7 @@ asm ("setssbsy");

> 	  ])],

> 	 [enable_cet=yes],

> 	 [enable_cet=no])

>+	CFLAGS="$save_CFLAGS"

> 	;;

>       yes)

> 	# Check if assembler supports CET.

>diff --git a/libatomic/configure b/libatomic/configure

>index c4b4714abc0..478670a6fe7 100755

>--- a/libatomic/configure

>+++ b/libatomic/configure

>@@ -15595,6 +15595,8 @@ case "$host" in

>       auto)

> 	# Check if target supports multi-byte NOPs

> 	# and if assembler supports CET insn.

>+	save_CFLAGS="$CFLAGS"

>+	CFLAGS="$CFLAGS -fcf-protection"

> 	cat confdefs.h - <<_ACEOF >conftest.$ac_ext

> /* end confdefs.h.  */

> 

>@@ -15618,6 +15620,7 @@ else

>   enable_cet=no

> fi

> rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext

>+	CFLAGS="$save_CFLAGS"

> 	;;

>       yes)

> 	# Check if assembler supports CET.

>diff --git a/libbacktrace/configure b/libbacktrace/configure

>index 95d06c60be1..d851e807d2d 100755

>--- a/libbacktrace/configure

>+++ b/libbacktrace/configure

>@@ -12169,6 +12169,8 @@ case "$host" in

>       auto)

> 	# Check if target supports multi-byte NOPs

> 	# and if assembler supports CET insn.

>+	save_CFLAGS="$CFLAGS"

>+	CFLAGS="$CFLAGS -fcf-protection"

> 	cat confdefs.h - <<_ACEOF >conftest.$ac_ext

> /* end confdefs.h.  */

> 

>@@ -12192,6 +12194,7 @@ else

>   enable_cet=no

> fi

> rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext

>+	CFLAGS="$save_CFLAGS"

> 	;;

>       yes)

> 	# Check if assembler supports CET.

>diff --git a/libgcc/configure b/libgcc/configure

>index a5d5ab84607..5d0c79bcd75 100755

>--- a/libgcc/configure

>+++ b/libgcc/configure

>@@ -4913,6 +4913,8 @@ case "$host" in

>       auto)

> 	# Check if target supports multi-byte NOPs

> 	# and if assembler supports CET insn.

>+	save_CFLAGS="$CFLAGS"

>+	CFLAGS="$CFLAGS -fcf-protection"

> 	cat confdefs.h - <<_ACEOF >conftest.$ac_ext

> /* end confdefs.h.  */

> 

>@@ -4936,6 +4938,7 @@ else

>   enable_cet=no

> fi

> rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext

>+	CFLAGS="$save_CFLAGS"

> 	;;

>       yes)

> 	# Check if assembler supports CET.

>diff --git a/libgfortran/configure b/libgfortran/configure

>index 3c8be061ede..97d9616e425 100755

>--- a/libgfortran/configure

>+++ b/libgfortran/configure

>@@ -6014,6 +6014,8 @@ case "$host" in

>       auto)

> 	# Check if target supports multi-byte NOPs

> 	# and if assembler supports CET insn.

>+	save_CFLAGS="$CFLAGS"

>+	CFLAGS="$CFLAGS -fcf-protection"

> 	cat confdefs.h - <<_ACEOF >conftest.$ac_ext

> /* end confdefs.h.  */

> 

>@@ -6037,6 +6039,7 @@ else

>   enable_cet=no

> fi

> rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext

>+	CFLAGS="$save_CFLAGS"

> 	;;

>       yes)

> 	# Check if assembler supports CET.

>@@ -12719,7 +12722,7 @@ else

>   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2

>   lt_status=$lt_dlunknown

>   cat > conftest.$ac_ext <<_LT_EOF

>-#line 12722 "configure"

>+#line 12725 "configure"

> #include "confdefs.h"

> 

> #if HAVE_DLFCN_H

>@@ -12825,7 +12828,7 @@ else

>   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2

>   lt_status=$lt_dlunknown

>   cat > conftest.$ac_ext <<_LT_EOF

>-#line 12828 "configure"

>+#line 12831 "configure"

> #include "confdefs.h"

> 

> #if HAVE_DLFCN_H

>diff --git a/libgomp/configure b/libgomp/configure

>index 4a0e1498415..e5710b26749 100755

>--- a/libgomp/configure

>+++ b/libgomp/configure

>@@ -16753,6 +16753,8 @@ case "$host" in

>       auto)

> 	# Check if target supports multi-byte NOPs

> 	# and if assembler supports CET insn.

>+	save_CFLAGS="$CFLAGS"

>+	CFLAGS="$CFLAGS -fcf-protection"

> 	cat confdefs.h - <<_ACEOF >conftest.$ac_ext

> /* end confdefs.h.  */

> 

>@@ -16776,6 +16778,7 @@ else

>   enable_cet=no

> fi

> rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext

>+	CFLAGS="$save_CFLAGS"

> 	;;

>       yes)

> 	# Check if assembler supports CET.

>diff --git a/libitm/configure b/libitm/configure

>index 2c451fb0a98..be70ea6f76f 100755

>--- a/libitm/configure

>+++ b/libitm/configure

>@@ -17890,6 +17890,8 @@ case "$host" in

>       auto)

> 	# Check if target supports multi-byte NOPs

> 	# and if assembler supports CET insn.

>+	save_CFLAGS="$CFLAGS"

>+	CFLAGS="$CFLAGS -fcf-protection"

> 	cat confdefs.h - <<_ACEOF >conftest.$ac_ext

> /* end confdefs.h.  */

> 

>@@ -17913,6 +17915,7 @@ else

>   enable_cet=no

> fi

> rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext

>+	CFLAGS="$save_CFLAGS"

> 	;;

>       yes)

> 	# Check if assembler supports CET.

>diff --git a/libobjc/configure b/libobjc/configure

>index 018c9db76e8..6975a727d5e 100755

>--- a/libobjc/configure

>+++ b/libobjc/configure

>@@ -3466,6 +3466,8 @@ case "$host" in

>       auto)

> 	# Check if target supports multi-byte NOPs

> 	# and if assembler supports CET insn.

>+	save_CFLAGS="$CFLAGS"

>+	CFLAGS="$CFLAGS -fcf-protection"

> 	cat confdefs.h - <<_ACEOF >conftest.$ac_ext

> /* end confdefs.h.  */

> 

>@@ -3489,6 +3491,7 @@ else

>   enable_cet=no

> fi

> rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext

>+	CFLAGS="$save_CFLAGS"

> 	;;

>       yes)

> 	# Check if assembler supports CET.

>@@ -10775,7 +10778,7 @@ else

>   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2

>   lt_status=$lt_dlunknown

>   cat > conftest.$ac_ext <<_LT_EOF

>-#line 10778 "configure"

>+#line 10781 "configure"

> #include "confdefs.h"

> 

> #if HAVE_DLFCN_H

>@@ -10881,7 +10884,7 @@ else

>   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2

>   lt_status=$lt_dlunknown

>   cat > conftest.$ac_ext <<_LT_EOF

>-#line 10884 "configure"

>+#line 10887 "configure"

> #include "confdefs.h"

> 

> #if HAVE_DLFCN_H

>diff --git a/libphobos/configure b/libphobos/configure

>index c8137d4d572..4551e9fddef 100755

>--- a/libphobos/configure

>+++ b/libphobos/configure

>@@ -1478,7 +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-cet            enable Intel CET in target libraries

>[default=auto]

>   --enable-shared[=PKGS]  build shared libraries [default=yes]

>   --enable-static[=PKGS]  build static libraries [default=yes]

>   --enable-fast-install[=PKGS]

>@@ -5573,7 +5573,7 @@ if test "${enable_cet+set}" = set; then :

>                           esac

> 

> else

>-  enable_cet=no

>+  enable_cet=auto

> fi

> 

> 

>@@ -5586,6 +5586,8 @@ case "$host" in

>       auto)

> 	# Check if target supports multi-byte NOPs

> 	# and if assembler supports CET insn.

>+	save_CFLAGS="$CFLAGS"

>+	CFLAGS="$CFLAGS -fcf-protection"

> 	cat confdefs.h - <<_ACEOF >conftest.$ac_ext

> /* end confdefs.h.  */

> 

>@@ -5609,6 +5611,7 @@ else

>   enable_cet=no

> fi

> rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext

>+	CFLAGS="$save_CFLAGS"

> 	;;

>       yes)

> 	# Check if assembler supports CET.

>@@ -11734,7 +11737,7 @@ else

>   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2

>   lt_status=$lt_dlunknown

>   cat > conftest.$ac_ext <<_LT_EOF

>-#line 11737 "configure"

>+#line 11740 "configure"

> #include "confdefs.h"

> 

> #if HAVE_DLFCN_H

>@@ -11840,7 +11843,7 @@ else

>   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2

>   lt_status=$lt_dlunknown

>   cat > conftest.$ac_ext <<_LT_EOF

>-#line 11843 "configure"

>+#line 11846 "configure"

> #include "confdefs.h"

> 

> #if HAVE_DLFCN_H

>diff --git a/libquadmath/configure b/libquadmath/configure

>index d995a2cfd25..dee79cf99a0 100755

>--- a/libquadmath/configure

>+++ b/libquadmath/configure

>@@ -13039,6 +13039,8 @@ case "$host" in

>       auto)

> 	# Check if target supports multi-byte NOPs

> 	# and if assembler supports CET insn.

>+	save_CFLAGS="$CFLAGS"

>+	CFLAGS="$CFLAGS -fcf-protection"

> 	cat confdefs.h - <<_ACEOF >conftest.$ac_ext

> /* end confdefs.h.  */

> 

>@@ -13062,6 +13064,7 @@ else

>   enable_cet=no

> fi

> rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext

>+	CFLAGS="$save_CFLAGS"

> 	;;

>       yes)

> 	# Check if assembler supports CET.

>diff --git a/libsanitizer/configure b/libsanitizer/configure

>index 8d1aa6db492..7ec074491c1 100755

>--- a/libsanitizer/configure

>+++ b/libsanitizer/configure

>@@ -16862,6 +16862,8 @@ case "$host" in

>       auto)

> 	# Check if target supports multi-byte NOPs

> 	# and if assembler supports CET insn.

>+	save_CFLAGS="$CFLAGS"

>+	CFLAGS="$CFLAGS -fcf-protection"

> 	cat confdefs.h - <<_ACEOF >conftest.$ac_ext

> /* end confdefs.h.  */

> 

>@@ -16885,6 +16887,7 @@ else

>   enable_cet=no

> fi

> rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext

>+	CFLAGS="$save_CFLAGS"

> 	;;

>       yes)

> 	# Check if assembler supports CET.

>diff --git a/libssp/configure b/libssp/configure

>index 7e54b16bfaf..2eb4c7998d5 100755

>--- a/libssp/configure

>+++ b/libssp/configure

>@@ -4338,6 +4338,8 @@ case "$host" in

>       auto)

> 	# Check if target supports multi-byte NOPs

> 	# and if assembler supports CET insn.

>+	save_CFLAGS="$CFLAGS"

>+	CFLAGS="$CFLAGS -fcf-protection"

> 	cat confdefs.h - <<_ACEOF >conftest.$ac_ext

> /* end confdefs.h.  */

> 

>@@ -4361,6 +4363,7 @@ else

>   enable_cet=no

> fi

> rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext

>+	CFLAGS="$save_CFLAGS"

> 	;;

>       yes)

> 	# Check if assembler supports CET.

>@@ -10996,7 +10999,7 @@ else

>   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2

>   lt_status=$lt_dlunknown

>   cat > conftest.$ac_ext <<_LT_EOF

>-#line 10999 "configure"

>+#line 11002 "configure"

> #include "confdefs.h"

> 

> #if HAVE_DLFCN_H

>@@ -11102,7 +11105,7 @@ else

>   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2

>   lt_status=$lt_dlunknown

>   cat > conftest.$ac_ext <<_LT_EOF

>-#line 11105 "configure"

>+#line 11108 "configure"

> #include "confdefs.h"

> 

> #if HAVE_DLFCN_H

>diff --git a/libstdc++-v3/configure b/libstdc++-v3/configure

>index 24cc51c8bef..502f6602001 100755

>--- a/libstdc++-v3/configure

>+++ b/libstdc++-v3/configure

>@@ -77488,6 +77488,8 @@ case "$host" in

>       auto)

> 	# Check if target supports multi-byte NOPs

> 	# and if assembler supports CET insn.

>+	save_CFLAGS="$CFLAGS"

>+	CFLAGS="$CFLAGS -fcf-protection"

> 	cat confdefs.h - <<_ACEOF >conftest.$ac_ext

> /* end confdefs.h.  */

> 

>@@ -77511,6 +77513,7 @@ else

>   enable_cet=no

> fi

> rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext

>+	CFLAGS="$save_CFLAGS"

> 	;;

>       yes)

> 	# Check if assembler supports CET.

>diff --git a/libvtv/configure b/libvtv/configure

>index 9d42cb88fb2..eced2b23ce0 100755

>--- a/libvtv/configure

>+++ b/libvtv/configure

>@@ -15680,6 +15680,8 @@ case "$host" in

>       auto)

> 	# Check if target supports multi-byte NOPs

> 	# and if assembler supports CET insn.

>+	save_CFLAGS="$CFLAGS"

>+	CFLAGS="$CFLAGS -fcf-protection"

> 	cat confdefs.h - <<_ACEOF >conftest.$ac_ext

> /* end confdefs.h.  */

> 

>@@ -15703,6 +15705,7 @@ else

>   enable_cet=no

> fi

> rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext

>+	CFLAGS="$save_CFLAGS"

> 	;;

>       yes)

> 	# Check if assembler supports CET.

>diff --git a/zlib/configure b/zlib/configure

>index 65005f131dc..ae1f1934911 100755

>--- a/zlib/configure

>+++ b/zlib/configure

>@@ -4169,6 +4169,8 @@ case "$host" in

>       auto)

> 	# Check if target supports multi-byte NOPs

> 	# and if assembler supports CET insn.

>+	save_CFLAGS="$CFLAGS"

>+	CFLAGS="$CFLAGS -fcf-protection"

> 	cat confdefs.h - <<_ACEOF >conftest.$ac_ext

> /* end confdefs.h.  */

> 

>@@ -4192,6 +4194,7 @@ else

>   enable_cet=no

> fi

> rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext

>+	CFLAGS="$save_CFLAGS"

> 	;;

>       yes)

> 	# Check if assembler supports CET.

>@@ -10739,7 +10742,7 @@ else

>   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2

>   lt_status=$lt_dlunknown

>   cat > conftest.$ac_ext <<_LT_EOF

>-#line 10742 "configure"

>+#line 10745 "configure"

> #include "confdefs.h"

> 

> #if HAVE_DLFCN_H

>@@ -10845,7 +10848,7 @@ else

>   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2

>   lt_status=$lt_dlunknown

>   cat > conftest.$ac_ext <<_LT_EOF

>-#line 10848 "configure"

>+#line 10851 "configure"

> #include "confdefs.h"

> 

> #if HAVE_DLFCN_H

Patch

diff --git a/config/cet.m4 b/config/cet.m4
index 63c6ea9ee02..2bb2c8a95ac 100644
--- a/config/cet.m4
+++ b/config/cet.m4
@@ -13,6 +13,8 @@  case "$host" in
       auto)
 	# Check if target supports multi-byte NOPs
 	# and if assembler supports CET insn.
+	save_CFLAGS="$CFLAGS"
+	CFLAGS="$CFLAGS -fcf-protection"
 	AC_COMPILE_IFELSE(
 	 [AC_LANG_PROGRAM(
 	  [],
@@ -25,6 +27,7 @@  asm ("setssbsy");
 	  ])],
 	 [enable_cet=yes],
 	 [enable_cet=no])
+	CFLAGS="$save_CFLAGS"
 	;;
       yes)
 	# Check if assembler supports CET.
diff --git a/libatomic/configure b/libatomic/configure
index c4b4714abc0..478670a6fe7 100755
--- a/libatomic/configure
+++ b/libatomic/configure
@@ -15595,6 +15595,8 @@  case "$host" in
       auto)
 	# Check if target supports multi-byte NOPs
 	# and if assembler supports CET insn.
+	save_CFLAGS="$CFLAGS"
+	CFLAGS="$CFLAGS -fcf-protection"
 	cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 
@@ -15618,6 +15620,7 @@  else
   enable_cet=no
 fi
 rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+	CFLAGS="$save_CFLAGS"
 	;;
       yes)
 	# Check if assembler supports CET.
diff --git a/libbacktrace/configure b/libbacktrace/configure
index 95d06c60be1..d851e807d2d 100755
--- a/libbacktrace/configure
+++ b/libbacktrace/configure
@@ -12169,6 +12169,8 @@  case "$host" in
       auto)
 	# Check if target supports multi-byte NOPs
 	# and if assembler supports CET insn.
+	save_CFLAGS="$CFLAGS"
+	CFLAGS="$CFLAGS -fcf-protection"
 	cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 
@@ -12192,6 +12194,7 @@  else
   enable_cet=no
 fi
 rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+	CFLAGS="$save_CFLAGS"
 	;;
       yes)
 	# Check if assembler supports CET.
diff --git a/libgcc/configure b/libgcc/configure
index a5d5ab84607..5d0c79bcd75 100755
--- a/libgcc/configure
+++ b/libgcc/configure
@@ -4913,6 +4913,8 @@  case "$host" in
       auto)
 	# Check if target supports multi-byte NOPs
 	# and if assembler supports CET insn.
+	save_CFLAGS="$CFLAGS"
+	CFLAGS="$CFLAGS -fcf-protection"
 	cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 
@@ -4936,6 +4938,7 @@  else
   enable_cet=no
 fi
 rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+	CFLAGS="$save_CFLAGS"
 	;;
       yes)
 	# Check if assembler supports CET.
diff --git a/libgfortran/configure b/libgfortran/configure
index 3c8be061ede..97d9616e425 100755
--- a/libgfortran/configure
+++ b/libgfortran/configure
@@ -6014,6 +6014,8 @@  case "$host" in
       auto)
 	# Check if target supports multi-byte NOPs
 	# and if assembler supports CET insn.
+	save_CFLAGS="$CFLAGS"
+	CFLAGS="$CFLAGS -fcf-protection"
 	cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 
@@ -6037,6 +6039,7 @@  else
   enable_cet=no
 fi
 rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+	CFLAGS="$save_CFLAGS"
 	;;
       yes)
 	# Check if assembler supports CET.
@@ -12719,7 +12722,7 @@  else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 12722 "configure"
+#line 12725 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -12825,7 +12828,7 @@  else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 12828 "configure"
+#line 12831 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
diff --git a/libgomp/configure b/libgomp/configure
index 4a0e1498415..e5710b26749 100755
--- a/libgomp/configure
+++ b/libgomp/configure
@@ -16753,6 +16753,8 @@  case "$host" in
       auto)
 	# Check if target supports multi-byte NOPs
 	# and if assembler supports CET insn.
+	save_CFLAGS="$CFLAGS"
+	CFLAGS="$CFLAGS -fcf-protection"
 	cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 
@@ -16776,6 +16778,7 @@  else
   enable_cet=no
 fi
 rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+	CFLAGS="$save_CFLAGS"
 	;;
       yes)
 	# Check if assembler supports CET.
diff --git a/libitm/configure b/libitm/configure
index 2c451fb0a98..be70ea6f76f 100755
--- a/libitm/configure
+++ b/libitm/configure
@@ -17890,6 +17890,8 @@  case "$host" in
       auto)
 	# Check if target supports multi-byte NOPs
 	# and if assembler supports CET insn.
+	save_CFLAGS="$CFLAGS"
+	CFLAGS="$CFLAGS -fcf-protection"
 	cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 
@@ -17913,6 +17915,7 @@  else
   enable_cet=no
 fi
 rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+	CFLAGS="$save_CFLAGS"
 	;;
       yes)
 	# Check if assembler supports CET.
diff --git a/libobjc/configure b/libobjc/configure
index 018c9db76e8..6975a727d5e 100755
--- a/libobjc/configure
+++ b/libobjc/configure
@@ -3466,6 +3466,8 @@  case "$host" in
       auto)
 	# Check if target supports multi-byte NOPs
 	# and if assembler supports CET insn.
+	save_CFLAGS="$CFLAGS"
+	CFLAGS="$CFLAGS -fcf-protection"
 	cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 
@@ -3489,6 +3491,7 @@  else
   enable_cet=no
 fi
 rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+	CFLAGS="$save_CFLAGS"
 	;;
       yes)
 	# Check if assembler supports CET.
@@ -10775,7 +10778,7 @@  else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 10778 "configure"
+#line 10781 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -10881,7 +10884,7 @@  else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 10884 "configure"
+#line 10887 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
diff --git a/libphobos/configure b/libphobos/configure
index c8137d4d572..4551e9fddef 100755
--- a/libphobos/configure
+++ b/libphobos/configure
@@ -1478,7 +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-cet            enable Intel CET in target libraries [default=auto]
   --enable-shared[=PKGS]  build shared libraries [default=yes]
   --enable-static[=PKGS]  build static libraries [default=yes]
   --enable-fast-install[=PKGS]
@@ -5573,7 +5573,7 @@  if test "${enable_cet+set}" = set; then :
                           esac
 
 else
-  enable_cet=no
+  enable_cet=auto
 fi
 
 
@@ -5586,6 +5586,8 @@  case "$host" in
       auto)
 	# Check if target supports multi-byte NOPs
 	# and if assembler supports CET insn.
+	save_CFLAGS="$CFLAGS"
+	CFLAGS="$CFLAGS -fcf-protection"
 	cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 
@@ -5609,6 +5611,7 @@  else
   enable_cet=no
 fi
 rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+	CFLAGS="$save_CFLAGS"
 	;;
       yes)
 	# Check if assembler supports CET.
@@ -11734,7 +11737,7 @@  else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 11737 "configure"
+#line 11740 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -11840,7 +11843,7 @@  else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 11843 "configure"
+#line 11846 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
diff --git a/libquadmath/configure b/libquadmath/configure
index d995a2cfd25..dee79cf99a0 100755
--- a/libquadmath/configure
+++ b/libquadmath/configure
@@ -13039,6 +13039,8 @@  case "$host" in
       auto)
 	# Check if target supports multi-byte NOPs
 	# and if assembler supports CET insn.
+	save_CFLAGS="$CFLAGS"
+	CFLAGS="$CFLAGS -fcf-protection"
 	cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 
@@ -13062,6 +13064,7 @@  else
   enable_cet=no
 fi
 rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+	CFLAGS="$save_CFLAGS"
 	;;
       yes)
 	# Check if assembler supports CET.
diff --git a/libsanitizer/configure b/libsanitizer/configure
index 8d1aa6db492..7ec074491c1 100755
--- a/libsanitizer/configure
+++ b/libsanitizer/configure
@@ -16862,6 +16862,8 @@  case "$host" in
       auto)
 	# Check if target supports multi-byte NOPs
 	# and if assembler supports CET insn.
+	save_CFLAGS="$CFLAGS"
+	CFLAGS="$CFLAGS -fcf-protection"
 	cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 
@@ -16885,6 +16887,7 @@  else
   enable_cet=no
 fi
 rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+	CFLAGS="$save_CFLAGS"
 	;;
       yes)
 	# Check if assembler supports CET.
diff --git a/libssp/configure b/libssp/configure
index 7e54b16bfaf..2eb4c7998d5 100755
--- a/libssp/configure
+++ b/libssp/configure
@@ -4338,6 +4338,8 @@  case "$host" in
       auto)
 	# Check if target supports multi-byte NOPs
 	# and if assembler supports CET insn.
+	save_CFLAGS="$CFLAGS"
+	CFLAGS="$CFLAGS -fcf-protection"
 	cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 
@@ -4361,6 +4363,7 @@  else
   enable_cet=no
 fi
 rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+	CFLAGS="$save_CFLAGS"
 	;;
       yes)
 	# Check if assembler supports CET.
@@ -10996,7 +10999,7 @@  else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 10999 "configure"
+#line 11002 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -11102,7 +11105,7 @@  else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 11105 "configure"
+#line 11108 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
diff --git a/libstdc++-v3/configure b/libstdc++-v3/configure
index 24cc51c8bef..502f6602001 100755
--- a/libstdc++-v3/configure
+++ b/libstdc++-v3/configure
@@ -77488,6 +77488,8 @@  case "$host" in
       auto)
 	# Check if target supports multi-byte NOPs
 	# and if assembler supports CET insn.
+	save_CFLAGS="$CFLAGS"
+	CFLAGS="$CFLAGS -fcf-protection"
 	cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 
@@ -77511,6 +77513,7 @@  else
   enable_cet=no
 fi
 rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+	CFLAGS="$save_CFLAGS"
 	;;
       yes)
 	# Check if assembler supports CET.
diff --git a/libvtv/configure b/libvtv/configure
index 9d42cb88fb2..eced2b23ce0 100755
--- a/libvtv/configure
+++ b/libvtv/configure
@@ -15680,6 +15680,8 @@  case "$host" in
       auto)
 	# Check if target supports multi-byte NOPs
 	# and if assembler supports CET insn.
+	save_CFLAGS="$CFLAGS"
+	CFLAGS="$CFLAGS -fcf-protection"
 	cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 
@@ -15703,6 +15705,7 @@  else
   enable_cet=no
 fi
 rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+	CFLAGS="$save_CFLAGS"
 	;;
       yes)
 	# Check if assembler supports CET.
diff --git a/zlib/configure b/zlib/configure
index 65005f131dc..ae1f1934911 100755
--- a/zlib/configure
+++ b/zlib/configure
@@ -4169,6 +4169,8 @@  case "$host" in
       auto)
 	# Check if target supports multi-byte NOPs
 	# and if assembler supports CET insn.
+	save_CFLAGS="$CFLAGS"
+	CFLAGS="$CFLAGS -fcf-protection"
 	cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 
@@ -4192,6 +4194,7 @@  else
   enable_cet=no
 fi
 rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+	CFLAGS="$save_CFLAGS"
 	;;
       yes)
 	# Check if assembler supports CET.
@@ -10739,7 +10742,7 @@  else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 10742 "configure"
+#line 10745 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -10845,7 +10848,7 @@  else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 10848 "configure"
+#line 10851 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H