Skip to contentSkip to conversation

Fix GCC 5.2 "_FOR_BUILD" and related variables

PATCH In review Mark Hatle 4 participants 11 messages Oct 19, 2015 – Nov 7, 2015

lore
Share & tools
lore

Mark Hatle

author
#0 lore raw

PATCH 1/1 Fix GCC 5.2 "_FOR_BUILD" and related variables

Without this patch, the wrong header fragments can be used to generate the nativesdk, cross-canadian, and other variations. Generally this works fine. However, when there is enough variation from the build machine to the target runtime it will break.. (Such as SDKMACHINE=i686-mingw32)

The bugs can also how up on a Linux -> Linux build, but it's signficiantly more rare. It would require some set of options that make the host headers and flags incompatible with the target. (Such as various profiling options.)

This has been tested with a set of meta-mingw patches that will be sent to the Yocto Project mailing list soon.

Mark Hatle (1):
gcc-5.2: Fix various _FOR_BUILD and related variables

 meta/recipes-devtools/gcc/gcc-5.2.inc              |   1 +
 .../gcc/gcc-5.2/0042-cxxflags-for-build.patch      | 123 +++++++++++++++++++++
 2 files changed, 124 insertions(+)
 create mode 100644 meta/recipes-devtools/gcc/gcc-5.2/0042-cxxflags-for-build.patch
Signature · 1 line
1.9.3
author
#1 lore raw

PATCH 1/1 gcc-5.2: 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.

---
 meta/recipes-devtools/gcc/gcc-5.2.inc              |   1 +
 .../gcc/gcc-5.2/0042-cxxflags-for-build.patch      | 123 +++++++++++++++++++++
 2 files changed, 124 insertions(+)
 create mode 100644 meta/recipes-devtools/gcc/gcc-5.2/0042-cxxflags-for-build.patch
meta/recipes-devtools/gcc/gcc-5.2.inc +1 -0
index f6673e6..a6b385a 100644
@@ -73,6 +73,7 @@ SRC_URI = "\
            file://0039-libcc1-fix-libcc1-s-install-path-and-rpath.patch \
            file://0040-nativesdk-gcc-support.patch \
            file://0041-handle-target-sysroot-multilib.patch \
+           file://0042-cxxflags-for-build.patch \
           "
 
 BACKPORTS = ""
meta/recipes-devtools/gcc/gcc-5.2/0042-cxxflags-for-build.patch new file +123 -0

123 lines not on this page · raw message

Signature · 1 line
1.9.3
#2 lore raw

Re: [PATCH] gcc-5.2: Fix various _FOR_BUILD and related variables

Quoted 11 lines · Mark Hatle

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.

this is ok to install.

Quoted 158 lines

---
meta/recipes-devtools/gcc/gcc-5.2.inc | 1 +
.../gcc/gcc-5.2/0042-cxxflags-for-build.patch | 123 +++++++++++++++++++++

2 files changed, 124 insertions(+)

create mode 100644 meta/recipes-devtools/gcc/gcc-5.2/0042-cxxflags-for-build.patch

meta/recipes-devtools/gcc/gcc-5.2.inc +1 -0
index f6673e6..a6b385a 100644
@@ -73,6 +73,7 @@ SRC_URI = "\
           file://0039-libcc1-fix-libcc1-s-install-path-and-rpath.patch \
           file://0040-nativesdk-gcc-support.patch \
           file://0041-handle-target-sysroot-multilib.patch \
+           file://0042-cxxflags-for-build.patch \
          "
 

BACKPORTS = ""

