Brad Bishop | bec4ebc | 2022-08-03 09:55:16 -0400 | [diff] [blame^] | 1 | From: Richard Purdie <richard.purdie@linuxfoundation.org> |
| 2 | Subject: [PATCH 1/5] Makefile.in: Ensure build CPP/CPPFLAGS is used for build targets |
| 3 | |
| 4 | During cross compiling, CPP is being set to the target compiler even for |
| 5 | build targets. As an example, when building a cross compiler targetting |
| 6 | mingw, the config.log for libiberty in |
| 7 | build.x86_64-pokysdk-mingw32.i586-poky-linux/build-x86_64-linux/libiberty/config.log |
| 8 | shows: |
| 9 | |
| 10 | configure:3786: checking how to run the C preprocessor |
| 11 | configure:3856: result: x86_64-pokysdk-mingw32-gcc -E --sysroot=[sysroot]/x86_64-nativesdk-mingw32-pokysdk-mingw32 |
| 12 | configure:3876: x86_64-pokysdk-mingw32-gcc -E --sysroot=[sysroot]/x86_64-nativesdk-mingw32-pokysdk-mingw32 conftest.c |
| 13 | configure:3876: $? = 0 |
| 14 | |
| 15 | This is libiberty being built for the build environment, not the target one |
| 16 | (i.e. in build-x86_64-linux). As such it should be using the build environment's |
| 17 | gcc and not the target one. In the mingw case the system headers are quite |
| 18 | different leading to build failures related to not being able to include a |
| 19 | process.h file for pem-unix.c. |
| 20 | |
| 21 | Further analysis shows the same issue occuring for CPPFLAGS too. |
| 22 | |
| 23 | Fix this by adding support for CPP_FOR_BUILD and CPPFLAGS_FOR_BUILD which |
| 24 | for example, avoids mixing the mingw headers for host binaries on linux |
| 25 | systems. |
| 26 | |
| 27 | 2021-10-27 Richard Purdie <richard.purdie@linuxfoundation.org> |
| 28 | |
| 29 | ChangeLog: |
| 30 | |
| 31 | * Makefile.tpl: Add CPP_FOR_BUILD and CPPFLAGS_FOR_BUILD support |
| 32 | * Makefile.in: Regenerate. |
| 33 | * configure: Regenerate. |
| 34 | * configure.ac: Add CPP_FOR_BUILD and CPPFLAGS_FOR_BUILD support |
| 35 | |
| 36 | gcc/ChangeLog: |
| 37 | |
| 38 | * configure: Regenerate. |
| 39 | * configure.ac: Use CPPFLAGS_FOR_BUILD for GMPINC |
| 40 | |
| 41 | Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org> |
| 42 | |
| 43 | Submitted [https://gcc.gnu.org/pipermail/gcc-patches/2021-October/582727.html] |
| 44 | Upstream-Status: Backport [https://gcc.gnu.org/git/?p=gcc.git;a=commitdiff;h=84401ce5fb4ecab55decb472b168100e7593e01f] |
| 45 | --- |
| 46 | Makefile.in | 6 ++++++ |
| 47 | Makefile.tpl | 6 ++++++ |
| 48 | configure | 4 ++++ |
| 49 | configure.ac | 4 ++++ |
| 50 | gcc/configure | 2 +- |
| 51 | gcc/configure.ac | 2 +- |
| 52 | 6 files changed, 22 insertions(+), 2 deletions(-) |
| 53 | |
| 54 | Index: gcc-11.2.0/Makefile.in |
| 55 | =================================================================== |
| 56 | --- gcc-11.2.0.orig/Makefile.in |
| 57 | +++ gcc-11.2.0/Makefile.in |
| 58 | @@ -151,6 +151,8 @@ BUILD_EXPORTS = \ |
| 59 | CC="$(CC_FOR_BUILD)"; export CC; \ |
| 60 | CFLAGS="$(CFLAGS_FOR_BUILD)"; export CFLAGS; \ |
| 61 | CONFIG_SHELL="$(SHELL)"; export CONFIG_SHELL; \ |
| 62 | + CPP="$(CPP_FOR_BUILD)"; export CPP; \ |
| 63 | + CPPFLAGS="$(CPPFLAGS_FOR_BUILD)"; export CPPFLAGS; \ |
| 64 | CXX="$(CXX_FOR_BUILD)"; export CXX; \ |
| 65 | CXXFLAGS="$(CXXFLAGS_FOR_BUILD)"; export CXXFLAGS; \ |
| 66 | GFORTRAN="$(GFORTRAN_FOR_BUILD)"; export GFORTRAN; \ |
| 67 | @@ -198,6 +200,8 @@ HOST_EXPORTS = \ |
| 68 | AR="$(AR)"; export AR; \ |
| 69 | AS="$(AS)"; export AS; \ |
| 70 | CC_FOR_BUILD="$(CC_FOR_BUILD)"; export CC_FOR_BUILD; \ |
| 71 | + CPP_FOR_BUILD="$(CPP_FOR_BUILD)"; export CPP_FOR_BUILD; \ |
| 72 | + CPPFLAGS_FOR_BUILD="$(CPPFLAGS_FOR_BUILD)"; export CPPFLAGS_FOR_BUILD; \ |
| 73 | CXX_FOR_BUILD="$(CXX_FOR_BUILD)"; export CXX_FOR_BUILD; \ |
| 74 | DLLTOOL="$(DLLTOOL)"; export DLLTOOL; \ |
| 75 | LD="$(LD)"; export LD; \ |
| 76 | @@ -353,6 +357,8 @@ AR_FOR_BUILD = @AR_FOR_BUILD@ |
| 77 | AS_FOR_BUILD = @AS_FOR_BUILD@ |
| 78 | CC_FOR_BUILD = @CC_FOR_BUILD@ |
| 79 | CFLAGS_FOR_BUILD = @CFLAGS_FOR_BUILD@ |
| 80 | +CPP_FOR_BUILD = @CPP_FOR_BUILD@ |
| 81 | +CPPFLAGS_FOR_BUILD = @CPPFLAGS_FOR_BUILD@ |
| 82 | CXXFLAGS_FOR_BUILD = @CXXFLAGS_FOR_BUILD@ |
| 83 | CXX_FOR_BUILD = @CXX_FOR_BUILD@ |
| 84 | DLLTOOL_FOR_BUILD = @DLLTOOL_FOR_BUILD@ |
| 85 | Index: gcc-11.2.0/Makefile.tpl |
| 86 | =================================================================== |
| 87 | --- gcc-11.2.0.orig/Makefile.tpl |
| 88 | +++ gcc-11.2.0/Makefile.tpl |
| 89 | @@ -154,6 +154,8 @@ BUILD_EXPORTS = \ |
| 90 | CC="$(CC_FOR_BUILD)"; export CC; \ |
| 91 | CFLAGS="$(CFLAGS_FOR_BUILD)"; export CFLAGS; \ |
| 92 | CONFIG_SHELL="$(SHELL)"; export CONFIG_SHELL; \ |
| 93 | + CPP="$(CPP_FOR_BUILD)"; export CPP; \ |
| 94 | + CPPFLAGS="$(CPPFLAGS_FOR_BUILD)"; export CPPFLAGS; \ |
| 95 | CXX="$(CXX_FOR_BUILD)"; export CXX; \ |
| 96 | CXXFLAGS="$(CXXFLAGS_FOR_BUILD)"; export CXXFLAGS; \ |
| 97 | GFORTRAN="$(GFORTRAN_FOR_BUILD)"; export GFORTRAN; \ |
| 98 | @@ -201,6 +203,8 @@ HOST_EXPORTS = \ |
| 99 | AR="$(AR)"; export AR; \ |
| 100 | AS="$(AS)"; export AS; \ |
| 101 | CC_FOR_BUILD="$(CC_FOR_BUILD)"; export CC_FOR_BUILD; \ |
| 102 | + CPP_FOR_BUILD="$(CPP_FOR_BUILD)"; export CPP_FOR_BUILD; \ |
| 103 | + CPPFLAGS_FOR_BUILD="$(CPPFLAGS_FOR_BUILD)"; export CPPFLAGS_FOR_BUILD; \ |
| 104 | CXX_FOR_BUILD="$(CXX_FOR_BUILD)"; export CXX_FOR_BUILD; \ |
| 105 | DLLTOOL="$(DLLTOOL)"; export DLLTOOL; \ |
| 106 | LD="$(LD)"; export LD; \ |
| 107 | @@ -356,6 +360,8 @@ AR_FOR_BUILD = @AR_FOR_BUILD@ |
| 108 | AS_FOR_BUILD = @AS_FOR_BUILD@ |
| 109 | CC_FOR_BUILD = @CC_FOR_BUILD@ |
| 110 | CFLAGS_FOR_BUILD = @CFLAGS_FOR_BUILD@ |
| 111 | +CPP_FOR_BUILD = @CPP_FOR_BUILD@ |
| 112 | +CPPFLAGS_FOR_BUILD = @CPPFLAGS_FOR_BUILD@ |
| 113 | CXXFLAGS_FOR_BUILD = @CXXFLAGS_FOR_BUILD@ |
| 114 | CXX_FOR_BUILD = @CXX_FOR_BUILD@ |
| 115 | DLLTOOL_FOR_BUILD = @DLLTOOL_FOR_BUILD@ |
| 116 | Index: gcc-11.2.0/configure |
| 117 | =================================================================== |
| 118 | --- gcc-11.2.0.orig/configure |
| 119 | +++ gcc-11.2.0/configure |
| 120 | @@ -652,6 +652,8 @@ GFORTRAN_FOR_BUILD |
| 121 | DLLTOOL_FOR_BUILD |
| 122 | CXX_FOR_BUILD |
| 123 | CXXFLAGS_FOR_BUILD |
| 124 | +CPPFLAGS_FOR_BUILD |
| 125 | +CPP_FOR_BUILD |
| 126 | CFLAGS_FOR_BUILD |
| 127 | CC_FOR_BUILD |
| 128 | AS_FOR_BUILD |
| 129 | @@ -4092,6 +4094,7 @@ if test "${build}" != "${host}" ; then |
| 130 | AR_FOR_BUILD=${AR_FOR_BUILD-ar} |
| 131 | AS_FOR_BUILD=${AS_FOR_BUILD-as} |
| 132 | CC_FOR_BUILD=${CC_FOR_BUILD-gcc} |
| 133 | + CPP_FOR_BUILD="${CPP_FOR_BUILD-\$(CPP)}" |
| 134 | CXX_FOR_BUILD=${CXX_FOR_BUILD-g++} |
| 135 | GFORTRAN_FOR_BUILD=${GFORTRAN_FOR_BUILD-gfortran} |
| 136 | GOC_FOR_BUILD=${GOC_FOR_BUILD-gccgo} |
| 137 | @@ -9809,6 +9812,7 @@ esac |
| 138 | # our build compiler if desired. |
| 139 | if test x"${build}" = x"${host}" ; then |
| 140 | CFLAGS_FOR_BUILD=${CFLAGS_FOR_BUILD-${CFLAGS}} |
| 141 | + CPPFLAGS_FOR_BUILD=${CPPFLAGS_FOR_BUILD-${CPPFLAGS}} |
| 142 | CXXFLAGS_FOR_BUILD=${CXXFLAGS_FOR_BUILD-${CXXFLAGS}} |
| 143 | LDFLAGS_FOR_BUILD=${LDFLAGS_FOR_BUILD-${LDFLAGS}} |
| 144 | fi |
| 145 | Index: gcc-11.2.0/configure.ac |
| 146 | =================================================================== |
| 147 | --- gcc-11.2.0.orig/configure.ac |
| 148 | +++ gcc-11.2.0/configure.ac |
| 149 | @@ -1347,6 +1347,7 @@ if test "${build}" != "${host}" ; then |
| 150 | AR_FOR_BUILD=${AR_FOR_BUILD-ar} |
| 151 | AS_FOR_BUILD=${AS_FOR_BUILD-as} |
| 152 | CC_FOR_BUILD=${CC_FOR_BUILD-gcc} |
| 153 | + CPP_FOR_BUILD="${CPP_FOR_BUILD-\$(CPP)}" |
| 154 | CXX_FOR_BUILD=${CXX_FOR_BUILD-g++} |
| 155 | GFORTRAN_FOR_BUILD=${GFORTRAN_FOR_BUILD-gfortran} |
| 156 | GOC_FOR_BUILD=${GOC_FOR_BUILD-gccgo} |
| 157 | @@ -3321,6 +3322,7 @@ esac |
| 158 | # our build compiler if desired. |
| 159 | if test x"${build}" = x"${host}" ; then |
| 160 | CFLAGS_FOR_BUILD=${CFLAGS_FOR_BUILD-${CFLAGS}} |
| 161 | + CPPFLAGS_FOR_BUILD=${CPPFLAGS_FOR_BUILD-${CPPFLAGS}} |
| 162 | CXXFLAGS_FOR_BUILD=${CXXFLAGS_FOR_BUILD-${CXXFLAGS}} |
| 163 | LDFLAGS_FOR_BUILD=${LDFLAGS_FOR_BUILD-${LDFLAGS}} |
| 164 | fi |
| 165 | @@ -3387,6 +3389,8 @@ AC_SUBST(AR_FOR_BUILD) |
| 166 | AC_SUBST(AS_FOR_BUILD) |
| 167 | AC_SUBST(CC_FOR_BUILD) |
| 168 | AC_SUBST(CFLAGS_FOR_BUILD) |
| 169 | +AC_SUBST(CPP_FOR_BUILD) |
| 170 | +AC_SUBST(CPPFLAGS_FOR_BUILD) |
| 171 | AC_SUBST(CXXFLAGS_FOR_BUILD) |
| 172 | AC_SUBST(CXX_FOR_BUILD) |
| 173 | AC_SUBST(DLLTOOL_FOR_BUILD) |
| 174 | Index: gcc-11.2.0/gcc/configure |
| 175 | =================================================================== |
| 176 | --- gcc-11.2.0.orig/gcc/configure |
| 177 | +++ gcc-11.2.0/gcc/configure |
| 178 | @@ -12699,7 +12699,7 @@ else |
| 179 | CC="${CC_FOR_BUILD}" CFLAGS="${CFLAGS_FOR_BUILD}" \ |
| 180 | CXX="${CXX_FOR_BUILD}" CXXFLAGS="${CXXFLAGS_FOR_BUILD}" \ |
| 181 | LD="${LD_FOR_BUILD}" LDFLAGS="${LDFLAGS_FOR_BUILD}" \ |
| 182 | - GMPINC="" CPPFLAGS="${CPPFLAGS} -DGENERATOR_FILE" \ |
| 183 | + GMPINC="" CPPFLAGS="${CPPFLAGS_FOR_BUILD} -DGENERATOR_FILE" \ |
| 184 | ${realsrcdir}/configure \ |
| 185 | --enable-languages=${enable_languages-all} \ |
| 186 | ${enable_obsolete+--enable-obsolete="$enable_obsolete"} \ |
| 187 | Index: gcc-11.2.0/gcc/configure.ac |
| 188 | =================================================================== |
| 189 | --- gcc-11.2.0.orig/gcc/configure.ac |
| 190 | +++ gcc-11.2.0/gcc/configure.ac |
| 191 | @@ -2023,7 +2023,7 @@ else |
| 192 | CC="${CC_FOR_BUILD}" CFLAGS="${CFLAGS_FOR_BUILD}" \ |
| 193 | CXX="${CXX_FOR_BUILD}" CXXFLAGS="${CXXFLAGS_FOR_BUILD}" \ |
| 194 | LD="${LD_FOR_BUILD}" LDFLAGS="${LDFLAGS_FOR_BUILD}" \ |
| 195 | - GMPINC="" CPPFLAGS="${CPPFLAGS} -DGENERATOR_FILE" \ |
| 196 | + GMPINC="" CPPFLAGS="${CPPFLAGS_FOR_BUILD} -DGENERATOR_FILE" \ |
| 197 | ${realsrcdir}/configure \ |
| 198 | --enable-languages=${enable_languages-all} \ |
| 199 | ${enable_obsolete+--enable-obsolete="$enable_obsolete"} \ |