Skip to contentSkip to conversation

Badness with -ibad, a replacement for zecke-no-host-includes.patch.

RFC In review Graham Gower 7 participants 13 messages Jul 8, 2010 – Jul 13, 2010

lore
Share & tools
lore
#0 lore raw

RFC 1/1 Badness with -ibad, a replacement for zecke-no-host-includes.patch.

This patch introduces a new command line parameter to gcc (at Zecke's suggestion), -ibad, which may be used to specify blacklisted include prefixes. E.g.

grg@eye7:/tmp$ ~/oe2/tmp/cross/mipsel/bin/mipsel-angstrom-linux-gcc -c test.c -ibad /usr/include -I /usr/include
CROSS COMPILE Badness: /usr/include in INCLUDEPATH: /usr/include

This makes it much easier to add new blacklisted include paths, with a trivial edit to bitbake.conf. No additional paths have been added yet, but my motivation for this was to add /usr/X11R6/include and /usr/X11/include.

Please note that the bitbake.conf change will break builds with versions of gcc that do not accept this -ibad parameter. I have tested that the ibad patch applies to each of the gcc versions in this patch, but only done functional tests for gcc-4.3.3 and gcc-.4.1.

The following gcc versions may need attention:
3.3.3
3.3.4
svn
csl-arm-2007q3
csl-arm-2008q1
csl-arm-2008q3

3.3.x will require a completely reworked ibad patch. The others should be compatible with one of the three ibad patches included below.

-Graham

---
 conf/bitbake.conf                  |    8 ++-
 recipes/gcc/files/ibad-4.2.1.patch |  117 ++++++++++++++++++++++++++++++++++
 recipes/gcc/files/ibad-4.3.3.patch |  117 ++++++++++++++++++++++++++++++++++
 recipes/gcc/files/ibad-4.4.1.patch |  122 ++++++++++++++++++++++++++++++++++++
 recipes/gcc/gcc-3.4.4.inc          |    4 +-
 recipes/gcc/gcc-3.4.6.inc          |    1 -
 recipes/gcc/gcc-4.0.0.inc          |    1 -
 recipes/gcc/gcc-4.0.2.inc          |    2 -
 recipes/gcc/gcc-4.1.0.inc          |    4 +-
 recipes/gcc/gcc-cross_3.4.4.bb     |    4 +-
 recipes/gcc/gcc-cross_4.0.0.bb     |    4 +-
 recipes/gcc/gcc-cross_4.0.2.bb     |    4 +-
 recipes/gcc/gcc-cross_4.1.0.bb     |    4 +-
 recipes/gcc/gcc-cross_4.1.1.bb     |    4 +-
 recipes/gcc/gcc-cross_4.1.2.bb     |    4 +-
 recipes/gcc/gcc-cross_4.2.1.bb     |    4 +-
 recipes/gcc/gcc-cross_4.2.2.bb     |    4 +-
 recipes/gcc/gcc-cross_4.2.3.bb     |    4 +-
 recipes/gcc/gcc-cross_4.2.4.bb     |    4 +-
 recipes/gcc/gcc-cross_4.3.1.bb     |    4 +-
 recipes/gcc/gcc-cross_4.3.2.bb     |    4 +-
 recipes/gcc/gcc-cross_4.3.3.bb     |    4 +-
 recipes/gcc/gcc-cross_4.3.4.bb     |    4 +-
 recipes/gcc/gcc-cross_4.4.1.bb     |    4 +-
 recipes/gcc/gcc-cross_4.4.2.bb     |    4 +-
 recipes/gcc/gcc-cross_4.4.4.bb     |    4 +-
 recipes/gcc/gcc-cross_4.5.bb       |    4 +-
 27 files changed, 405 insertions(+), 43 deletions(-)
 create mode 100644 recipes/gcc/files/ibad-4.2.1.patch
 create mode 100644 recipes/gcc/files/ibad-4.3.3.patch
 create mode 100644 recipes/gcc/files/ibad-4.4.1.patch
conf/bitbake.conf +7 -1
index 0119294..93f8574 100644
@@ -463,9 +463,15 @@ PATCHRESOLVE = 'noop'
 # Build flags and options.
 ##################################################################
 
+# We don't want cross builds to include these paths.
+BAD_HOST_INCDIRS = " \
+		-ibad /usr/include \
+		-ibad /sw/include \
+		-ibad /opt/include"
+
 export BUILD_CPPFLAGS = "-isystem${STAGING_INCDIR_NATIVE}"
 export CPPFLAGS = "${TARGET_CPPFLAGS}"
-export TARGET_CPPFLAGS = "-isystem${STAGING_DIR_TARGET}${includedir}"
+export TARGET_CPPFLAGS = "-isystem${STAGING_DIR_TARGET}${includedir} ${BAD_HOST_INCDIRS}"
 export SDK_CPPFLAGS = "-isystem${STAGING_DIR_SDK}${includedir} -isystem${STAGING_DIR_HOST}${includedir}"
 
 export BUILD_CFLAGS = "${BUILD_CPPFLAGS} ${BUILD_OPTIMIZATION}"
recipes/gcc/files/ibad-4.2.1.patch new file +117 -0

117 lines not on this page · raw message

recipes/gcc/files/ibad-4.3.3.patch new file +117 -0

117 lines not on this page · raw message

recipes/gcc/files/ibad-4.4.1.patch new file +122 -0

122 lines not on this page · raw message

recipes/gcc/gcc-3.4.4.inc +1 -3
index b63f59e..f749160 100644
@@ -1,6 +1,6 @@
 require gcc-common.inc
 
-INC_PR = "r15"
+INC_PR = "r16"
 
 SRC_URI = "${GNU_MIRROR}/gcc/gcc-${PV}/gcc-${PV}.tar.bz2;name=archive \
 	   file://gcc34-reverse-compare.patch \
@@ -26,7 +26,5 @@ SRC_URI = "${GNU_MIRROR}/gcc/gcc-${PV}/gcc-${PV}.tar.bz2;name=archive \
 	   file://gcc-cross-fixincl.patch \
 	   file://gcc-posix-open-fix.patch \
 	   "
-SRC_URI_append = " file://zecke-no-host-includes.patch "
-
 SRC_URI[archive.md5sum] = "b594ff4ea4fbef4ba9220887de713dfe"
 SRC_URI[archive.sha256sum] = "3444179840638cb8664e8e53604900c4521d29d57785a5091202ee4937d8d0fd"
recipes/gcc/gcc-3.4.6.inc +0 -1
index b6b01e3..171b54f 100644
@@ -21,7 +21,6 @@ SRC_URI = "${GNU_MIRROR}/gcc/gcc-${PV}/gcc-${PV}.tar.bz2;name=archive \
 
 SRC_URI += "file://gcc34-configure.in.patch"
 SRC_URI += "file://gcc34-thumb-support.patch"
-SRC_URI_append = " file://zecke-no-host-includes.patch "
 
 SRC_URI[archive.md5sum] = "4a21ac777d4b5617283ce488b808da7b"
 SRC_URI[archive.sha256sum] = "7791a601878b765669022b8b3409fba33cc72f9e39340fec8af6d0e6f72dec39"
recipes/gcc/gcc-4.0.0.inc +0 -1
index dd48595..e16b388 100644
@@ -6,7 +6,6 @@ NATIVEDEPS = "mpfr-native gmp-native"
 SRC_URI = "${GNU_MIRROR}/gcc/gcc-${PV}/gcc-${PV}.tar.bz2;name=archive \
 	file://gcc-posix-open-fix.patch \
 	file://zecke-xgcc-cpp.patch"
-SRC_URI_append_fail-fast = " file://zecke-no-host-includes.patch "
 
 # Language Overrides
 FORTRAN = ",f95"
recipes/gcc/gcc-4.0.2.inc +0 -2
index 16584ec..9eb25d7 100644
@@ -21,8 +21,6 @@ SRC_URI_append = " file://100-uclibc-conf.patch   \
 		   file://gcc-4.0.2-atmel.0.99.2.patch \
 		   "
 
-SRC_URI_append_fail-fast = " file://zecke-no-host-includes.patch "
-
 # Language Overrides
 FORTRAN = ""
 
recipes/gcc/gcc-4.1.0.inc +1 -3
index bfaf699..1e296fc 100644
@@ -1,6 +1,6 @@
 require gcc-common.inc
 
-INC_PR = "r10"
+INC_PR = "r11"
 
 DEFAULT_PREFERENCE = "-1"
 
@@ -13,8 +13,6 @@ SRC_URI = "${GNU_MIRROR}/gcc/gcc-${PV}/gcc-${PV}.tar.bz2;name=archive \
 	file://zecke-xgcc-cpp.patch \
     file://pr34130.patch"
 
-SRC_URI_append_fail-fast = " file://zecke-no-host-includes.patch "
-
 EXTRA_OECONF_BASE = "--disable-libssp --disable-libmudflap"
 EXTRA_OECONF_INITIAL = "--disable-libmudflap --disable-libssp"
 EXTRA_OECONF_INTERMEDIATE = "--disable-libmudflap --disable-libssp"
recipes/gcc/gcc-cross_3.4.4.bb +3 -1
index 40ea603..d8199e4 100644
@@ -1,4 +1,6 @@
-PR = "${INC_PR}.1"
+PR = "${INC_PR}.2"
 
 require gcc-${PV}.inc
 require gcc-cross.inc
+
+SRC_URI_append_fail-fast = " file://ibad-4.2.1.patch "
recipes/gcc/gcc-cross_4.0.0.bb +3 -1
index 2ab9ef4..7b57648 100644
@@ -1,4 +1,6 @@
-PR = "r9"
+PR = "r10"
 
 require gcc-${PV}.inc
 require gcc-cross4.inc
+
+SRC_URI_append_fail-fast = " file://ibad-4.2.1.patch "
recipes/gcc/gcc-cross_4.0.2.bb +3 -1
index 1294af5..4c2997c 100644
@@ -1,4 +1,6 @@
-PR = "r15"
+PR = "r16"
 
 require gcc-${PV}.inc
 require gcc-cross4.inc
+
+SRC_URI_append_fail-fast = " file://ibad-4.2.1.patch "
recipes/gcc/gcc-cross_4.1.0.bb +3 -1
index 39ad5fe..5e9df67 100644
@@ -1,7 +1,9 @@
-PR = "${INC_PR}.1"
+PR = "${INC_PR}.2"
 
 require gcc-${PV}.inc
 require gcc-cross4.inc
 
+SRC_URI_append_fail-fast = " file://ibad-4.2.1.patch "
+
 EXTRA_OECONF += "--disable-libunwind-exceptions --with-mpfr=${STAGING_DIR_NATIVE}${prefix_native}"
 
recipes/gcc/gcc-cross_4.1.1.bb +2 -2
index 1864078..606a4cb 100644
@@ -1,8 +1,8 @@
-PR = "${INC_PR}.1"
+PR = "${INC_PR}.2"
 
 require gcc-${PV}.inc
 require gcc-cross4.inc
 
-SRC_URI_append_fail-fast = " file://zecke-no-host-includes.patch "
+SRC_URI_append_fail-fast = " file://ibad-4.2.1.patch "
 
 EXTRA_OECONF += "--disable-libunwind-exceptions --with-mpfr=${STAGING_DIR_NATIVE}${prefix_native}"
recipes/gcc/gcc-cross_4.1.2.bb +2 -2
index d2038c7..7431368 100644
@@ -1,9 +1,9 @@
-PR = "${INC_PR}.1"
+PR = "${INC_PR}.2"
 
 require gcc-${PV}.inc
 require gcc-cross4.inc
 
-SRC_URI_append_fail-fast = " file://zecke-no-host-includes.patch "
+SRC_URI_append_fail-fast = " file://ibad-4.2.1.patch "
 
 EXTRA_OECONF_append_avr32= "  --disable-libmudflap "
 
recipes/gcc/gcc-cross_4.2.1.bb +2 -2
index ae7f2b7..e6a14aa 100644
@@ -1,9 +1,9 @@
-PR = "r21"
+PR = "r22"
 
 require gcc-${PV}.inc
 require gcc-cross4.inc
 
-SRC_URI_append_fail-fast = " file://zecke-no-host-includes.patch "
+SRC_URI_append_fail-fast = " file://ibad-4.2.1.patch "
 
 EXTRA_OECONF += "--disable-libunwind-exceptions --with-mpfr=${STAGING_DIR_NATIVE}${prefix_native}"
 
recipes/gcc/gcc-cross_4.2.2.bb +2 -2
index 30c1d78..272610a 100644
@@ -1,9 +1,9 @@
-PR = "${INC_PR}.1"
+PR = "${INC_PR}.2"
 
 require gcc-${PV}.inc
 require gcc-cross4.inc
 
-SRC_URI_append_fail-fast = " file://zecke-no-host-includes.patch "
+SRC_URI_append_fail-fast = " file://ibad-4.2.1.patch "
 
 EXTRA_OECONF += "--disable-libunwind-exceptions --with-mpfr=${STAGING_DIR_NATIVE}${prefix_native}"
 
recipes/gcc/gcc-cross_4.2.3.bb +2 -2
index 13dec27..4f2cea1 100644
@@ -1,9 +1,9 @@
-PR = "${INC_PR}.1"
+PR = "${INC_PR}.2"
 
 require gcc-${PV}.inc
 require gcc-cross4.inc
 
-SRC_URI_append_fail-fast = " file://zecke-no-host-includes.patch "
+SRC_URI_append_fail-fast = " file://ibad-4.2.1.patch "
 
 EXTRA_OECONF += "--disable-libunwind-exceptions --with-mpfr=${STAGING_DIR_NATIVE}${prefix_native}"
 
recipes/gcc/gcc-cross_4.2.4.bb +2 -2
index 13dec27..4f2cea1 100644
@@ -1,9 +1,9 @@
-PR = "${INC_PR}.1"
+PR = "${INC_PR}.2"
 
 require gcc-${PV}.inc
 require gcc-cross4.inc
 
-SRC_URI_append_fail-fast = " file://zecke-no-host-includes.patch "
+SRC_URI_append_fail-fast = " file://ibad-4.2.1.patch "
 
 EXTRA_OECONF += "--disable-libunwind-exceptions --with-mpfr=${STAGING_DIR_NATIVE}${prefix_native}"
 
recipes/gcc/gcc-cross_4.3.1.bb +2 -2
index 1c191fa..672a892 100644
@@ -1,9 +1,9 @@
-PR = "${INC_PR}.1"
+PR = "${INC_PR}.2"
 
 require gcc-${PV}.inc
 require gcc-cross4.inc
 
-SRC_URI_append_fail-fast = " file://zecke-no-host-includes.patch "
+SRC_URI_append_fail-fast = " file://ibad-4.3.3.patch "
 
 EXTRA_OECONF += "  --enable-cheaders=c_std --disable-libunwind-exceptions --with-mpfr=${STAGING_DIR_NATIVE}${prefix_native}"
 
recipes/gcc/gcc-cross_4.3.2.bb +2 -2
index 322a203..19407b0 100644
@@ -1,8 +1,8 @@
-PR = "${INC_PR}.1"
+PR = "${INC_PR}.2"
 require gcc-${PV}.inc
 require gcc-cross4.inc
 
-SRC_URI_append_fail-fast = " file://zecke-no-host-includes.patch "
+SRC_URI_append_fail-fast = " file://ibad-4.3.3.patch "
 
 EXTRA_OECONF += "  --enable-cheaders=c_std --disable-libunwind-exceptions --with-mpfr=${STAGING_DIR_NATIVE}${prefix_native}"
 
recipes/gcc/gcc-cross_4.3.3.bb +2 -2
index c8e2f9b..20440cc 100644
@@ -1,8 +1,8 @@
-PR = "${INC_PR}.1"
+PR = "${INC_PR}.2"
 require gcc-${PV}.inc
 require gcc-cross4.inc
 
-SRC_URI_append_fail-fast = " file://zecke-no-host-includes.patch "
+SRC_URI_append_fail-fast = " file://ibad-4.3.3.patch "
 
 EXTRA_OECONF += "  --enable-cheaders=c_std --disable-libunwind-exceptions --with-mpfr=${STAGING_DIR_NATIVE}${prefix_native}"
 
recipes/gcc/gcc-cross_4.3.4.bb +2 -2
index 7edb21b..69fa142 100644
@@ -1,8 +1,8 @@
-PR = "${INC_PR}.0"
+PR = "${INC_PR}.1"
 require gcc-${PV}.inc
 require gcc-cross4.inc
 
-SRC_URI_append_fail-fast = " file://zecke-no-host-includes.patch "
+SRC_URI_append_fail-fast = " file://ibad-4.3.3.patch "
 
 EXTRA_OECONF += "  --enable-cheaders=c_std --disable-libunwind-exceptions --with-mpfr=${STAGING_DIR_NATIVE}${prefix_native}"
 
recipes/gcc/gcc-cross_4.4.1.bb +2 -2
index fce459b..5a8ebb8 100644
@@ -1,8 +1,8 @@
 require gcc-${PV}.inc
 require gcc-cross4.inc
-PR = "${INC_PR}.1"
+PR = "${INC_PR}.2"
 
-SRC_URI_append_fail-fast = " file://zecke-no-host-includes.patch "
+SRC_URI_append_fail-fast = " file://ibad-4.4.1.patch "
 
 EXTRA_OECONF += " --disable-libunwind-exceptions --with-mpfr=${STAGING_DIR_NATIVE}${prefix_native}"
 
recipes/gcc/gcc-cross_4.4.2.bb +2 -2
index fce459b..5a8ebb8 100644
@@ -1,8 +1,8 @@
 require gcc-${PV}.inc
 require gcc-cross4.inc
-PR = "${INC_PR}.1"
+PR = "${INC_PR}.2"
 
-SRC_URI_append_fail-fast = " file://zecke-no-host-includes.patch "
+SRC_URI_append_fail-fast = " file://ibad-4.4.1.patch "
 
 EXTRA_OECONF += " --disable-libunwind-exceptions --with-mpfr=${STAGING_DIR_NATIVE}${prefix_native}"
 
recipes/gcc/gcc-cross_4.4.4.bb +2 -2
index 4309fd4..d069bd6 100644
@@ -1,8 +1,8 @@
 require gcc-${PV}.inc
 require gcc-cross4.inc
-PR = "${INC_PR}.0"
+PR = "${INC_PR}.1"
 
-SRC_URI_append_fail-fast = " file://zecke-no-host-includes.patch "
+SRC_URI_append_fail-fast = " file://ibad-4.4.1.patch "
 
 EXTRA_OECONF += " --disable-libunwind-exceptions --with-mpfr=${STAGING_DIR_NATIVE}${prefix_native}"
 
recipes/gcc/gcc-cross_4.5.bb +2 -2
index a2da4a8..82ff1ae 100644
@@ -1,9 +1,9 @@
-PR = "r1"
+PR = "r2"
 require gcc-${PV}.inc
 require gcc-cross4.inc
 
 NATIVEDEPS += "libmpc-native libelf-native"
-SRC_URI_append_fail-fast = " file://zecke-no-host-includes.patch "
+SRC_URI_append_fail-fast = " file://ibad-4.4.1.patch "
 
 EXTRA_OECONF += " --disable-libunwind-exceptions --with-mpfr=${STAGING_DIR_NATIVE}${prefix_native} --with-system-zlib"
 
Signature · 1 line
1.7.1
#1 lore raw
Quoted 5 lines

Please note that the bitbake.conf change will break builds with versions of gcc that do not accept this -ibad parameter. I have tested that the ibad patch applies to each of the gcc versions in this patch, but only done functional tests for gcc-4.3.3 and gcc-.4.1.

That should be gcc-4.3.3 and gcc-4.4.1.

#2 lore raw
In reply to Graham Gower

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Quoted 2 lines · Graham Gower

This patch introduces a new command line parameter to gcc (at Zecke's suggestion), -ibad

It gets bonus point for being an obscure Dune reference :) -----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.5 (Darwin)

iD8DBQFMNaHwMkyGM64RGpERAjBdAJ9p7NscxVpFywRGncv7096IuWAnNgCeMCwR 8k4tXeQKH5hRccEF+KN8e0U=
=vHwm
-----END PGP SIGNATURE-----

#3 lore raw
Quoted 8 lines · Koen Kooi

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Quoted 2 lines · Graham Gower

This patch introduces a new command line parameter to gcc (at Zecke's suggestion), -ibad

It gets bonus point for being an obscure Dune reference :)

I think I lose the bonus points, as I don't understand the reference :(

#4 lore raw

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Quoted 11 lines · Graham Gower
Quoted 8 lines · Koen Kooi

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Quoted 2 lines · Graham Gower

This patch introduces a new command line parameter to gcc (at Zecke's suggestion), -ibad

It gets bonus point for being an obscure Dune reference :)

I think I lose the bonus points, as I don't understand the reference :(

http://dunepedia.wetpaint.com/page/Eyes+of+the+Ibad
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.5 (Darwin)

iD8DBQFMNcCQMkyGM64RGpERAq+wAJ9epmSlI1cQcj+wWIvTwMlF7324FQCfRoTd z30/JoyHoH6KpeKLAt/G3Ek=
=vyka
-----END PGP SIGNATURE-----

#5 lore raw
In reply to Graham Gower
Quoted 18 lines · Graham Gower

This patch introduces a new command line parameter to gcc (at Zecke's suggestion), -ibad, which may be used to specify blacklisted include prefixes. E.g.

grg@eye7:/tmp$ ~/oe2/tmp/cross/mipsel/bin/mipsel-angstrom-linux-gcc -c test.c -ibad /usr/include -I /usr/include
CROSS COMPILE Badness: /usr/include in INCLUDEPATH: /usr/include

This makes it much easier to add new blacklisted include paths, with a trivial edit to bitbake.conf. No additional paths have been added yet, but my motivation for this was to add /usr/X11R6/include and /usr/X11/include.

Please note that the bitbake.conf change will break builds with versions of gcc that do not accept this -ibad parameter. I have tested that the ibad patch applies to each of the gcc versions in this patch, but only done functional tests for gcc-4.3.3 and gcc-.4.1.

Quoted 8 lines

The following gcc versions may need attention:
3.3.3
3.3.4
svn
csl-arm-2007q3
csl-arm-2008q1
csl-arm-2008q3

csl already has a similar feature and its turned on by default but IIRC its only a warning which can be turned off by -Wno-poison-system-directories I am interested in patching svn others not so much in above lis

Quoted 6 lines

3.3.x will require a completely reworked ibad patch. The others should be compatible with one of the three ibad patches included below.

-Graham

#6 lore raw
In reply to Graham Gower
Quoted 6 lines · Graham Gower

This patch introduces a new command line parameter to gcc (at Zecke's suggestion), -ibad, which may be used to specify blacklisted include prefixes. E.g.

grg@eye7:/tmp$ ~/oe2/tmp/cross/mipsel/bin/mipsel-angstrom-linux-gcc -c test.c -ibad /usr/include -I /usr/include
CROSS COMPILE Badness: /usr/include in INCLUDEPATH: /usr/include

nice! The only thing that is worrying is the question how we make sure these bad path's are enforced.

E.g. a recipe not honoring our CPPFLAGS might silently pass this check (while before it was hardcoded into the compiler). My proposal would be to extend the sanity check and grep the compile log for gcc and -ibad and fail if gcc exists but -ibad does not occur?

#7 lore raw
Quoted 4 lines · Holger Freyther

E.g. a recipe not honoring our CPPFLAGS might silently pass this check (while before it was hardcoded into the compiler). My proposal would be to extend the sanity check and grep the compile log for gcc and -ibad and fail if gcc exists but -ibad does not occur?

That sounds a bit fragile too. How about just adding the -ibad flags to ${CC} rather than putting them in CPPFLAGS? Only the most determined package is likely to be able to build without using our value for CC.

Failing that, I guess the original approach of patching the compiler is actually the better one, inelegant though it might seem.

p.

#10 lore raw
In reply to Graham Gower
Quoted 7 lines · Graham Gower

This patch introduces a new command line parameter to gcc (at Zecke's suggestion), -ibad, which may be used to specify blacklisted include prefixes. E.g.

grg@eye7:/tmp$ ~/oe2/tmp/cross/mipsel/bin/mipsel-angstrom-linux-gcc -c test.c -ibad /usr/include -I /usr/include
CROSS COMPILE Badness: /usr/include in INCLUDEPATH: /usr/include
Quoted 7 lines

This makes it much easier to add new blacklisted include paths, with a trivial edit to bitbake.conf. No additional paths have been added yet, but my motivation for this was to add /usr/X11R6/include and /usr/X11/include.

Please note that the bitbake.conf change will break builds with versions of gcc that do not accept this -ibad parameter. I have

Does it mean any external toolchain will be broken or require changes to the bitbake.conf?

Signature · 1 line
Denys
Quoted 17 lines

tested that the ibad patch applies to each of the gcc versions in this patch, but only done functional tests for gcc-4.3.3 and gcc-.4.1.

The following gcc versions may need attention:
3.3.3
3.3.4
svn
csl-arm-2007q3
csl-arm-2008q1
csl-arm-2008q3

3.3.x will require a completely reworked ibad patch. The others should be compatible with one of the three ibad patches included below.

-Graham

#8 lore raw
In reply to Holger Freyther
Quoted 8 lines · Holger Freyther
Quoted 6 lines · Graham Gower

This patch introduces a new command line parameter to gcc (at Zecke's suggestion), -ibad, which may be used to specify blacklisted include prefixes. E.g.

grg@eye7:/tmp$ ~/oe2/tmp/cross/mipsel/bin/mipsel-angstrom-linux-gcc -c test.c -ibad /usr/include -I /usr/include
CROSS COMPILE Badness: /usr/include in INCLUDEPATH: /usr/include
Quoted 7 lines

nice! The only thing that is worrying is the question how we make sure these bad path's are enforced.

E.g. a recipe not honoring our CPPFLAGS might silently pass this check (while before it was hardcoded into the compiler). My proposal would be to extend the sanity check and grep the compile log for gcc and -ibad and fail if gcc exists but -ibad does not occur?

How about making this option an environmental variable rather than a flag? I've seen that technique used to great effect for this exact reason before...

Cheers,

Richard

#11 lore raw
In reply to Denys Dmytriyenko
Quoted 13 lines · Denys Dmytriyenko
Quoted 12 lines · Graham Gower

This patch introduces a new command line parameter to gcc (at Zecke's suggestion), -ibad, which may be used to specify blacklisted include prefixes. E.g.

grg@eye7:/tmp$ ~/oe2/tmp/cross/mipsel/bin/mipsel-angstrom-linux-gcc -c test.c -ibad /usr/include -I /usr/include
CROSS COMPILE Badness: /usr/include in INCLUDEPATH: /usr/include

This makes it much easier to add new blacklisted include paths, with a trivial edit to bitbake.conf. No additional paths have been added yet, but my motivation for this was to add /usr/X11R6/include and /usr/X11/include.

Quoted 5 lines
Quoted 2 lines

Please note that the bitbake.conf change will break builds with versions of gcc that do not accept this -ibad parameter. I have

Does it mean any external toolchain will be broken or require changes to the bitbake.conf?

Yes.

#9 lore raw
In reply to Richard Purdie
Quoted 9 lines · Richard Purdie
Quoted 8 lines · Holger Freyther
Quoted 6 lines · Graham Gower

This patch introduces a new command line parameter to gcc (at Zecke's suggestion), -ibad, which may be used to specify blacklisted include prefixes. E.g.

grg@eye7:/tmp$ ~/oe2/tmp/cross/mipsel/bin/mipsel-angstrom-linux-gcc -c test.c -ibad /usr/include -I /usr/include
CROSS COMPILE Badness: /usr/include in INCLUDEPATH: /usr/include
Quoted 7 lines
Quoted 7 lines

nice! The only thing that is worrying is the question how we make sure these bad path's are enforced.

E.g. a recipe not honoring our CPPFLAGS might silently pass this check (while before it was hardcoded into the compiler). My proposal would be to extend the sanity check and grep the compile log for gcc and -ibad and fail if gcc exists but -ibad does not occur?

I haven't tried this, but I suspect it wouldn't be too difficult to put them into gcc's default spec file.
That would fix the problem of breaking things for an external toolchain too.

Quoted 4 lines

How about making this option an environmental variable rather than a flag? I've seen that technique used to great effect for this exact reason before...

That would work too.

-Graham

#12 lore raw

PATCH 1/1 gcc: badness with -ibad, a replacement for zecke-no-host-includes.patch

In reply to Graham Gower

Subject: [PATCH] gcc: badness with -ibad, a replacement for zecke-no-host-includes.patch

This change makes it significantly easier to add new blacklisted include paths by introducing a new command line parameter to gcc, -ibad, which may be used to specify blacklisted include prefixes. A list of bad include paths are provided in gcc's default specs file and may be modified by editing ibad-specs.sed.

---

This version addresses previous concerns regarding bitbake.conf changes breaking toolchains without -ibad support and the enforcement of the -ibad flags for recipes which may break CPPFLAGS.

If it is desired that an environment variable be used for additional flags, this could be supported in the spec file with %:getenv(), see
http://gcc.gnu.org/onlinedocs/gcc/Spec-Files.html

I've only provided patches against recent gcc versions, but older versions should work fine too, with the ibad-4.2.1.patch previously posted. I confirmed that ibad-4.6.patch applies correctly to gcc from svn, but was unable to test due to an unrelated patch failing (gcc-flags-for-build.patch).

---
 recipes/gcc/files/ibad-4.3.3.patch |  117 ++++++++++++++++++++++++++++++++++
 recipes/gcc/files/ibad-4.4.1.patch |  117 ++++++++++++++++++++++++++++++++++
 recipes/gcc/files/ibad-4.6.patch   |  122 ++++++++++++++++++++++++++++++++++++
 recipes/gcc/files/ibad-specs.sed   |    9 +++
 recipes/gcc/gcc-cross_4.3.1.bb     |   11 +++-
 recipes/gcc/gcc-cross_4.3.2.bb     |   12 +++-
 recipes/gcc/gcc-cross_4.3.3.bb     |   11 +++-
 recipes/gcc/gcc-cross_4.3.4.bb     |   11 +++-
 recipes/gcc/gcc-cross_4.4.1.bb     |   11 +++-
 recipes/gcc/gcc-cross_4.4.2.bb     |   11 +++-
 recipes/gcc/gcc-cross_4.4.4.bb     |   12 +++-
 recipes/gcc/gcc-cross_4.5.bb       |   12 +++-
 recipes/gcc/gcc-cross_svn.bb       |   12 +++-
 13 files changed, 450 insertions(+), 18 deletions(-)
 create mode 100644 recipes/gcc/files/ibad-4.3.3.patch
 create mode 100644 recipes/gcc/files/ibad-4.4.1.patch
 create mode 100644 recipes/gcc/files/ibad-4.6.patch
 create mode 100644 recipes/gcc/files/ibad-specs.sed
recipes/gcc/files/ibad-4.3.3.patch new file +117 -0
new file mode 100644
index 0000000..dfc1d10
@@ -0,0 +1,117 @@
+diff -ur gcc-4.3.3-orig/gcc/c-incpath.c gcc-4.3.3/gcc/c-incpath.c
+--- gcc-4.3.3-orig/gcc/c-incpath.c	2007-07-26 18:07:01.000000000 +0930
++++ gcc-4.3.3/gcc/c-incpath.c	2010-07-08 12:21:08.000000000 +0930
+@@ -58,8 +58,8 @@
+ 					   struct cpp_dir *, int);
+ 
+ /* Include chains heads and tails.  */
+-static struct cpp_dir *heads[4];
+-static struct cpp_dir *tails[4];
++static struct cpp_dir *heads[5];
++static struct cpp_dir *tails[5];
+ static bool quote_ignores_source_dir;
+ enum { REASON_QUIET = 0, REASON_NOENT, REASON_DUP, REASON_DUP_SYS };
+ 
+@@ -283,6 +283,32 @@
+   return head;
+ }
+ 
++/* Exit if paths in BAD are found in HEAD. */
++static void
++check_bad_includes (struct cpp_dir *head, struct cpp_dir *bad)
++{
++  struct cpp_dir *h, *b;
++  size_t len;
++
++  if (head == NULL)
++    return;
++
++  for (b = bad; b; b = b->next)
++    {
++      len = strlen(b->name);
++      for (h = head; h; h = h->next)
++        {
++          if (!strncmp(h->name, b->name, len))
++            {
++                fprintf(stderr,
++                          _("CROSS COMPILE Badness: %s in INCLUDEPATH: %s\n"),
++                          b->name, h->name);
++                exit(EXIT_FAILURE);
++            }
++        }
++    }
++}
++
+ /* Add SYSROOT to any user-supplied paths in CHAIN starting with
+    "=".  */
+ 
+@@ -318,6 +344,13 @@
+       add_sysroot_to_chain (sysroot, AFTER);
+     }
+ 
++  /* Exit if paths specified with -ibad are found in the include chain.
++     This must be done before inode duplicates are removed. */
++  check_bad_includes(heads[QUOTE], heads[BAD]);
++  check_bad_includes(heads[BRACKET], heads[BAD]);
++  check_bad_includes(heads[SYSTEM], heads[BAD]);
++  check_bad_includes(heads[AFTER], heads[BAD]);
++
+   /* Join the SYSTEM and AFTER chains.  Remove duplicates in the
+      resulting SYSTEM chain.  */
+   if (heads[SYSTEM])
+diff -ur gcc-4.3.3-orig/gcc/c-incpath.h gcc-4.3.3/gcc/c-incpath.h
+--- gcc-4.3.3-orig/gcc/c-incpath.h	2007-07-26 18:07:01.000000000 +0930
++++ gcc-4.3.3/gcc/c-incpath.h	2010-07-07 14:58:53.000000000 +0930
+@@ -30,4 +30,4 @@
+ 
+ extern struct target_c_incpath_s target_c_incpath;
+ 
+-enum { QUOTE = 0, BRACKET, SYSTEM, AFTER };
++enum { QUOTE = 0, BRACKET, SYSTEM, AFTER, BAD };
+diff -ur gcc-4.3.3-orig/gcc/c-opts.c gcc-4.3.3/gcc/c-opts.c
+--- gcc-4.3.3-orig/gcc/c-opts.c	2008-01-23 00:41:44.000000000 +1030
++++ gcc-4.3.3/gcc/c-opts.c	2010-07-08 09:31:23.000000000 +0930
+@@ -164,6 +164,7 @@
+ 
+     case OPT_F:
+     case OPT_I:
++    case OPT_ibad:
+     case OPT_idirafter:
+     case OPT_isysroot:
+     case OPT_isystem:
+@@ -848,6 +849,10 @@
+       set_struct_debug_option (arg);
+       break;
+ 
++    case OPT_ibad:
++      add_path (xstrdup (arg), BAD, 0, true);
++      break;
++
+     case OPT_idirafter:
+       add_path (xstrdup (arg), AFTER, 0, true);
+       break;
+diff -ur gcc-4.3.3-orig/gcc/c.opt gcc-4.3.3/gcc/c.opt
+--- gcc-4.3.3-orig/gcc/c.opt	2008-01-13 10:52:38.000000000 +1030
++++ gcc-4.3.3/gcc/c.opt	2010-07-07 14:57:21.000000000 +0930
+@@ -822,6 +822,10 @@
+ C ObjC C++ ObjC++ Joined
+ -femit-struct-debug-detailed=<spec-list>	Detailed reduced debug info for structs
+ 
++ibad
++C ObjC C++ ObjC++ Joined Separate
++-ibad <dir>	Abort if <dir> is specified in the include paths
++
+ idirafter
+ C ObjC C++ ObjC++ Joined Separate
+ -idirafter <dir>	Add <dir> to the end of the system include path
+diff -ur gcc-4.3.3-orig/gcc/gcc.h gcc-4.3.3/gcc/gcc.h
+--- gcc-4.3.3-orig/gcc/gcc.h	2007-07-26 18:07:01.000000000 +0930
++++ gcc-4.3.3/gcc/gcc.h	2010-07-08 09:26:17.000000000 +0930
+@@ -45,6 +45,7 @@
+  (!strcmp (STR, "Tdata") || !strcmp (STR, "Ttext")	\
+   || !strcmp (STR, "Tbss") || !strcmp (STR, "include")	\
+   || !strcmp (STR, "imacros") || !strcmp (STR, "aux-info") \
++  || !strcmp (STR, "ibad") \
+   || !strcmp (STR, "idirafter") || !strcmp (STR, "iprefix") \
+   || !strcmp (STR, "iwithprefix") || !strcmp (STR, "iwithprefixbefore") \
+   || !strcmp (STR, "iquote") || !strcmp (STR, "isystem") \
recipes/gcc/files/ibad-4.4.1.patch new file +117 -0

117 lines not on this page · raw message

recipes/gcc/files/ibad-4.6.patch new file +122 -0

122 lines not on this page · raw message

recipes/gcc/files/ibad-specs.sed new file +9 -0
new file mode 100644
index 0000000..59ad077
@@ -0,0 +1,9 @@
+# Add bad_includes to the cpp spec string.
+/^*cpp:$/ {n; s|^|%(bad_includes) |}
+
+# Add bad_includes to the cc1plus spec string.
+/^*cc1plus:$/ {n; s|^|%(bad_includes) |}
+
+# Append the bad_incldues spec string to the file.
+$ a *bad_includes:\
+-ibad /usr/include -ibad /sw/include -ibad /opt/include -ibad /usr/X11R6/include -ibad /usr/X11/include -ibad /usr/local/include
recipes/gcc/gcc-cross_4.3.1.bb +9 -2
index 1c191fa..879c2ac 100644
@@ -1,11 +1,18 @@
-PR = "${INC_PR}.1"
+PR = "${INC_PR}.2"
 
 require gcc-${PV}.inc
 require gcc-cross4.inc
 
-SRC_URI_append_fail-fast = " file://zecke-no-host-includes.patch "
+SRC_URI_append_fail-fast = " file://ibad-4.3.3.patch \
+				file://ibad-specs.sed"
 
 EXTRA_OECONF += "  --enable-cheaders=c_std --disable-libunwind-exceptions --with-mpfr=${STAGING_DIR_NATIVE}${prefix_native}"
 
 ARCH_FLAGS_FOR_TARGET += "-isystem${STAGING_DIR_TARGET}${target_includedir}"
 
+do_install_append() {
+	# Add -ibad paths to the default cflags.
+	install -m 0755 -d ${gcclibdir}/${TARGET_SYS}/${BINV}
+	${TARGET_PREFIX}gcc -dumpspecs | sed -f ${WORKDIR}/ibad-specs.sed \
+		> ${gcclibdir}/${TARGET_SYS}/${BINV}/specs
+}
recipes/gcc/gcc-cross_4.3.2.bb +10 -2
index 322a203..c9433e9 100644
@@ -1,9 +1,17 @@
-PR = "${INC_PR}.1"
+PR = "${INC_PR}.2"
 require gcc-${PV}.inc
 require gcc-cross4.inc
 
-SRC_URI_append_fail-fast = " file://zecke-no-host-includes.patch "
+SRC_URI_append_fail-fast = " file://ibad-4.3.3.patch \
+				file://ibad-specs.sed"
 
 EXTRA_OECONF += "  --enable-cheaders=c_std --disable-libunwind-exceptions --with-mpfr=${STAGING_DIR_NATIVE}${prefix_native}"
 
 ARCH_FLAGS_FOR_TARGET += "-isystem${STAGING_DIR_TARGET}${target_includedir}"
+
+do_install_append() {
+	# Add -ibad paths to the default cflags.
+	install -m 0755 -d ${gcclibdir}/${TARGET_SYS}/${BINV}
+	${TARGET_PREFIX}gcc -dumpspecs | sed -f ${WORKDIR}/ibad-specs.sed \
+		> ${gcclibdir}/${TARGET_SYS}/${BINV}/specs
+}
recipes/gcc/gcc-cross_4.3.3.bb +9 -2
index c8e2f9b..c9433e9 100644
@@ -1,10 +1,17 @@
-PR = "${INC_PR}.1"
+PR = "${INC_PR}.2"
 require gcc-${PV}.inc
 require gcc-cross4.inc
 
-SRC_URI_append_fail-fast = " file://zecke-no-host-includes.patch "
+SRC_URI_append_fail-fast = " file://ibad-4.3.3.patch \
+				file://ibad-specs.sed"
 
 EXTRA_OECONF += "  --enable-cheaders=c_std --disable-libunwind-exceptions --with-mpfr=${STAGING_DIR_NATIVE}${prefix_native}"
 
 ARCH_FLAGS_FOR_TARGET += "-isystem${STAGING_DIR_TARGET}${target_includedir}"
 
+do_install_append() {
+	# Add -ibad paths to the default cflags.
+	install -m 0755 -d ${gcclibdir}/${TARGET_SYS}/${BINV}
+	${TARGET_PREFIX}gcc -dumpspecs | sed -f ${WORKDIR}/ibad-specs.sed \
+		> ${gcclibdir}/${TARGET_SYS}/${BINV}/specs
+}
recipes/gcc/gcc-cross_4.3.4.bb +9 -2
index 7edb21b..c35abbb 100644
@@ -1,10 +1,17 @@
-PR = "${INC_PR}.0"
+PR = "${INC_PR}.1"
 require gcc-${PV}.inc
 require gcc-cross4.inc
 
-SRC_URI_append_fail-fast = " file://zecke-no-host-includes.patch "
+SRC_URI_append_fail-fast = " file://ibad-4.3.3.patch \
+				file://ibad-specs.sed"
 
 EXTRA_OECONF += "  --enable-cheaders=c_std --disable-libunwind-exceptions --with-mpfr=${STAGING_DIR_NATIVE}${prefix_native}"
 
 ARCH_FLAGS_FOR_TARGET += "-isystem${STAGING_DIR_TARGET}${target_includedir}"
 
+do_install_append() {
+	# Add -ibad paths to the default cflags.
+	install -m 0755 -d ${gcclibdir}/${TARGET_SYS}/${BINV}
+	${TARGET_PREFIX}gcc -dumpspecs | sed -f ${WORKDIR}/ibad-specs.sed \
+		> ${gcclibdir}/${TARGET_SYS}/${BINV}/specs
+}
recipes/gcc/gcc-cross_4.4.1.bb +9 -2
index fce459b..9aceaa2 100644
@@ -1,10 +1,17 @@
 require gcc-${PV}.inc
 require gcc-cross4.inc
-PR = "${INC_PR}.1"
+PR = "${INC_PR}.2"
 
-SRC_URI_append_fail-fast = " file://zecke-no-host-includes.patch "
+SRC_URI_append_fail-fast = " file://ibad-4.4.1.patch \
+				file://ibad-specs.sed"
 
 EXTRA_OECONF += " --disable-libunwind-exceptions --with-mpfr=${STAGING_DIR_NATIVE}${prefix_native}"
 
 ARCH_FLAGS_FOR_TARGET += "-isystem${STAGING_DIR_TARGET}${target_includedir}"
 
+do_install_append() {
+	# Add -ibad paths to the default cflags.
+	install -m 0755 -d ${gcclibdir}/${TARGET_SYS}/${BINV}
+	${TARGET_PREFIX}gcc -dumpspecs | sed -f ${WORKDIR}/ibad-specs.sed \
+		> ${gcclibdir}/${TARGET_SYS}/${BINV}/specs
+}
recipes/gcc/gcc-cross_4.4.2.bb +9 -2
index fce459b..9aceaa2 100644
@@ -1,10 +1,17 @@
 require gcc-${PV}.inc
 require gcc-cross4.inc
-PR = "${INC_PR}.1"
+PR = "${INC_PR}.2"
 
-SRC_URI_append_fail-fast = " file://zecke-no-host-includes.patch "
+SRC_URI_append_fail-fast = " file://ibad-4.4.1.patch \
+				file://ibad-specs.sed"
 
 EXTRA_OECONF += " --disable-libunwind-exceptions --with-mpfr=${STAGING_DIR_NATIVE}${prefix_native}"
 
 ARCH_FLAGS_FOR_TARGET += "-isystem${STAGING_DIR_TARGET}${target_includedir}"
 
+do_install_append() {
+	# Add -ibad paths to the default cflags.
+	install -m 0755 -d ${gcclibdir}/${TARGET_SYS}/${BINV}
+	${TARGET_PREFIX}gcc -dumpspecs | sed -f ${WORKDIR}/ibad-specs.sed \
+		> ${gcclibdir}/${TARGET_SYS}/${BINV}/specs
+}
recipes/gcc/gcc-cross_4.4.4.bb +10 -2
index 4309fd4..431ba44 100644
@@ -1,9 +1,17 @@
 require gcc-${PV}.inc
 require gcc-cross4.inc
-PR = "${INC_PR}.0"
+PR = "${INC_PR}.1"
 
-SRC_URI_append_fail-fast = " file://zecke-no-host-includes.patch "
+SRC_URI_append_fail-fast = " file://ibad-4.4.1.patch \
+				file://ibad-specs.sed"
 
 EXTRA_OECONF += " --disable-libunwind-exceptions --with-mpfr=${STAGING_DIR_NATIVE}${prefix_native}"
 
 ARCH_FLAGS_FOR_TARGET += "-isystem${STAGING_DIR_TARGET}${target_includedir}"
+
+do_install_append() {
+	# Add -ibad paths to the default cflags.
+	install -m 0755 -d ${gcclibdir}/${TARGET_SYS}/${BINV}
+	${TARGET_PREFIX}gcc -dumpspecs | sed -f ${WORKDIR}/ibad-specs.sed \
+		> ${gcclibdir}/${TARGET_SYS}/${BINV}/specs
+}
recipes/gcc/gcc-cross_4.5.bb +10 -2
index a2da4a8..abf0af5 100644
@@ -1,10 +1,18 @@
-PR = "r1"
+PR = "r2"
 require gcc-${PV}.inc
 require gcc-cross4.inc
 
 NATIVEDEPS += "libmpc-native libelf-native"
-SRC_URI_append_fail-fast = " file://zecke-no-host-includes.patch "
+SRC_URI_append_fail-fast = " file://ibad-4.4.1.patch \
+				file://ibad-specs.sed"
 
 EXTRA_OECONF += " --disable-libunwind-exceptions --with-mpfr=${STAGING_DIR_NATIVE}${prefix_native} --with-system-zlib"
 
 ARCH_FLAGS_FOR_TARGET += "-isystem${STAGING_DIR_TARGET}${target_includedir}"
+
+do_install_append() {
+	# Add -ibad paths to the default cflags.
+	install -m 0755 -d ${gcclibdir}/${TARGET_SYS}/${BINV}
+	${TARGET_PREFIX}gcc -dumpspecs | sed -f ${WORKDIR}/ibad-specs.sed \
+		> ${gcclibdir}/${TARGET_SYS}/${BINV}/specs
+}
recipes/gcc/gcc-cross_svn.bb +10 -2
index 825a7bd..3d1e22a 100644
@@ -1,11 +1,19 @@
-PR = "r0"
+PR = "r1"
 require gcc-${PV}.inc
 require gcc-cross4.inc
 
 DEPENDS += "libmpc-native"
 
-SRC_URI_append_fail-fast = " file://zecke-no-host-includes.patch "
+SRC_URI_append_fail-fast = " file://ibad-4.6.patch \
+				file://ibad-specs.sed"
 
 EXTRA_OECONF += " --disable-libunwind-exceptions --with-mpfr=${STAGING_DIR_NATIVE}${prefix_native} --with-system-zlib"
 
 ARCH_FLAGS_FOR_TARGET += "-isystem${STAGING_DIR_TARGET}${target_includedir}"
+
+do_install_append() {
+	# Add -ibad paths to the default cflags.
+	install -m 0755 -d ${gcclibdir}/${TARGET_SYS}/${BINV}
+	${TARGET_PREFIX}gcc -dumpspecs | sed -f ${WORKDIR}/ibad-specs.sed \
+		> ${gcclibdir}/${TARGET_SYS}/${BINV}/specs
+}
Signature · 1 line
1.7.1