meta/recipes-devtools/gcc/gcc-5.2/0042-cxxflags-for-build.patch new file +123 -1
new file mode 100644
index 0000000..1105e29
@@ -0,0 +1,123 @@
+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 <[email protected]>
+Signed-off-by: Mark Hatle <[email protected]>
+
+diff --git a/Makefile.in b/Makefile.in
+index 9370174..011c29a 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; \
+ 	GCJ="$(GCJ_FOR_BUILD)"; export GCJ; \
+@@ -170,6 +171,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.
+@@ -187,6 +191,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; \
+@@ -711,6 +715,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 1ea1954..78a59c3 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; \
+ 	GCJ="$(GCJ_FOR_BUILD)"; export GCJ; \
+@@ -172,6 +173,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.
+@@ -189,6 +193,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 cd5bc4a..98ae4f4 100644
+--- a/gcc/Makefile.in
++++ b/gcc/Makefile.in
+@@ -762,7 +762,7 @@ BUILD_LINKERFLAGS = $(BUILD_CXXFLAGS)
+ # Native linker and preprocessor flags.  For x-fragment overrides.
+ BUILD_LDFLAGS=@BUILD_LDFLAGS@
+ 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 c7ac14b..5ac63e4 100755
+--- a/gcc/configure
++++ b/gcc/configure
+@@ -11521,7 +11521,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 50856e6..17a4dfd 100644
+--- a/gcc/configure.ac
++++ b/gcc/configure.ac
+@@ -1633,7 +1633,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
--

1.9.3

--
_______________________________________________
Openembedded-core mailing list
[email protected]
http://lists.openembedded.org/mailman/listinfo/openembedded-core

#3 lore raw
In reply to Mark Hatle

The patch works unmodified (and solves mingw build problems) for gcc 4.9. as well, providing gcc-4.9.inc is patched the same way as gcc-5.2.inc

(However, this makes the Makefile.in patch status:

Upstream-Status: Pending

incorrect for case of gcc 4.9.)

meta/recipes-devtools/gcc/gcc-4.9.inc +1 -0
@@ -81,6 +81,7 @@ SRC_URI = "\                                                                                                                                                       
     file://0063-nativesdk-gcc-support.patch \                                                                                                                                       
     file://0064-handle-target-sysroot-multilib.patch \                                                                                                                              
     file://0065-gcc-483-universal-initializer-no-warning.patch \                                                                                                                    
+    file://0042-cxxflags-for-build.patch \                                                                                                                                          
 "   
 
 
Quoted 39 lines

-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Mark Hatle
Sent: Monday, October 19, 2015 8:30 AM
To: [email protected]
Subject: [OE-core] [PATCH] Fix GCC 5.2 "_FOR_BUILD" and related variables

Without this patch, the wrong header fragments can be used to generate the nativesdk, cross-canadian, and other variations. Generally this works fine. However, when there is enough variation from the build machine to the target runtime it will break.. (Such as SDKMACHINE=i686-mingw32)

The bugs can also how up on a Linux -> Linux build, but it's signficiantly more rare. It would require some set of options that make the host headers and flags incompatible with the target. (Such as various profiling options.)

This has been tested with a set of meta-mingw patches that will be sent to the Yocto Project mailing list soon.

Mark Hatle (1):
gcc-5.2: Fix various _FOR_BUILD and related variables

 meta/recipes-devtools/gcc/gcc-5.2.inc              |   1 +
 .../gcc/gcc-5.2/0042-cxxflags-for-build.patch      | 123
+++++++++++++++++++++
 2 files changed, 124 insertions(+)
 create mode 100644 meta/recipes-devtools/gcc/gcc-5.2/0042-cxxflags-for-

build.patch

--
1.9.3

--
_______________________________________________
Openembedded-core mailing list
[email protected]
http://lists.openembedded.org/mailman/listinfo/openembedded-core

#4 lore raw
Quoted 8 lines · Juro

The patch works unmodified (and solves mingw build problems) for gcc 4.9. as well, providing gcc-4.9.inc is patched the same way as gcc-5.2.inc

(However, this makes the Makefile.in patch status:

Upstream-Status: Pending

incorrect for case of gcc 4.9.)

why it it incorrect. is gcc 4.9 EOL ?

Quoted 57 lines
meta/recipes-devtools/gcc/gcc-4.9.inc +1 -0
@@ -81,6 +81,7 @@ SRC_URI = "\
     file://0063-nativesdk-gcc-support.patch \
     file://0064-handle-target-sysroot-multilib.patch \
     file://0065-gcc-483-universal-initializer-no-warning.patch \
+    file://0042-cxxflags-for-build.patch \
 "
 
 
Quoted 32 lines

