diff mbox series

Enable CET in cross compiler if possible

Message ID 20200508131105.170077-1-hjl.tools@gmail.com
State New
Headers show
Series Enable CET in cross compiler if possible | expand

Commit Message

H.J. Lu May 8, 2020, 1:11 p.m. UTC
Don't perform CET run-time check for host when cross compiling.  Instead,
enable CET in cross compiler if possible so that it will run on both CET
and non-CET hosts.

config/

	PR bootstrap/94998
	* cet.m4 (GCC_CET_HOST_FLAGS): Enable CET in cross compiler if
	possible.

libiberty/

	PR bootstrap/94998
	* configure: Regenerated.

lto-plugin/

	PR bootstrap/94998
	* configure: Regenerated.
---
 config/cet.m4        | 18 ++++++++++++------
 libiberty/configure  | 12 +++++++++---
 lto-plugin/configure | 16 +++++++++++-----
 3 files changed, 32 insertions(+), 14 deletions(-)

Comments

H.J. Lu May 12, 2020, 1:32 p.m. UTC | #1
On Fri, May 8, 2020 at 6:11 AM H.J. Lu <hjl.tools@gmail.com> wrote:
>
> Don't perform CET run-time check for host when cross compiling.  Instead,
> enable CET in cross compiler if possible so that it will run on both CET
> and non-CET hosts.
>
> config/
>
>         PR bootstrap/94998
>         * cet.m4 (GCC_CET_HOST_FLAGS): Enable CET in cross compiler if
>         possible.
>
> libiberty/
>
>         PR bootstrap/94998
>         * configure: Regenerated.
>
> lto-plugin/
>
>         PR bootstrap/94998
>         * configure: Regenerated.
> ---
>  config/cet.m4        | 18 ++++++++++++------
>  libiberty/configure  | 12 +++++++++---
>  lto-plugin/configure | 16 +++++++++++-----
>  3 files changed, 32 insertions(+), 14 deletions(-)
>
> diff --git a/config/cet.m4 b/config/cet.m4
> index ea616b728a9..d9608699cd5 100644
> --- a/config/cet.m4
> +++ b/config/cet.m4
> @@ -111,7 +111,8 @@ if test x$may_have_cet = xyes; then
>  fi
>
>  if test x$may_have_cet = xyes; then
> -  AC_TRY_RUN([
> +  if test x$cross_compiling = xno; then
> +    AC_TRY_RUN([
>  static void
>  foo (void)
>  {
> @@ -137,12 +138,17 @@ main ()
>    bar ();
>    return 0;
>  }
> -  ],
> -  [have_cet=no],
> -  [have_cet=yes])
> -  if test x$enable_cet = xno -a x$have_cet = xyes; then
> -    AC_MSG_ERROR([Intel CET must be enabled on Intel CET enabled host])
> +    ],
> +    [have_cet=no],
> +    [have_cet=yes])
> +    if test x$enable_cet = xno -a x$have_cet = xyes; then
> +      AC_MSG_ERROR([Intel CET must be enabled on Intel CET enabled host])
> +    fi
>    fi
> +else
> +  # Enable CET in cross compiler if possible so that it will run on both
> +  # CET and non-CET hosts.
> +  have_cet=yes
>  fi
>  if test x$enable_cet = xyes; then
>    $1="-fcf-protection"
> diff --git a/libiberty/configure b/libiberty/configure
> index bb76cf1b823..3f82c5bb865 100755
> --- a/libiberty/configure
> +++ b/libiberty/configure
> @@ -5375,7 +5375,8 @@ rm -f core conftest.err conftest.$ac_objext \
>  fi
>
>  if test x$may_have_cet = xyes; then
> -  if test "$cross_compiling" = yes; then :
> +  if test x$cross_compiling = xno; then
> +    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
> @@ -5420,9 +5421,14 @@ rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
>    conftest.$ac_objext conftest.beam conftest.$ac_ext
>  fi
>
> -  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
> +    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
> +else
> +  # Enable CET in cross compiler if possible so that it will run on both
> +  # CET and non-CET hosts.
> +  have_cet=yes
>  fi
>  if test x$enable_cet = xyes; then
>    CET_HOST_FLAGS="-fcf-protection"
> diff --git a/lto-plugin/configure b/lto-plugin/configure
> index 1baf6cc70b8..36c6ecc5875 100755
> --- a/lto-plugin/configure
> +++ b/lto-plugin/configure
> @@ -5768,7 +5768,8 @@ rm -f core conftest.err conftest.$ac_objext \
>  fi
>
>  if test x$may_have_cet = xyes; then
> -  if test "$cross_compiling" = yes; then :
> +  if test x$cross_compiling = xno; then
> +    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
> @@ -5813,9 +5814,14 @@ rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
>    conftest.$ac_objext conftest.beam conftest.$ac_ext
>  fi
>
> -  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
> +    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
> +else
> +  # Enable CET in cross compiler if possible so that it will run on both
> +  # CET and non-CET hosts.
> +  have_cet=yes
>  fi
>  if test x$enable_cet = xyes; then
>    CET_HOST_FLAGS="-fcf-protection"
> @@ -11941,7 +11947,7 @@ else
>    lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
>    lt_status=$lt_dlunknown
>    cat > conftest.$ac_ext <<_LT_EOF
> -#line 11944 "configure"
> +#line 11950 "configure"
>  #include "confdefs.h"
>
>  #if HAVE_DLFCN_H
> @@ -12047,7 +12053,7 @@ else
>    lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
>    lt_status=$lt_dlunknown
>    cat > conftest.$ac_ext <<_LT_EOF
> -#line 12050 "configure"
> +#line 12056 "configure"
>  #include "confdefs.h"
>
>  #if HAVE_DLFCN_H
> --
> 2.26.2
>

