For example: g++ tst-unique3lib.cc -c -O2 -Wall -Winline -Wwrite-strings -fmerge-all-constants -g -fPIC -I../include -I/var/tmp/glibc-build/elf -I/var/tmp/glibc-build -I../nptl/sysdeps/unix/sysv/linux/x86_64 -I../sysdeps/unix/sysv/linux/x86_64 -I../sysdeps/unix/sysv/linux/wordsize-64 -I../nptl/sysdeps/unix/sysv/linux -I../nptl/sysdeps/pthread -I../sysdeps/pthread -I../sysdeps/unix/sysv/linux -I../sysdeps/gnu -I../sysdeps/unix/common -I../sysdeps/unix/mman -I../sysdeps/unix/inet -I../nptl/sysdeps/unix/sysv -I../sysdeps/unix/sysv -I../sysdeps/unix/x86_64 -I../nptl/sysdeps/unix -I../sysdeps/unix -I../sysdeps/posix -I../sysdeps/x86_64/fpu -I../nptl/sysdeps/x86_64 -I../sysdeps/x86_64 -I../sysdeps/wordsize-64 -I../sysdeps/ieee754/ldbl-96 -I../sysdeps/ieee754/dbl-64/wordsize-64 -I../sysdeps/ieee754/dbl-64 -I../sysdeps/ieee754/flt-32 -I../sysdeps/ieee754 -I../sysdeps/generic -I../nptl -I.. -I../libio -I. -nostdinc -isystem /usr/lib/gcc/x86_64-pc-linux-gnu/4.8.0/include -isystem /usr/lib/gcc/x86_64-pc-linux-gnu/4.8.0/include-fixed -isystem /usr/include -D_LIBC_REENTRANT -include ../include/libc-symbols.h -DPIC -DSHARED -DNOT_IN_libc=1 -o /var/tmp/glibc-build/elf/tst-unique3lib.os -MD -MP -MF /var/tmp/glibc-build/elf/tst-unique3lib.os.dt -MT /var/tmp/glibc-build/elf/tst-unique3lib.os tst-unique3lib.cc:1:18: fatal error: cstdio: No such file or directory compilation terminated. This is apparently caused by the -nostdinc flag; without it the problem vanishes.
The following patch also works: diff --git a/elf/tst-unique3.cc b/elf/tst-unique3.cc index efdd6d7..bc6e6ae 100644 --- a/elf/tst-unique3.cc +++ b/elf/tst-unique3.cc @@ -1,6 +1,6 @@ #include "tst-unique3.h" -#include <cstdio> +#include <stdio.h> #include "../dlfcn/dlfcn.h" int t = S<char>::i; @@ -8,14 +8,14 @@ int t = S<char>::i; int main (void) { - std::printf ("%d %d\n", S<char>::i, t); + printf ("%d %d\n", S<char>::i, t); int result = S<char>::i++ != 1 || t != 1; result |= in_lib (); void *d = dlopen ("$ORIGIN/tst-unique3lib2.so", RTLD_LAZY); int (*fp) (); if (d == NULL || (fp = (int(*)()) dlsym (d, "in_lib2")) == NULL) { - std::printf ("failed to get symbol in_lib2\n"); + printf ("failed to get symbol in_lib2\n"); return 1; } result |= fp (); diff --git a/elf/tst-unique3lib.cc b/elf/tst-unique3lib.cc index fa8e85a..79f8b31 100644 --- a/elf/tst-unique3lib.cc +++ b/elf/tst-unique3lib.cc @@ -1,4 +1,4 @@ -#include <cstdio> +#include <stdio.h> #include "tst-unique3.h" template<typename T> int S<T>::i = 1; static int i = S<char>::i; @@ -6,6 +6,6 @@ static int i = S<char>::i; int in_lib (void) { - std::printf ("in_lib: %d %d\n", S<char>::i, i); + printf ("in_lib: %d %d\n", S<char>::i, i); return S<char>::i++ != 2 || i != 1; } diff --git a/elf/tst-unique3lib2.cc b/elf/tst-unique3lib2.cc index 17d817e..18d8100 100644 --- a/elf/tst-unique3lib2.cc +++ b/elf/tst-unique3lib2.cc @@ -1,4 +1,4 @@ -#include <cstdio> +#include <stdio.h> #include "tst-unique3.h" template<typename T> int S<T>::i; @@ -7,6 +7,6 @@ extern "C" int in_lib2 () { - std::printf ("in_lib2: %d\n", S<char>::i); + printf ("in_lib2: %d\n", S<char>::i); return S<char>::i != 3; } diff --git a/elf/tst-unique4.cc b/elf/tst-unique4.cc index 575c70d..c00df13 100644 --- a/elf/tst-unique4.cc +++ b/elf/tst-unique4.cc @@ -1,7 +1,7 @@ // BZ 12511 #include "tst-unique4.h" -#include <cstdio> +#include <stdio.h> static int a[24] = {
Octoploid, Thanks for the patch! I don't know how this worked in the past. Compiling a C++ application with -nostdinc is not going to work. Adding -nostdinc removes: /usr/include/c++/4.5 /usr/include/c++/4.5/i686-linux-gnu /usr/include/c++/4.5/backward /usr/local/include /usr/include/i386-linux-gnu /usr/include And glibc doesn't provide back the required headers to build a C++ application. I can reproduce this on my x86 build/test system, in fact you can see the failures in the 2.15 known issues: http://sourceware.org/glibc/wiki/Release/2.15 Joseph, Do you have any idea about the right fix for this? The use of C++ applications in the testsuite won't work reliably without C++ headers. I have no objection to applying Octoploid's patch since it fixes the *immediate* testsuite failures that you can see are present in 2.15 known issues. Should glibc's testsuite infrastructure add back: /usr/include/c++/4.5 /usr/include/c++/4.5/i686-linux-gnu /usr/include/c++/4.5/backward e.g. add back only the C++ header directories?
On Tue, 10 Apr 2012, carlos_odonell at mentor dot com wrote: > I don't know how this worked in the past. > > Compiling a C++ application with -nostdinc is not going to work. If you don't use --with-headers - if you use your system's default kernel headers - then you don't get -nostdinc used, so don't see this. (And that also covers the case of building a cross compiler and preinstalling the kernel headers into its default sysroot.) There is code in configure.in that tries to locate the compiler's internal directories - including the C++ ones - for the case where -nostdinc is used. So if it's not working in a particular case, I'd investigate, on the affected system, what is wrong with this configure code and how it needs to be fixed to find the right directories for C++ headers. # if using special system headers, find out the compiler's sekrit # header directory and add that to the list. NOTE: Only does the right # thing on a system that doesn't need fixincludes. (Not presently a problem.) if test -n "$sysheaders"; then SYSINCLUDES=-nostdinc for d in include include-fixed; do i=`$CC -print-file-name="$d"` && test "x$i" != x && test "x$i" != "x$d" && SYSINCLUDES="$SYSINCLUDES -isystem $i" done SYSINCLUDES="$SYSINCLUDES \ -isystem `echo $sysheaders | sed 's/:/ -isystem /g'`" if test -n "$CXX"; then CXX_SYSINCLUDES= cxxversion=`$CXX -dumpversion 2>&AS_MESSAGE_LOG_FD` && cxxmachine=`$CXX -dumpmachine 2>&AS_MESSAGE_LOG_FD` && for d in include "$cxxmachine/include"; do i=../../../../$d/c++/$cxxversion cxxheaders=`$CXX -print-file-name="$i"` && test "x$cxxheaders" != x && test "x$i" != "x$cxxheaders" && CXX_SYSINCLUDES="$CXX_SYSINCLUDES -isystem $cxxheaders \ -isystem $cxxheaders/$cxxmachine -isystem $cxxheaders/backward" done fi fi AC_SUBST(SYSINCLUDES) AC_SUBST(CXX_SYSINCLUDES)
(In reply to comment #3) > On Tue, 10 Apr 2012, carlos_odonell at mentor dot com wrote: > > > I don't know how this worked in the past. > > > > Compiling a C++ application with -nostdinc is not going to work. > > If you don't use --with-headers - if you use your system's default kernel > headers - then you don't get -nostdinc used, so don't see this. (And > that also covers the case of building a cross compiler and preinstalling > the kernel headers into its default sysroot.) Thanks for the head-up. I just didn't know that "--with-headers=/usr/include" is not only redundant, but also the root cause this issue.
--with-headers=/usr/include is working fine here.
On my machine the C++ headers live under: /usr/lib/gcc/x86_64-pc-linux-gnu/4.8.0/include/g++-v4/ and when I insert a few echos: 5256 cxxheaders=`$CXX -print-file-name="$i"` && 5257 echo $i && echo $cxxheaders && 5258 test "x$cxxheaders" != x && test "x$i" != "x$cxxheaders" && I get: ../../../../include/c++/4.8.0 ../../../../include/c++/4.8.0 ../../../../x86_64-pc-linux-gnu/include/c++/4.8.0 ../../../../x86_64-pc-linux-gnu/include/c++/4.8.0
Looks like this needs to be amended for gcc 4.8.
Did you use a non-standard gxx-include-dir?
(In reply to comment #8) > Did you use a non-standard gxx-include-dir? Yes: ~/gcc/configure --prefix=/usr --bindir=/usr/x86_64-pc-linux-gnu/gcc-bin/4.8.0 --includedir=/usr/lib/gcc/x86_64-pc-linux-gnu/4.8.0/include --datadir=/usr/share/gcc-data/x86_64-pc-linux-gnu/4.8.0 --mandir=/usr/share/gcc-data/x86_64-pc-linux-gnu/4.8.0/man --infodir=/usr/share/gcc-data/x86_64-pc-linux-gnu/4.8.0/info --with-gxx-include-dir=/usr/lib/gcc/x86_64-pc-linux-gnu/4.8.0/include/g++-v4 --host=x86_64-pc-linux-gnu --build=x86_64-pc-linux-gnu --disable-altivec --disable-fixed-point --without-ppl --without-cloog --enable-lto --enable-nls --without-included-gettext --with-system-zlib --disable-werror --enable-initfini-array --with-gold --enable-secureplt --disable-multilib --enable-libmudflap --disable-libssp --disable-libgomp --enable-cld --with-python-dir=/share/gcc-data/x86_64-pc-linux-gnu/4.8.0/python --enable-checking=release --disable-libgcj --enable-languages=c,c++ --enable-shared --enable-threads=posix --enable-__cxa_atexit --enable-clocale=gnu --with-build-config=bootstrap-lto --with-boot-ldflags="-Wl,-O1,--hash-style=gnu,--as-needed,--gc-sections" --enable-version-specific-runtime-libs --disable-libstdcxx-pch --enable-libstdcxx-time=yes
Removing glibc_2.15 keyword as backport suitability can't be judged until there is a fix on master. After this is fixed on master, anyone wanting a backport should feel free to attach a tested backport patch to this bug (or a new bug, if this one is closed as fixed).
Created attachment 6623 [details] Improved cxx header detection Octoploid, Can you test the attached patch?
(In reply to comment #11) > Created attachment 6623 [details] > Improved cxx header detection > > Octoploid, > > Can you test the attached patch? Thanks Allan, your patch is fine and solves the issue.
Fixed with commit: commit c4e85184d2ded3f6a259948098a0c297a9cf0be6 Author: Allan McRae <allan@archlinux.org> Date: Thu Sep 6 00:16:24 2012 +1000 Improve C++ header location detection (bug 13966)
The error is back again: tst-unique3lib.cc:1:18: fatal error: cstdio: No such file or directory #include <cstdio> ^ compilation terminated.
Looks like this fix was adjusted in commit 1e4a95361c71e8073f448012c3eeb6f09cc9a814. Can you confirm if it was that commit that caused the regression?
What is the value of c++-sysincludes in your config.make?
I cannot reproduce the failure anymore. It must have been a temporary local glitch. Sorry!
I am seeing this problem now with 4.9.0. I build and run on a Mips board, but as a cross compile, MIPS to MIPS, so I don't use the installed system headers. For what it is worth: % grep sysincludes config.make sysincludes = -nostdinc -isystem /home/jcarter/workarea/gcc/ifunc/mips_native/install-mips-mti-linux-gnu/lib/gcc/mips-mti-linux-gnu/4.9.0/include -isystem /home/jcarter/workarea/gcc/ifunc/mips_native/install-mips-mti-linux-gnu/lib/gcc/mips-mti-linux-gnu/4.9.0/include-fixed -isystem /home/jcarter/workarea/gcc/ifunc/mips_native/sysroot-mips-mti-linux-gnu/usr/include c++-sysincludes = Here is the familiar invocation: mips-mti-linux-gnu-g++ tst-unique3.cc -c -O2 -Wall -Winline -Wwrite-strings -fmerge-all-constants -frounding-math -g -I../include -I/home/jcarter/workarea/gcc/ifunc/mips_native/obj-mips-mti-linux-gnu/glibc/elf -I/home/jcarter/workarea/gcc/ifunc/mips_native/obj-mips-mti-linux-gnu/glibc -I../ports/sysdeps/unix/sysv/linux/mips/mips32/nptl -I../ports/sysdeps/unix/sysv/linux/mips/mips32 -I../ports/sysdeps/unix/sysv/linux/mips/nptl -I../ports/sysdeps/unix/sysv/linux/mips -I../nptl/sysdeps/unix/sysv/linux -I../nptl/sysdeps/pthread -I../sysdeps/pthread -I../ports/sysdeps/unix/sysv/linux -I../sysdeps/unix/sysv/linux -I../sysdeps/gnu -I../sysdeps/unix/inet -I../nptl/sysdeps/unix/sysv -I../ports/sysdeps/unix/sysv -I../sysdeps/unix/sysv -I../ports/sysdeps/unix/mips/mips32 -I../ports/sysdeps/unix/mips -I../nptl/sysdeps/unix -I../ports/sysdeps/unix -I../sysdeps/unix -I../sysdeps/posix -I../ports/sysdeps/mips/mips32/fpu -I../ports/sysdeps/mips/mips32 -I../ports/sysdeps/mips/ieee754 -I../ports/sysdeps/mips/soft-fp -I../ports/sysdeps/mips/include -I../ports/sysdeps/mips -I../sysdeps/ieee754/flt-32 -I../sysdeps/ieee754/dbl-64 -I../sysdeps/wordsize-32 -I../ports/sysdeps/mips/fpu -I../ports/sysdeps/mips/nptl -I../sysdeps/ieee754 -I../sysdeps/generic -I../nptl -I../ports -I.. -I../libio -I. -nostdinc -isystem /home/jcarter/workarea/gcc/ifunc/mips_native/install-mips-mti-linux-gnu/lib/gcc/mips-mti-linux-gnu/4.9.0/include -isystem /home/jcarter/workarea/gcc/ifunc/mips_native/install-mips-mti-linux-gnu/lib/gcc/mips-mti-linux-gnu/4.9.0/include-fixed -isystem /home/jcarter/workarea/gcc/ifunc/mips_native/sysroot-mips-mti-linux-gnu/usr/include -D_LIBC_REENTRANT -include ../include/libc-symbols.h -DNOT_IN_libc=1 -o /home/jcarter/workarea/gcc/ifunc/mips_native/obj-mips-mti-linux-gnu/glibc/elf/tst-unique3.o -MD -MP -MF /home/jcarter/workarea/gcc/ifunc/mips_native/obj-mips-mti-linux-gnu/glibc/elf/tst-unique3.o.dt -MT /home/jcarter/workarea/gcc/ifunc/mips_native/obj-mips-mti-linux-gnu/glibc/elf/tst-unique3.o tst-unique3.cc:3:18: fatal error: cstdio: No such file or directory #include <cstdio>
This bug is marked fixed. If you see this symptom, it must have a different cause, so please file a new bug (detailing glibc configure options, results of the relevant glibc configure tests, etc.).
I will package up information and post it to new bug and refer to this one for reference, Thanks ________________________________________ From: joseph at codesourcery dot com [sourceware-bugzilla@sourceware.org] Sent: Thursday, September 05, 2013 5:31 PM To: Jack Carter Subject: [Bug build/13966] Some elf tests fail with "fatal error: cstdio: No such file or directory" on trunk http://sourceware.org/bugzilla/show_bug.cgi?id=13966 --- Comment #19 from joseph at codesourcery dot com <joseph at codesourcery dot com> --- This bug is marked fixed. If you see this symptom, it must have a different cause, so please file a new bug (detailing glibc configure options, results of the relevant glibc configure tests, etc.). -- You are receiving this mail because: You are on the CC list for the bug.