-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Mark Hatle
Sent: Monday, October 19, 2015 8:30 AM
To: [email protected]
Subject: [OE-core] [PATCH] Fix GCC 5.2 "_FOR_BUILD" and related variables

Without this patch, the wrong header fragments can be used to generate the nativesdk, cross-canadian, and other variations. Generally this works fine. However, when there is enough variation from the build machine to the target runtime it will break.. (Such as SDKMACHINE=i686-mingw32)

The bugs can also how up on a Linux -> Linux build, but it's signficiantly more rare. It would require some set of options that make the host headers and flags incompatible with the target. (Such as various profiling options.)

This has been tested with a set of meta-mingw patches that will be sent to the Yocto Project mailing list soon.

Mark Hatle (1):
gcc-5.2: Fix various _FOR_BUILD and related variables

 meta/recipes-devtools/gcc/gcc-5.2.inc              |   1 +
 .../gcc/gcc-5.2/0042-cxxflags-for-build.patch      | 123
+++++++++++++++++++++
 2 files changed, 124 insertions(+)
 create mode 100644 meta/recipes-devtools/gcc/gcc-5.2/0042-cxxflags-for-

build.patch

Quoted 8 lines

--
1.9.3

--
_______________________________________________
Openembedded-core mailing list
[email protected]
http://lists.openembedded.org/mailman/listinfo/openembedded-core

--
_______________________________________________
Openembedded-core mailing list
[email protected]
http://lists.openembedded.org/mailman/listinfo/openembedded-core

#5 lore raw

Maybe this is my misunderstanding, I assume "Pending" means
a patch has been also sent to gcc developers it is going to be upstreamed at some point.
(I also assume patch for 4.9 Makefile.in needs to be upstreamed separately from 5.2)

Quoted 85 lines

-----Original Message-----
From: Khem Raj [mailto:[email protected]]
Sent: Thursday, November 5, 2015 10:18 AM
To: Bystricky, Juro
Cc: Hatle, Mark G (Wind River); openembedded- [email protected]
Subject: Re: [OE-core] [PATCH] Fix GCC 5.2 "_FOR_BUILD" and related variables

Quoted 9 lines · Juro

The patch works unmodified (and solves mingw build problems) for gcc 4.9. as well, providing gcc-4.9.inc is patched the same way as gcc-5.2.inc

(However, this makes the Makefile.in patch status:

Upstream-Status: Pending

incorrect for case of gcc 4.9.)

why it it incorrect. is gcc 4.9 EOL ?

Quoted 13 lines
meta/recipes-devtools/gcc/gcc-4.9.inc +1 -0
@@ -81,6 +81,7 @@ SRC_URI = "\
     file://0063-nativesdk-gcc-support.patch \
     file://0064-handle-target-sysroot-multilib.patch \
     file://0065-gcc-483-universal-initializer-no-warning.patch \
+    file://0042-cxxflags-for-build.patch \
 "
 
 
Quoted 3 lines
Quoted 3 lines

-----Original Message-----
From: [email protected] [mailto:[email protected]] On

Behalf

Quoted 8 lines
Quoted 8 lines

Of Mark Hatle
Sent: Monday, October 19, 2015 8:30 AM
To: [email protected]
Subject: [OE-core] [PATCH] Fix GCC 5.2 "_FOR_BUILD" and related variables

Without this patch, the wrong header fragments can be used to generate the nativesdk, cross-canadian, and other variations. Generally

this works fine.

Quoted 36 lines
Quoted 23 lines

However, when there is enough variation from the build machine to the target runtime it will break.. (Such as SDKMACHINE=i686-mingw32)

The bugs can also how up on a Linux -> Linux build, but it's signficiantly more rare. It would require some set of options that make the host headers and flags incompatible with the target. (Such as various profiling
options.)

This has been tested with a set of meta-mingw patches that will be sent to the Yocto Project mailing list soon.

Mark Hatle (1):
gcc-5.2: Fix various _FOR_BUILD and related variables

 meta/recipes-devtools/gcc/gcc-5.2.inc              |   1 +
 .../gcc/gcc-5.2/0042-cxxflags-for-build.patch      | 123
