Andrew Geissler | c182c62 | 2020-05-15 14:13:32 -0500 | [diff] [blame] | 1 | From 87a5ace658f2294b025e0420ef03ade1f45d926c Mon Sep 17 00:00:00 2001 |
| 2 | From: "H.J. Lu" <hjl.tools@gmail.com> |
| 3 | Date: Fri, 8 May 2020 06:11:05 -0700 |
| 4 | Subject: [PATCH] Enable CET in cross compiler if possible |
| 5 | |
| 6 | Don't perform CET run-time check for host when cross compiling. Instead, |
| 7 | enable CET in cross compiler if possible so that it will run on both CET |
| 8 | and non-CET hosts. |
| 9 | |
| 10 | config/ |
| 11 | |
| 12 | PR bootstrap/94998 |
| 13 | * cet.m4 (GCC_CET_HOST_FLAGS): Enable CET in cross compiler if |
| 14 | possible. |
| 15 | |
| 16 | libiberty/ |
| 17 | |
| 18 | PR bootstrap/94998 |
| 19 | * configure: Regenerated. |
| 20 | |
| 21 | lto-plugin/ |
| 22 | |
| 23 | PR bootstrap/94998 |
| 24 | * configure: Regenerated. |
| 25 | |
| 26 | Upstream-Status: Submitted [https://patchwork.ozlabs.org/project/gcc/patch/20200508131105.170077-1-hjl.tools@gmail.com/] |
| 27 | Signed-off-by: Khem Raj <raj.khem@gmail.com> |
| 28 | --- |
| 29 | config/cet.m4 | 18 ++++++++++++------ |
| 30 | libiberty/configure | 12 +++++++++--- |
| 31 | lto-plugin/configure | 16 +++++++++++----- |
| 32 | 3 files changed, 32 insertions(+), 14 deletions(-) |
| 33 | |
| 34 | diff --git a/config/cet.m4 b/config/cet.m4 |
| 35 | index ea616b728a9..d9608699cd5 100644 |
| 36 | --- a/config/cet.m4 |
| 37 | +++ b/config/cet.m4 |
| 38 | @@ -111,7 +111,8 @@ if test x$may_have_cet = xyes; then |
| 39 | fi |
| 40 | |
| 41 | if test x$may_have_cet = xyes; then |
| 42 | - AC_TRY_RUN([ |
| 43 | + if test x$cross_compiling = xno; then |
| 44 | + AC_TRY_RUN([ |
| 45 | static void |
| 46 | foo (void) |
| 47 | { |
| 48 | @@ -137,12 +138,17 @@ main () |
| 49 | bar (); |
| 50 | return 0; |
| 51 | } |
| 52 | - ], |
| 53 | - [have_cet=no], |
| 54 | - [have_cet=yes]) |
| 55 | - if test x$enable_cet = xno -a x$have_cet = xyes; then |
| 56 | - AC_MSG_ERROR([Intel CET must be enabled on Intel CET enabled host]) |
| 57 | + ], |
| 58 | + [have_cet=no], |
| 59 | + [have_cet=yes]) |
| 60 | + if test x$enable_cet = xno -a x$have_cet = xyes; then |
| 61 | + AC_MSG_ERROR([Intel CET must be enabled on Intel CET enabled host]) |
| 62 | + fi |
| 63 | fi |
| 64 | +else |
| 65 | + # Enable CET in cross compiler if possible so that it will run on both |
| 66 | + # CET and non-CET hosts. |
| 67 | + have_cet=yes |
| 68 | fi |
| 69 | if test x$enable_cet = xyes; then |
| 70 | $1="-fcf-protection" |
| 71 | diff --git a/libiberty/configure b/libiberty/configure |
| 72 | index bb76cf1b823..3f82c5bb865 100755 |
| 73 | --- a/libiberty/configure |
| 74 | +++ b/libiberty/configure |
| 75 | @@ -5375,7 +5375,8 @@ rm -f core conftest.err conftest.$ac_objext \ |
| 76 | fi |
| 77 | |
| 78 | if test x$may_have_cet = xyes; then |
| 79 | - if test "$cross_compiling" = yes; then : |
| 80 | + if test x$cross_compiling = xno; then |
| 81 | + if test "$cross_compiling" = yes; then : |
| 82 | { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 |
| 83 | $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} |
| 84 | as_fn_error $? "cannot run test program while cross compiling |
| 85 | @@ -5420,9 +5421,14 @@ rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ |
| 86 | conftest.$ac_objext conftest.beam conftest.$ac_ext |
| 87 | fi |
| 88 | |
| 89 | - if test x$enable_cet = xno -a x$have_cet = xyes; then |
| 90 | - as_fn_error $? "Intel CET must be enabled on Intel CET enabled host" "$LINENO" 5 |
| 91 | + if test x$enable_cet = xno -a x$have_cet = xyes; then |
| 92 | + as_fn_error $? "Intel CET must be enabled on Intel CET enabled host" "$LINENO" 5 |
| 93 | + fi |
| 94 | fi |
| 95 | +else |
| 96 | + # Enable CET in cross compiler if possible so that it will run on both |
| 97 | + # CET and non-CET hosts. |
| 98 | + have_cet=yes |
| 99 | fi |
| 100 | if test x$enable_cet = xyes; then |
| 101 | CET_HOST_FLAGS="-fcf-protection" |
| 102 | diff --git a/lto-plugin/configure b/lto-plugin/configure |
| 103 | index 1baf6cc70b8..36c6ecc5875 100755 |
| 104 | --- a/lto-plugin/configure |
| 105 | +++ b/lto-plugin/configure |
| 106 | @@ -5768,7 +5768,8 @@ rm -f core conftest.err conftest.$ac_objext \ |
| 107 | fi |
| 108 | |
| 109 | if test x$may_have_cet = xyes; then |
| 110 | - if test "$cross_compiling" = yes; then : |
| 111 | + if test x$cross_compiling = xno; then |
| 112 | + if test "$cross_compiling" = yes; then : |
| 113 | { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 |
| 114 | $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} |
| 115 | as_fn_error $? "cannot run test program while cross compiling |
| 116 | @@ -5813,9 +5814,14 @@ rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ |
| 117 | conftest.$ac_objext conftest.beam conftest.$ac_ext |
| 118 | fi |
| 119 | |
| 120 | - if test x$enable_cet = xno -a x$have_cet = xyes; then |
| 121 | - as_fn_error $? "Intel CET must be enabled on Intel CET enabled host" "$LINENO" 5 |
| 122 | + if test x$enable_cet = xno -a x$have_cet = xyes; then |
| 123 | + as_fn_error $? "Intel CET must be enabled on Intel CET enabled host" "$LINENO" 5 |
| 124 | + fi |
| 125 | fi |
| 126 | +else |
| 127 | + # Enable CET in cross compiler if possible so that it will run on both |
| 128 | + # CET and non-CET hosts. |
| 129 | + have_cet=yes |
| 130 | fi |
| 131 | if test x$enable_cet = xyes; then |
| 132 | CET_HOST_FLAGS="-fcf-protection" |
| 133 | @@ -11941,7 +11947,7 @@ else |
| 134 | lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 |
| 135 | lt_status=$lt_dlunknown |
| 136 | cat > conftest.$ac_ext <<_LT_EOF |
| 137 | -#line 11944 "configure" |
| 138 | +#line 11950 "configure" |
| 139 | #include "confdefs.h" |
| 140 | |
| 141 | #if HAVE_DLFCN_H |
| 142 | @@ -12047,7 +12053,7 @@ else |
| 143 | lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 |
| 144 | lt_status=$lt_dlunknown |
| 145 | cat > conftest.$ac_ext <<_LT_EOF |
| 146 | -#line 12050 "configure" |
| 147 | +#line 12056 "configure" |
| 148 | #include "confdefs.h" |
| 149 | |
| 150 | #if HAVE_DLFCN_H |