insane: don't check for a warning string that is never output
PATCH 1/4 insane: don't check for a warning string that is never output
insane has checks that the compiler isn't printing "CROSS COMPILE Badness" during configure/compile/install, but this message hasn't been output by GCC since 2010 (23f522e7).
The current warning is "include location [...] is unsafe for cross- compilation" and as that is a proper GCC warning, we can make it fatal in follow-up patches.
--- meta/classes/insane.bbclass | 22 +--------------------- 1 file changed, 1 insertion(+), 21 deletions(-)
meta/classes/insane.bbclass +1 -21
@@ -1014,26 +1014,6 @@ python do_package_qa () { logdir = d.getVar('T') pn = d.getVar('PN') - # Check the compile log for host contamination - compilelog = os.path.join(logdir,"log.do_compile") - - if os.path.exists(compilelog): - statement = "grep -e 'CROSS COMPILE Badness:' -e 'is unsafe for cross-compilation' %s > /dev/null" % compilelog - if subprocess.call(statement, shell=True) == 0: - msg = "%s: The compile log indicates that host include and/or library paths were used.\n \ - Please check the log '%s' for more information." % (pn, compilelog) - package_qa_handle_error("compile-host-path", msg, d) - - # Check the install log for host contamination - installlog = os.path.join(logdir,"log.do_install") - - if os.path.exists(installlog): - statement = "grep -e 'CROSS COMPILE Badness:' -e 'is unsafe for cross-compilation' %s > /dev/null" % installlog - if subprocess.call(statement, shell=True) == 0: - msg = "%s: The install log indicates that host include and/or library paths were used.\n \ - Please check the log '%s' for more information." % (pn, installlog) - package_qa_handle_error("install-host-path", msg, d) - # Scan the packages... pkgdest = d.getVar('PKGDEST') packages = set((d.getVar('PACKAGES') or '').split())
@@ -1212,7 +1192,7 @@ python do_qa_configure() { if bb.data.inherits_class('autotools', d) and not skip_configure_unsafe: bb.note("Checking autotools environment for common misconfiguration") for root, dirs, files in os.walk(workdir): - statement = "grep -q -F -e 'CROSS COMPILE Badness:' -e 'is unsafe for cross-compilation' %s" % \ + statement = "grep -q -F -e 'is unsafe for cross-compilation' %s" % \ os.path.join(root,"config.log") if "config.log" in files: if subprocess.call(statement, shell=True) == 0:
Signature · 1 line
2.25.1
PATCH 2/4 gcc: add an option for --enable-poison-system-directories to be fatal
Extend --enable-poison-system-directories so that it can be an error instead of a warning by default.
--- .../0002-gcc-poison-system-directories.patch | 56 ++++++++++++++++++- 1 file changed, 53 insertions(+), 3 deletions(-)
meta/recipes-devtools/gcc/gcc/0002-gcc-poison-system-directories.patch +53 -3
@@ -44,7 +44,7 @@ diff --git a/gcc/config.in b/gcc/config.in index 809e7b26823..5adeaeed36b 100644 --- a/gcc/config.in +++ b/gcc/config.in -@@ -224,6 +224,12 @@ +@@ -224,6 +224,16 @@ #endif
@@ -52,6 +52,10 @@ index 809e7b26823..5adeaeed36b 100644 +#ifndef USED_FOR_TARGET +#undef ENABLE_POISON_SYSTEM_DIRECTORIES +#endif ++/* Define to warn for use of native system header directories */ ++#ifndef USED_FOR_TARGET ++#undef POISON_BY_DEFAULT ++#endif + + /* Define if you want all operations on RTL (the basic data structure of the
@@ -78,7 +82,7 @@ index cd3d9516fce..8de766a942c 100755 --enable-plugin enable plugin support --enable-host-shared build host code as shared libraries --disable-libquadmath-support -@@ -30235,6 +30238,19 @@ if test "${enable_version_specific_runtime_libs+set}" = set; then : +@@ -30235,6 +30238,22 @@ if test "${enable_version_specific_runtime_libs+set}" = set; then : fi
@@ -89,9 +93,12 @@ index cd3d9516fce..8de766a942c 100755 + enable_poison_system_directories=no +fi + -+if test "x${enable_poison_system_directories}" = "xyes"; then ++if test "x${enable_poison_system_directories}" != "xno"; then + +$as_echo "#define ENABLE_POISON_SYSTEM_DIRECTORIES 1" >>confdefs.h ++if test "$enable_poison_system_directories" = "error"; then ++$as_echo "#define POISON_BY_DEFAULT 1" >>confdefs.h ++fi + +fi +
@@ -198,3 +205,46 @@ index 8a2bda00f80..9098ab044ab 100644 } /* Use given -I paths for #include "..." but not #include <...>, and +diff --git a/gcc/configure.ac b/gcc/configure.ac +index f42006e5476..de7e176ea53 100644 +--- a/gcc/configure.ac ++++ b/gcc/configure.ac +@@ -6602,12 +6602,18 @@ AC_ARG_ENABLE(version-specific-runtime-libs, + + AC_ARG_ENABLE([poison-system-directories], + AS_HELP_STRING([--enable-poison-system-directories], +- [warn for use of native system header directories]),, ++ [warn for use of native system header directories (no/yes/error)]),, + [enable_poison_system_directories=no]) ++AC_MSG_NOTICE([poisoned directories $enable_poison_system_directories]) +-if test "x${enable_poison_system_directories}" = "xyes"; then ++if test "x${enable_poison_system_directories}" != "xno"; then ++ AC_MSG_NOTICE([poisoned directories enabled]) + AC_DEFINE([ENABLE_POISON_SYSTEM_DIRECTORIES], + [1], + [Define to warn for use of native system header directories]) ++ if test $enable_poison_system_directories = "error"; then ++ AC_MSG_NOTICE([poisoned directories are fatal]) ++ AC_DEFINE([POISON_BY_DEFAULT], [1], [Define to make poison warnings errors]) ++ fi + fi + + # Substitute configuration variables +diff --git a/gcc/gcc.c b/gcc/gcc.c +index b2200c5185a..fa7b6fc8ddb 100644 +--- a/gcc/gcc.c ++++ b/gcc/gcc.c +@@ -1136,8 +1136,11 @@ static const char *cpp_unique_options = + static const char *cpp_options = + "%(cpp_unique_options) %1 %{m*} %{std*&ansi&trigraphs} %{W*&pedantic*} %{w}\ + %{f*} %{g*:%{%:debug-level-gt(0):%{g*}\ +- %{!fno-working-directory:-fworking-directory}}} %{O*}\ +- %{undef} %{save-temps*:-fpch-preprocess}"; ++ %{!fno-working-directory:-fworking-directory}}} %{O*}" ++#ifdef POISON_BY_DEFAULT ++ " -Werror=poison-system-directories" ++#endif ++ " %{undef} %{save-temps*:-fpch-preprocess}"; + + /* This contains cpp options which are not passed when the preprocessor + output will be used by another program. */
Signature · 1 line
2.25.1
PATCH 3/4 gcc-cross: make use of the system include directories fatal
In reply to Ross BurtonWhen building the cross GCC, configure it so that including the host system include directories is fatal, not just a warning.
--- meta/recipes-devtools/gcc/gcc-cross.inc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
meta/recipes-devtools/gcc/gcc-cross.inc +1 -1
@@ -21,7 +21,7 @@ require gcc-configure-common.inc # gnu) will hit a QA failure. LINKER_HASH_STYLE ?= "sysv" -EXTRA_OECONF += "--enable-poison-system-directories" +EXTRA_OECONF += "--enable-poison-system-directories=error" EXTRA_OECONF_append_sh4 = " \ --with-multilib-list= \ --enable-incomplete-targets \
Signature · 1 line
2.25.1
PATCH 4/4 oeqa/selftest: add test to verify that poisoned sysroots are detected
In reply to Ross BurtonAdd a recipe that explicitly searches /usr/include, and use that in oe-selftest to verify that host include paths are correctly causing build failures.
--- meta-selftest/recipes-test/poison/poison.bb | 16 ++++++++++++++++ meta/lib/oeqa/selftest/cases/buildoptions.py | 6 ++++++ 2 files changed, 22 insertions(+) create mode 100644 meta-selftest/recipes-test/poison/poison.bb
meta-selftest/recipes-test/poison/poison.bb new file +16 -0
@@ -0,0 +1,16 @@ +SUMMARY = "Sysroot poisoning test" +LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302" + +LICENSE = "MIT" + +inherit nopackages + +# This test confirms that compiling code that searches /usr/include for headers +# will result in compiler errors. This recipe should will fail to build and +# oe-selftest has a test that verifies that. +do_compile() { + touch empty.c + ${CPP} ${CFLAGS} -I/usr/include empty.c +} + +EXCLUDE_FROM_WORLD = "1"
meta/lib/oeqa/selftest/cases/buildoptions.py +6 -0
@@ -197,3 +197,9 @@ PREMIRRORS = "\\ bitbake("world --runall fetch") + +class Poisoning(OESelftestTestCase): + def test_poisoning(self): + res = bitbake("poison", ignore_status=True) + self.assertNotEqual(res.status, 0) + self.assertTrue("is unsafe for cross-compilation" in res.output)
Signature · 1 line
2.25.1