+++++++++++++++++++++
 2 files changed, 124 insertions(+)
 create mode 100644

meta/recipes-devtools/gcc/gcc-5.2/0042-cxxflags-for- build.patch

Quoted 8 lines

--
1.9.3

--
_______________________________________________
Openembedded-core mailing list
[email protected]
http://lists.openembedded.org/mailman/listinfo/openembedded-core

--
_______________________________________________
Openembedded-core mailing list
[email protected]
http://lists.openembedded.org/mailman/listinfo/openembedded-core

#7 lore raw
In reply to Bystricky, Juro
Quoted 4 lines · Juro

The patch works unmodified (and solves mingw build problems) for gcc 4.9. as well,
providing gcc-4.9.inc is patched the same way as gcc-5.2.inc

Can you send a proper patch for that?

Cheers,
Ross

#8 lore raw

Yes, I will do that shortly.

From: Burton, Ross [mailto:[email protected]]
Sent: Thursday, November 5, 2015 1:08 PM
To: Bystricky, Juro
Cc: Hatle, Mark G (Wind River); [email protected]
Subject: Re: [OE-core] [PATCH] Fix GCC 5.2 "_FOR_BUILD" and related variables

On 5 November 2015 at 18:13, Bystricky, Juro <[email protected]<mailto:[email protected]>> wrote:
The patch works unmodified (and solves mingw build problems) for gcc 4.9. as well,
providing gcc-4.9.inc is patched the same way as gcc-5.2.inc

Can you send a proper patch for that?

Cheers,
Ross

#9 lore raw

cover gcc-4.9: Fix various _FOR_BUILD and related variables

This is a patch by Peter Seebach and Mark Hatle (commit 41cbfd7af60f93a4bd496b7b6bf477215a286950) except it is applied against gcc-4.9 instead of gcc-5.2.

Tested with local.conf:

SDKMACHINE="i686-mingw32"
SDKTAROPTS_append=" -h --hard-dereference"
GCCVERSION="4.9.3"

$ bitbake nativesdk-gcc

There are some additional minor fixes needed for meta-mingw to build successfully, but that should be a separate meta-mingw specific patch.

Juro Bystricky (1):
gcc-4.9: Fix various _FOR_BUILD and related variables

 meta/recipes-devtools/gcc/gcc-4.9.inc              |   1 +
 .../gcc/gcc-4.9/0066-cxxflags-for-build.patch      | 123 +++++++++++++++++++++
 2 files changed, 124 insertions(+)
 create mode 100644 meta/recipes-devtools/gcc/gcc-4.9/0066-cxxflags-for-build.patch
Signature · 1 line
1.9.1
#10 lore raw

PATCH 1/1 gcc-4.9: Fix various _FOR_BUILD and related variables

This patch is based on the patch for gcc-5.2 (41cbfd7af60f93a4bd496b7b6bf477215a286950)

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.

---
 meta/recipes-devtools/gcc/gcc-4.9.inc              |   1 +
 .../gcc/gcc-4.9/0066-cxxflags-for-build.patch      | 123 +++++++++++++++++++++
 2 files changed, 124 insertions(+)
 create mode 100644 meta/recipes-devtools/gcc/gcc-4.9/0066-cxxflags-for-build.patch
meta/recipes-devtools/gcc/gcc-4.9.inc +1 -0
index 95b553c..6ac3685 100644
@@ -81,6 +81,7 @@ SRC_URI = "\
     file://0063-nativesdk-gcc-support.patch \
     file://0064-handle-target-sysroot-multilib.patch \
     file://0065-gcc-483-universal-initializer-no-warning.patch \
+    file://0066-cxxflags-for-build.patch \
 "
 SRC_URI[md5sum] = "6f831b4d251872736e8e9cc09746f327"
 SRC_URI[sha256sum] = "2332b2a5a321b57508b9031354a8503af6fdfb868b8c1748d33028d100a8b67e"
meta/recipes-devtools/gcc/gcc-4.9/0066-cxxflags-for-build.patch new file +123 -0

123 lines not on this page · raw message

Signature · 1 line
1.9.1