PING.

This fixes a regression on master and GCC 10 branch.
Li, Pan2 via Gcc-patches May 12, 2020, 5:28 p.m. UTC | #2
On Fri, 2020-05-08 at 06:11 -0700, H.J. Lu via Gcc-patches wrote:
> Don't perform CET run-time check for host when cross compiling.  Instead,
> enable CET in cross compiler if possible so that it will run on both CET
> and non-CET hosts.
> 
> config/
> 
> 	PR bootstrap/94998
> 	* cet.m4 (GCC_CET_HOST_FLAGS): Enable CET in cross compiler if
> 	possible.
> 
> libiberty/
> 
> 	PR bootstrap/94998
> 	* configure: Regenerated.
> 
> lto-plugin/
> 
> 	PR bootstrap/94998
> 	* configure: Regenerated.
OK
jeff
>
H.J. Lu June 5, 2020, 3:18 p.m. UTC | #3
On Tue, May 12, 2020 at 10:28 AM Jeff Law <law@redhat.com> wrote:
>
> On Fri, 2020-05-08 at 06:11 -0700, H.J. Lu via Gcc-patches wrote:
> > Don't perform CET run-time check for host when cross compiling.  Instead,
> > enable CET in cross compiler if possible so that it will run on both CET
> > and non-CET hosts.
> >
> > config/
> >
> >       PR bootstrap/94998
> >       * cet.m4 (GCC_CET_HOST_FLAGS): Enable CET in cross compiler if
> >       possible.
> >
> > libiberty/
> >
> >       PR bootstrap/94998
> >       * configure: Regenerated.
> >
> > lto-plugin/
> >
> >       PR bootstrap/94998
> >       * configure: Regenerated.
> OK
> jeff

OK for backport to GCC 10?

