[OE-core] [PATCH] glibc-testing: explicitly specify system headers location for g++

Juro Bystricky jurobystricky at hotmail.com
Thu Dec 18 01:00:27 UTC 2014


The following glibc test programs fail to build when compiled using g++:
  /elf/tst-unique3cc
  /elf/tst-unique4cc
  /elf/tst-unique3lib.cc
  /elf/tst-unique3lib2.cc

The build fails because g++ system include files were not found. g++ is
invoked with -nostdinc option, so location of system include files must
be specified explicitly. glibc configure attempts to determine the
location, but this often fails for a number of reasons.

This patch tries to determine the location of g++ system include headers
just before running the glibc test suite. It queries configparms for
sysroot and the g++ compiler being used for building the test programs.
Then it queries g++ for version and machine information and based on this
information it assumes include headers in corresponding locations.

The header locations are assumed to be:
    <sysroot>/usr/include/c++/<version>
    <sysroot>/usr/include/c++/<version>/<machine>

The header locations are subsequently written out to configparms.

[YOCTO #7081]

Signed-off-by: Juro Bystricky <jurobystricky at hotmail.com>
---
 meta/recipes-core/glibc/glibc-testing.inc | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

diff --git a/meta/recipes-core/glibc/glibc-testing.inc b/meta/recipes-core/glibc/glibc-testing.inc
index ec16fe1..204c926 100644
--- a/meta/recipes-core/glibc/glibc-testing.inc
+++ b/meta/recipes-core/glibc/glibc-testing.inc
@@ -68,6 +68,25 @@ fi
 
 	fgrep tcbootstrap ${B}/config.make > ${B}/configparms
 	sed -i -e "s/\-tcbootstrap//g" ${B}/configparms
+
+# g++ uses flag -nostdinc, so the locations of system include headers must be explicitly specified.
+# If the locations are not already specified in config.make, then we provide the following locations:
+#    <sysroot>/usr/include/c++/<g++ version>
+#    <sysroot>/usr/include/c++/<g++ version>/<machine>
+
+cxxincludes=\`cat ${B}/config.make | gawk '\$1 == "c++-sysincludes"' | gawk -F"=" '{print \$2}' | sed "s/[ \t]\?//g"\`
+
+if [ -z "\$cxxincludes" ]; then
+  sysroot=\`cat ${B}/configparms | sed -n "/CXX/p" | sed -e "s/^.*--sysroot=//"\`
+  cxx=\`cat ${B}/configparms | gawk '\$1 ~ /^CXX/' | gawk -F"=" '{print \$2}' | gawk '{print \$1}'\`
+  cxxmachine=\`\$cxx -dumpmachine\`
+  cxxversion=\`\$cxx -dumpversion\`
+  if [ -d "\$sysroot/usr/include/c++/\$cxxversion" ] && [ -d "\$sysroot/usr/include/c++/\$cxxversion/\$cxxmachine" ]; then
+    # if the folders exist, pass the new value of c++-sysincludes via configparms
+    echo "c++-sysincludes = -isystem \$sysroot/usr/include/c++/\$cxxversion -isystem \$sysroot/usr/include/c++/\$cxxversion/\$cxxmachine" >> ${B}/configparms
+  fi
+fi
+
 wrapper="${S}/scripts/cross-test-ssh.sh \$target"
 localedef="${STAGING_BINDIR_NATIVE}/cross-localedef --little-endian --uint32-align=4"
 make tests-clean
-- 
1.9.1




More information about the Openembedded-core mailing list