From 93b4e1d3a0f8417118d1c48fcd1ce51996e1420b Mon Sep 17 00:00:00 2001 From: Khem Raj Date: Mon, 7 Dec 2015 23:42:45 +0000 Subject: [PATCH 31/39] Fix various _FOR_BUILD and related variables When doing a FOR_BUILD thing, you have to override CFLAGS with CFLAGS_FOR_BUILD. And if you use C++, you also have to override CXXFLAGS with CXXFLAGS_FOR_BUILD. Without this, when building for mingw, you end up trying to use the mingw headers for a host build. The same goes for other variables as well, such as CPPFLAGS, CPP, and GMPINC. Upstream-Status: Pending Signed-off-by: Peter Seebach Signed-off-by: Mark Hatle Signed-off-by: Khem Raj --- Makefile.in | 6 ++++++ Makefile.tpl | 5 +++++ gcc/Makefile.in | 2 +- gcc/configure | 2 +- gcc/configure.ac | 2 +- 5 files changed, 14 insertions(+), 3 deletions(-) diff --git a/Makefile.in b/Makefile.in index 1af45580086..8966453c32c 100644 --- a/Makefile.in +++ b/Makefile.in @@ -152,6 +152,7 @@ BUILD_EXPORTS = \ CPP="$(CC_FOR_BUILD) -E"; export CPP; \ CFLAGS="$(CFLAGS_FOR_BUILD)"; export CFLAGS; \ CONFIG_SHELL="$(SHELL)"; export CONFIG_SHELL; \ + CPPFLAGS="$(CPPFLAGS_FOR_BUILD)"; export CPPFLAGS; \ CXX="$(CXX_FOR_BUILD)"; export CXX; \ CXXFLAGS="$(CXXFLAGS_FOR_BUILD)"; export CXXFLAGS; \ GFORTRAN="$(GFORTRAN_FOR_BUILD)"; export GFORTRAN; \ @@ -169,6 +170,9 @@ BUILD_EXPORTS = \ # built for the build system to override those in BASE_FLAGS_TO_PASS. EXTRA_BUILD_FLAGS = \ CFLAGS="$(CFLAGS_FOR_BUILD)" \ + CXXFLAGS="$(CXXFLAGS_FOR_BUILD)" \ + CPP="$(CC_FOR_BUILD) -E" \ + CPPFLAGS="$(CPPFLAGS_FOR_BUILD)" \ LDFLAGS="$(LDFLAGS_FOR_BUILD)" # This is the list of directories to built for the host system. @@ -186,6 +190,7 @@ HOST_SUBDIR = @host_subdir@ HOST_EXPORTS = \ $(BASE_EXPORTS) \ CC="$(CC)"; export CC; \ + CPP="$(CC) -E"; export CPP; \ ADA_CFLAGS="$(ADA_CFLAGS)"; export ADA_CFLAGS; \ CFLAGS="$(CFLAGS)"; export CFLAGS; \ CONFIG_SHELL="$(SHELL)"; export CONFIG_SHELL; \ @@ -753,6 +758,7 @@ BASE_FLAGS_TO_PASS = \ "CC_FOR_BUILD=$(CC_FOR_BUILD)" \ "CFLAGS_FOR_BUILD=$(CFLAGS_FOR_BUILD)" \ "CXX_FOR_BUILD=$(CXX_FOR_BUILD)" \ + "CXXFLAGS_FOR_BUILD=$(CXXFLAGS_FOR_BUILD)" \ "EXPECT=$(EXPECT)" \ "FLEX=$(FLEX)" \ "INSTALL=$(INSTALL)" \ diff --git a/Makefile.tpl b/Makefile.tpl index abd2bc2fb89..5822b260404 100644 --- a/Makefile.tpl +++ b/Makefile.tpl @@ -154,6 +154,7 @@ BUILD_EXPORTS = \ CC="$(CC_FOR_BUILD)"; export CC; \ CFLAGS="$(CFLAGS_FOR_BUILD)"; export CFLAGS; \ CONFIG_SHELL="$(SHELL)"; export CONFIG_SHELL; \ + CPPFLAGS="$(CPPFLAGS_FOR_BUILD)"; export CPPFLAGS; \ CXX="$(CXX_FOR_BUILD)"; export CXX; \ CXXFLAGS="$(CXXFLAGS_FOR_BUILD)"; export CXXFLAGS; \ GFORTRAN="$(GFORTRAN_FOR_BUILD)"; export GFORTRAN; \ @@ -171,6 +172,9 @@ BUILD_EXPORTS = \ # built for the build system to override those in BASE_FLAGS_TO_PASS. EXTRA_BUILD_FLAGS = \ CFLAGS="$(CFLAGS_FOR_BUILD)" \ + CXXFLAGS="$(CXXFLAGS_FOR_BUILD)" \ + CPP="$(CC_FOR_BUILD) -E" \ + CPPFLAGS="$(CPPFLAGS_FOR_BUILD)" \ LDFLAGS="$(LDFLAGS_FOR_BUILD)" # This is the list of directories to built for the host system. @@ -188,6 +192,7 @@ HOST_SUBDIR = @host_subdir@ HOST_EXPORTS = \ $(BASE_EXPORTS) \ CC="$(CC)"; export CC; \ + CPP="$(CC) -E"; export CPP; \ ADA_CFLAGS="$(ADA_CFLAGS)"; export ADA_CFLAGS; \ CFLAGS="$(CFLAGS)"; export CFLAGS; \ CONFIG_SHELL="$(SHELL)"; export CONFIG_SHELL; \ diff --git a/gcc/Makefile.in b/gcc/Makefile.in index 5ae693fb06c..02ee0aa72f4 100644 --- a/gcc/Makefile.in +++ b/gcc/Makefile.in @@ -801,7 +801,7 @@ BUILD_LDFLAGS=@BUILD_LDFLAGS@ BUILD_NO_PIE_FLAG = @BUILD_NO_PIE_FLAG@ BUILD_LDFLAGS += $(BUILD_NO_PIE_FLAG) BUILD_CPPFLAGS= -I. -I$(@D) -I$(srcdir) -I$(srcdir)/$(@D) \ - -I$(srcdir)/../include @INCINTL@ $(CPPINC) $(CPPFLAGS) + -I$(srcdir)/../include @INCINTL@ $(CPPINC) $(CPPFLAGS_FOR_BUILD) # Actual name to use when installing a native compiler. GCC_INSTALL_NAME := $(shell echo gcc|sed '$(program_transform_name)') diff --git a/gcc/configure b/gcc/configure index cfcadc93a01..2f6b4f72ef3 100755 --- a/gcc/configure +++ b/gcc/configure @@ -11797,7 +11797,7 @@ else CC="${CC_FOR_BUILD}" CFLAGS="${CFLAGS_FOR_BUILD}" \ CXX="${CXX_FOR_BUILD}" CXXFLAGS="${CXXFLAGS_FOR_BUILD}" \ LD="${LD_FOR_BUILD}" LDFLAGS="${LDFLAGS_FOR_BUILD}" \ - GMPINC="" CPPFLAGS="${CPPFLAGS} -DGENERATOR_FILE" \ + GMPINC="" CPPFLAGS="${CPPFLAGS_FOR_BUILD} -DGENERATOR_FILE" \ ${realsrcdir}/configure \ --enable-languages=${enable_languages-all} \ --target=$target_alias --host=$build_alias --build=$build_alias diff --git a/gcc/configure.ac b/gcc/configure.ac index 44b90478f55..9f8a51fc9bd 100644 --- a/gcc/configure.ac +++ b/gcc/configure.ac @@ -1708,7 +1708,7 @@ else CC="${CC_FOR_BUILD}" CFLAGS="${CFLAGS_FOR_BUILD}" \ CXX="${CXX_FOR_BUILD}" CXXFLAGS="${CXXFLAGS_FOR_BUILD}" \ LD="${LD_FOR_BUILD}" LDFLAGS="${LDFLAGS_FOR_BUILD}" \ - GMPINC="" CPPFLAGS="${CPPFLAGS} -DGENERATOR_FILE" \ + GMPINC="" CPPFLAGS="${CPPFLAGS_FOR_BUILD} -DGENERATOR_FILE" \ ${realsrcdir}/configure \ --enable-languages=${enable_languages-all} \ --target=$target_alias --host=$build_alias --build=$build_alias -- 2.17.0