blob: 45953f861d562f67c575941327d0503454b6b956 [file] [log] [blame]
Patrick Williams03907ee2022-05-01 06:28:52 -05001From 667b302f637be0a4b6ef714b5eb0026c54425386 Mon Sep 17 00:00:00 2001
Andrew Geisslereff27472021-10-29 15:35:00 -05002From: Richard Purdie <richard.purdie@linuxfoundation.org>
Patrick Williams03907ee2022-05-01 06:28:52 -05003Date: Sun, 31 Oct 2021 17:40:12 -0700
4Subject: [PATCH] Makefile.in: Ensure build CPP/CPPFLAGS is used for build
5 targets
Andrew Geissler82c905d2020-04-13 13:39:40 -05006
Andrew Geisslereff27472021-10-29 15:35:00 -05007During cross compiling, CPP is being set to the target compiler even for
8build targets. As an example, when building a cross compiler targetting
9mingw, the config.log for libiberty in
10build.x86_64-pokysdk-mingw32.i586-poky-linux/build-x86_64-linux/libiberty/config.log
11shows:
Andrew Geissler82c905d2020-04-13 13:39:40 -050012
Andrew Geissler82c905d2020-04-13 13:39:40 -050013configure:3786: checking how to run the C preprocessor
Andrew Geisslereff27472021-10-29 15:35:00 -050014configure:3856: result: x86_64-pokysdk-mingw32-gcc -E --sysroot=[sysroot]/x86_64-nativesdk-mingw32-pokysdk-mingw32
15configure:3876: x86_64-pokysdk-mingw32-gcc -E --sysroot=[sysroot]/x86_64-nativesdk-mingw32-pokysdk-mingw32 conftest.c
Andrew Geissler82c905d2020-04-13 13:39:40 -050016configure:3876: $? = 0
17
Andrew Geisslereff27472021-10-29 15:35:00 -050018This is libiberty being built for the build environment, not the target one
19(i.e. in build-x86_64-linux). As such it should be using the build environment's
20gcc and not the target one. In the mingw case the system headers are quite
21different leading to build failures related to not being able to include a
22process.h file for pem-unix.c.
Andrew Geissler82c905d2020-04-13 13:39:40 -050023
Andrew Geisslereff27472021-10-29 15:35:00 -050024Further analysis shows the same issue occuring for CPPFLAGS too.
Andrew Geissler82c905d2020-04-13 13:39:40 -050025
Andrew Geisslereff27472021-10-29 15:35:00 -050026Fix this by adding support for CPP_FOR_BUILD and CPPFLAGS_FOR_BUILD which
27for example, avoids mixing the mingw headers for host binaries on linux
28systems.
Andrew Geissler82c905d2020-04-13 13:39:40 -050029
Andrew Geisslereff27472021-10-29 15:35:00 -0500302021-10-27 Richard Purdie <richard.purdie@linuxfoundation.org>
Andrew Geissler82c905d2020-04-13 13:39:40 -050031
Andrew Geisslereff27472021-10-29 15:35:00 -050032ChangeLog:
33
34 * Makefile.tpl: Add CPP_FOR_BUILD and CPPFLAGS_FOR_BUILD support
35 * Makefile.in: Regenerate.
36 * configure: Regenerate.
37 * configure.ac: Add CPP_FOR_BUILD and CPPFLAGS_FOR_BUILD support
38
39gcc/ChangeLog:
40
41 * configure: Regenerate.
42 * configure.ac: Use CPPFLAGS_FOR_BUILD for GMPINC
43
44Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
45
46Submitted [https://gcc.gnu.org/pipermail/gcc-patches/2021-October/582727.html]
47Upstream-Status: Backport [https://gcc.gnu.org/git/?p=gcc.git;a=commitdiff;h=84401ce5fb4ecab55decb472b168100e7593e01f]
Patrick Williams03907ee2022-05-01 06:28:52 -050048
49Signed-off-by: Khem Raj <raj.khem@gmail.com>
Andrew Geissler82c905d2020-04-13 13:39:40 -050050---
Andrew Geisslereff27472021-10-29 15:35:00 -050051 Makefile.in | 6 ++++++
52 Makefile.tpl | 6 ++++++
53 configure | 4 ++++
54 configure.ac | 4 ++++
55 gcc/configure | 2 +-
56 gcc/configure.ac | 2 +-
57 6 files changed, 22 insertions(+), 2 deletions(-)
Andrew Geissler82c905d2020-04-13 13:39:40 -050058
Patrick Williams03907ee2022-05-01 06:28:52 -050059diff --git a/Makefile.in b/Makefile.in
60index 20cbbe2906d..33476d53327 100644
61--- a/Makefile.in
62+++ b/Makefile.in
Andrew Geisslereff27472021-10-29 15:35:00 -050063@@ -154,6 +154,8 @@ BUILD_EXPORTS = \
64 CC="$(CC_FOR_BUILD)"; export CC; \
65 CFLAGS="$(CFLAGS_FOR_BUILD)"; export CFLAGS; \
66 CONFIG_SHELL="$(SHELL)"; export CONFIG_SHELL; \
67+ CPP="$(CPP_FOR_BUILD)"; export CPP; \
68+ CPPFLAGS="$(CPPFLAGS_FOR_BUILD)"; export CPPFLAGS; \
69 CXX="$(CXX_FOR_BUILD)"; export CXX; \
70 CXXFLAGS="$(CXXFLAGS_FOR_BUILD)"; export CXXFLAGS; \
71 GFORTRAN="$(GFORTRAN_FOR_BUILD)"; export GFORTRAN; \
Patrick Williams03907ee2022-05-01 06:28:52 -050072@@ -202,6 +204,8 @@ HOST_EXPORTS = \
Andrew Geisslereff27472021-10-29 15:35:00 -050073 AR="$(AR)"; export AR; \
74 AS="$(AS)"; export AS; \
75 CC_FOR_BUILD="$(CC_FOR_BUILD)"; export CC_FOR_BUILD; \
76+ CPP_FOR_BUILD="$(CPP_FOR_BUILD)"; export CPP_FOR_BUILD; \
77+ CPPFLAGS_FOR_BUILD="$(CPPFLAGS_FOR_BUILD)"; export CPPFLAGS_FOR_BUILD; \
78 CXX_FOR_BUILD="$(CXX_FOR_BUILD)"; export CXX_FOR_BUILD; \
79 DLLTOOL="$(DLLTOOL)"; export DLLTOOL; \
Patrick Williams03907ee2022-05-01 06:28:52 -050080 DSYMUTIL="$(DSYMUTIL)"; export DSYMUTIL; \
81@@ -360,6 +364,8 @@ AR_FOR_BUILD = @AR_FOR_BUILD@
Andrew Geisslereff27472021-10-29 15:35:00 -050082 AS_FOR_BUILD = @AS_FOR_BUILD@
83 CC_FOR_BUILD = @CC_FOR_BUILD@
84 CFLAGS_FOR_BUILD = @CFLAGS_FOR_BUILD@
85+CPP_FOR_BUILD = @CPP_FOR_BUILD@
86+CPPFLAGS_FOR_BUILD = @CPPFLAGS_FOR_BUILD@
87 CXXFLAGS_FOR_BUILD = @CXXFLAGS_FOR_BUILD@
88 CXX_FOR_BUILD = @CXX_FOR_BUILD@
89 DLLTOOL_FOR_BUILD = @DLLTOOL_FOR_BUILD@
Patrick Williams03907ee2022-05-01 06:28:52 -050090diff --git a/Makefile.tpl b/Makefile.tpl
91index 9adf4f94728..e39d85d1109 100644
92--- a/Makefile.tpl
93+++ b/Makefile.tpl
94@@ -157,6 +157,8 @@ BUILD_EXPORTS = \
95 CC="$(CC_FOR_BUILD)"; export CC; \
96 CFLAGS="$(CFLAGS_FOR_BUILD)"; export CFLAGS; \
97 CONFIG_SHELL="$(SHELL)"; export CONFIG_SHELL; \
98+ CPP="$(CPP_FOR_BUILD)"; export CPP; \
99+ CPPFLAGS="$(CPPFLAGS_FOR_BUILD)"; export CPPFLAGS; \
100 CXX="$(CXX_FOR_BUILD)"; export CXX; \
101 CXXFLAGS="$(CXXFLAGS_FOR_BUILD)"; export CXXFLAGS; \
102 GFORTRAN="$(GFORTRAN_FOR_BUILD)"; export GFORTRAN; \
103@@ -205,6 +207,8 @@ HOST_EXPORTS = \
104 AR="$(AR)"; export AR; \
105 AS="$(AS)"; export AS; \
106 CC_FOR_BUILD="$(CC_FOR_BUILD)"; export CC_FOR_BUILD; \
107+ CPP_FOR_BUILD="$(CPP_FOR_BUILD)"; export CPP_FOR_BUILD; \
108+ CPPFLAGS_FOR_BUILD="$(CPPFLAGS_FOR_BUILD)"; export CPPFLAGS_FOR_BUILD; \
109 CXX_FOR_BUILD="$(CXX_FOR_BUILD)"; export CXX_FOR_BUILD; \
110 DLLTOOL="$(DLLTOOL)"; export DLLTOOL; \
111 DSYMUTIL="$(DSYMUTIL)"; export DSYMUTIL; \
112@@ -363,6 +367,8 @@ AR_FOR_BUILD = @AR_FOR_BUILD@
113 AS_FOR_BUILD = @AS_FOR_BUILD@
114 CC_FOR_BUILD = @CC_FOR_BUILD@
115 CFLAGS_FOR_BUILD = @CFLAGS_FOR_BUILD@
116+CPP_FOR_BUILD = @CPP_FOR_BUILD@
117+CPPFLAGS_FOR_BUILD = @CPPFLAGS_FOR_BUILD@
118 CXXFLAGS_FOR_BUILD = @CXXFLAGS_FOR_BUILD@
119 CXX_FOR_BUILD = @CXX_FOR_BUILD@
120 DLLTOOL_FOR_BUILD = @DLLTOOL_FOR_BUILD@
121diff --git a/configure b/configure
122index 45744e6e471..ff0de8a68b4 100755
123--- a/configure
124+++ b/configure
125@@ -655,6 +655,8 @@ DSYMUTIL_FOR_BUILD
Andrew Geisslereff27472021-10-29 15:35:00 -0500126 DLLTOOL_FOR_BUILD
127 CXX_FOR_BUILD
128 CXXFLAGS_FOR_BUILD
129+CPPFLAGS_FOR_BUILD
130+CPP_FOR_BUILD
131 CFLAGS_FOR_BUILD
132 CC_FOR_BUILD
133 AS_FOR_BUILD
Patrick Williams03907ee2022-05-01 06:28:52 -0500134@@ -4100,6 +4102,7 @@ if test "${build}" != "${host}" ; then
Andrew Geisslereff27472021-10-29 15:35:00 -0500135 AR_FOR_BUILD=${AR_FOR_BUILD-ar}
136 AS_FOR_BUILD=${AS_FOR_BUILD-as}
137 CC_FOR_BUILD=${CC_FOR_BUILD-gcc}
138+ CPP_FOR_BUILD="${CPP_FOR_BUILD-\$(CPP)}"
139 CXX_FOR_BUILD=${CXX_FOR_BUILD-g++}
Patrick Williams03907ee2022-05-01 06:28:52 -0500140 DSYMUTIL_FOR_BUILD=${DSYMUTIL_FOR_BUILD-dsymutil}
Andrew Geisslereff27472021-10-29 15:35:00 -0500141 GFORTRAN_FOR_BUILD=${GFORTRAN_FOR_BUILD-gfortran}
Patrick Williams03907ee2022-05-01 06:28:52 -0500142@@ -9831,6 +9834,7 @@ esac
Andrew Geisslereff27472021-10-29 15:35:00 -0500143 # our build compiler if desired.
144 if test x"${build}" = x"${host}" ; then
145 CFLAGS_FOR_BUILD=${CFLAGS_FOR_BUILD-${CFLAGS}}
146+ CPPFLAGS_FOR_BUILD=${CPPFLAGS_FOR_BUILD-${CPPFLAGS}}
147 CXXFLAGS_FOR_BUILD=${CXXFLAGS_FOR_BUILD-${CXXFLAGS}}
148 LDFLAGS_FOR_BUILD=${LDFLAGS_FOR_BUILD-${LDFLAGS}}
149 fi
Patrick Williams03907ee2022-05-01 06:28:52 -0500150diff --git a/configure.ac b/configure.ac
151index bf66b51373c..09fa3896dc7 100644
152--- a/configure.ac
153+++ b/configure.ac
Andrew Geisslereff27472021-10-29 15:35:00 -0500154@@ -1347,6 +1347,7 @@ if test "${build}" != "${host}" ; then
155 AR_FOR_BUILD=${AR_FOR_BUILD-ar}
156 AS_FOR_BUILD=${AS_FOR_BUILD-as}
157 CC_FOR_BUILD=${CC_FOR_BUILD-gcc}
158+ CPP_FOR_BUILD="${CPP_FOR_BUILD-\$(CPP)}"
159 CXX_FOR_BUILD=${CXX_FOR_BUILD-g++}
Patrick Williams03907ee2022-05-01 06:28:52 -0500160 DSYMUTIL_FOR_BUILD=${DSYMUTIL_FOR_BUILD-dsymutil}
Andrew Geisslereff27472021-10-29 15:35:00 -0500161 GFORTRAN_FOR_BUILD=${GFORTRAN_FOR_BUILD-gfortran}
Patrick Williams03907ee2022-05-01 06:28:52 -0500162@@ -3336,6 +3337,7 @@ esac
Andrew Geisslereff27472021-10-29 15:35:00 -0500163 # our build compiler if desired.
164 if test x"${build}" = x"${host}" ; then
165 CFLAGS_FOR_BUILD=${CFLAGS_FOR_BUILD-${CFLAGS}}
166+ CPPFLAGS_FOR_BUILD=${CPPFLAGS_FOR_BUILD-${CPPFLAGS}}
167 CXXFLAGS_FOR_BUILD=${CXXFLAGS_FOR_BUILD-${CXXFLAGS}}
168 LDFLAGS_FOR_BUILD=${LDFLAGS_FOR_BUILD-${LDFLAGS}}
169 fi
Patrick Williams03907ee2022-05-01 06:28:52 -0500170@@ -3402,6 +3404,8 @@ AC_SUBST(AR_FOR_BUILD)
Andrew Geisslereff27472021-10-29 15:35:00 -0500171 AC_SUBST(AS_FOR_BUILD)
172 AC_SUBST(CC_FOR_BUILD)
173 AC_SUBST(CFLAGS_FOR_BUILD)
174+AC_SUBST(CPP_FOR_BUILD)
175+AC_SUBST(CPPFLAGS_FOR_BUILD)
176 AC_SUBST(CXXFLAGS_FOR_BUILD)
177 AC_SUBST(CXX_FOR_BUILD)
178 AC_SUBST(DLLTOOL_FOR_BUILD)
Patrick Williams03907ee2022-05-01 06:28:52 -0500179diff --git a/gcc/configure b/gcc/configure
180index ec3c24482df..31a460dc9d0 100755
181--- a/gcc/configure
182+++ b/gcc/configure
183@@ -12740,7 +12740,7 @@ else
Andrew Geisslereff27472021-10-29 15:35:00 -0500184 CC="${CC_FOR_BUILD}" CFLAGS="${CFLAGS_FOR_BUILD}" \
185 CXX="${CXX_FOR_BUILD}" CXXFLAGS="${CXXFLAGS_FOR_BUILD}" \
186 LD="${LD_FOR_BUILD}" LDFLAGS="${LDFLAGS_FOR_BUILD}" \
187- GMPINC="" CPPFLAGS="${CPPFLAGS} -DGENERATOR_FILE" \
188+ GMPINC="" CPPFLAGS="${CPPFLAGS_FOR_BUILD} -DGENERATOR_FILE" \
189 ${realsrcdir}/configure \
190 --enable-languages=${enable_languages-all} \
191 ${enable_obsolete+--enable-obsolete="$enable_obsolete"} \
Patrick Williams03907ee2022-05-01 06:28:52 -0500192diff --git a/gcc/configure.ac b/gcc/configure.ac
193index ea794cd1763..b965eb036bc 100644
194--- a/gcc/configure.ac
195+++ b/gcc/configure.ac
196@@ -2054,7 +2054,7 @@ else
Andrew Geisslereff27472021-10-29 15:35:00 -0500197 CC="${CC_FOR_BUILD}" CFLAGS="${CFLAGS_FOR_BUILD}" \
198 CXX="${CXX_FOR_BUILD}" CXXFLAGS="${CXXFLAGS_FOR_BUILD}" \
199 LD="${LD_FOR_BUILD}" LDFLAGS="${LDFLAGS_FOR_BUILD}" \
200- GMPINC="" CPPFLAGS="${CPPFLAGS} -DGENERATOR_FILE" \
201+ GMPINC="" CPPFLAGS="${CPPFLAGS_FOR_BUILD} -DGENERATOR_FILE" \
202 ${realsrcdir}/configure \
203 --enable-languages=${enable_languages-all} \
204 ${enable_obsolete+--enable-obsolete="$enable_obsolete"} \