Thanks.
Li, Pan2 via Gcc-patches June 9, 2020, 7:43 p.m. UTC | #4
On Fri, 2020-06-05 at 08:18 -0700, H.J. Lu wrote:
> On Tue, May 12, 2020 at 10:28 AM Jeff Law <law@redhat.com> wrote:
> > On Fri, 2020-05-08 at 06:11 -0700, H.J. Lu via Gcc-patches wrote:
> > > Don't perform CET run-time check for host when cross compiling.  Instead,
> > > enable CET in cross compiler if possible so that it will run on both CET
> > > and non-CET hosts.
> > > 
> > > config/
> > > 
> > >       PR bootstrap/94998
> > >       * cet.m4 (GCC_CET_HOST_FLAGS): Enable CET in cross compiler if
> > >       possible.
> > > 
> > > libiberty/
> > > 
> > >       PR bootstrap/94998
> > >       * configure: Regenerated.
> > > 
> > > lto-plugin/
> > > 
> > >       PR bootstrap/94998
> > >       * configure: Regenerated.
> > OK
> > jeff
> 
> OK for backport to GCC 10?
ISTM it doesn't meet the general criteria for backports, specifically it doesn't
fix a regression.  ISTM that the release managers would need to ACK for a
backport.

jeff
diff mbox series

Patch

diff --git a/config/cet.m4 b/config/cet.m4
index ea616b728a9..d9608699cd5 100644
--- a/config/cet.m4
+++ b/config/cet.m4
@@ -111,7 +111,8 @@  if test x$may_have_cet = xyes; then
 fi
 
 if test x$may_have_cet = xyes; then
-  AC_TRY_RUN([
+  if test x$cross_compiling = xno; then
+    AC_TRY_RUN([
 static void
 foo (void)
 {
@@ -137,12 +138,17 @@  main ()
   bar ();
   return 0;
 }
-  ],
-  [have_cet=no],
-  [have_cet=yes])
-  if test x$enable_cet = xno -a x$have_cet = xyes; then
-    AC_MSG_ERROR([Intel CET must be enabled on Intel CET enabled host])
+    ],
+    [have_cet=no],
+    [have_cet=yes])
+    if test x$enable_cet = xno -a x$have_cet = xyes; then
+      AC_MSG_ERROR([Intel CET must be enabled on Intel CET enabled host])
+    fi
   fi
+else
+  # Enable CET in cross compiler if possible so that it will run on both
+  # CET and non-CET hosts.
+  have_cet=yes
 fi
 if test x$enable_cet = xyes; then
   $1="-fcf-protection"
diff --git a/libiberty/configure b/libiberty/configure
index bb76cf1b823..3f82c5bb865 100755
--- a/libiberty/configure
+++ b/libiberty/configure
@@ -5375,7 +5375,8 @@  rm -f core conftest.err conftest.$ac_objext \
 fi
 
 if test x$may_have_cet = xyes; then
-  if test "$cross_compiling" = yes; then :
+  if test x$cross_compiling = xno; then
+    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
@@ -5420,9 +5421,14 @@  rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
   conftest.$ac_objext conftest.beam conftest.$ac_ext
 fi
 
-  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
+    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
+else
+  # Enable CET in cross compiler if possible so that it will run on both
+  # CET and non-CET hosts.
+  have_cet=yes
 fi
 if test x$enable_cet = xyes; then
   CET_HOST_FLAGS="-fcf-protection"
diff --git a/lto-plugin/configure b/lto-plugin/configure
index 1baf6cc70b8..36c6ecc5875 100755
--- a/lto-plugin/configure
+++ b/lto-plugin/configure
@@ -5768,7 +5768,8 @@  rm -f core conftest.err conftest.$ac_objext \
 fi
 
 if test x$may_have_cet = xyes; then
-  if test "$cross_compiling" = yes; then :
+  if test x$cross_compiling = xno; then
+    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
@@ -5813,9 +5814,14 @@  rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
   conftest.$ac_objext conftest.beam conftest.$ac_ext
 fi
 
-  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
+    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
+else
+  # Enable CET in cross compiler if possible so that it will run on both
+  # CET and non-CET hosts.
+  have_cet=yes
 fi
 if test x$enable_cet = xyes; then
   CET_HOST_FLAGS="-fcf-protection"
@@ -11941,7 +11947,7 @@  else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 11944 "configure"
+#line 11950 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -12047,7 +12053,7 @@  else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 12050 "configure"
+#line 12056 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H