Bug 8766

Summary: Compiling host-gcc-final-4.9.3 broken on i386
Product: buildroot Reporter: Bernd Kuhls <bernd>
Component: OtherAssignee: unassigned
Status: RESOLVED FIXED    
Severity: normal CC: buildroot
Priority: P5    
Version: unspecified   
Target Milestone: ---   
Hardware: All   
OS: Linux   
Host: Target:
Build:

Description Bernd Kuhls 2016-03-06 11:08:51 UTC
When compiling buildroot git master (c6e3511) with this defconfig

BR2_x86_i386=y

this error occurs:

/home/bernd/buildroot/br4_i386/output/build/host-gcc-final-4.9.3/build/./gcc/xgcc -B/home/bernd/buildroot/br4_i386/output/build/host-gcc-final-4.9.3/build/./gcc/ -B/home/bernd/buildroot/br4_i386/output/host/usr/i386-buildroot-linux-uclibc/bin/ -B/home/bernd/buildroot/br4_i386/output/host/usr/i386-buildroot-linux-uclibc/lib/ -isystem /home/bernd/buildroot/br4_i386/output/host/usr/i386-buildroot-linux-uclibc/include -isystem /home/bernd/buildroot/br4_i386/output/host/usr/i386-buildroot-linux-uclibc/sys-include    -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -Os -O2  -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64  -Os  -DIN_GCC  -DCROSS_DIRECTORY_STRUCTURE  -W -Wall -Wno-narrowing -Wwrite-strings -Wcast-qual -Wstrict-prototypes -Wmissing-prototypes -Wold-style-definition  -isystem ./include   -fpic -mlong-double-80 -g -DIN_LIBGCC2 -fbuilding-libgcc -fno-stack-protector   -fpic -mlong-double-80 -I. -I. -I../.././gcc -I../../../libgcc -I../../../libgcc/. -I../../../libgcc/../gcc -I../../../libgcc/../include    -DUSE_TLS -o _gcov_ior_profiler.o -MT _gcov_ior_profiler.o -MD -MP -MF _gcov_ior_profiler.dep -DL_gcov_ior_profiler -c ../../../libgcc/libgcov-profiler.c
../../../libgcc/generic-morestack-thread.c:41:21: fatal error: pthread.h: No such file or directory
 #include <pthread.h>
                     ^
compilation terminated.
../../../libgcc/shared-object.mk:14: recipe for target 'generic-morestack-thread.o' failed
make[3]: *** [generic-morestack-thread.o] Error 1
make[3]: *** Waiting for unfinished jobs....
make[3]: Leaving directory '/home/bernd/buildroot/br4_i386/output/build/host-gcc-final-4.9.3/build/i386-buildroot-linux-uclibc/libgcc'
Makefile:10153: recipe for target 'all-target-libgcc' failed
make[2]: *** [all-target-libgcc] Error 2
make[2]: Leaving directory '/home/bernd/buildroot/br4_i386/output/build/host-gcc-final-4.9.3/build'
Makefile:840: recipe for target 'all' failed
make[1]: *** [all] Error 2
make[1]: Leaving directory '/home/bernd/buildroot/br4_i386/output/build/host-gcc-final-4.9.3/build'
package/pkg-generic.mk:195: recipe for target '/home/bernd/buildroot/br4_i386/output/build/host-gcc-final-4.9.3/.stamp_built' failed
make: *** [/home/bernd/buildroot/br4_i386/output/build/host-gcc-final-4.9.3/.stamp_built] Error 2
Comment 1 Thomas Petazzoni 2016-03-06 12:51:15 UTC
Thanks Bernd for the report. This is an issue you already reported in the past, I found your previous report and some related discussion at https://patchwork.ozlabs.org/patch/484002/.

Basically, as I understand it, the problem is that uClibc-ng only offers the NPTL thread implementation for x86. But since i386 does not have the necessary instructions to implement NPTL, we only offer the "none" thread implementation, which explains why <pthread.h> is missing.

So I think there are really two questions here:

 1/ Is it correct that uClibc-ng provides no thread implementation at all for i386. This is something to discuss with Waldemar.

 2/ Are we also seeing this <pthread.h> missing problem when building with no threads on i486+. If we also have this problem, then I don't see how the "none" thread implementation can still be useful.
Comment 2 Thomas Petazzoni 2016-03-06 12:55:58 UTC
(In reply to Thomas Petazzoni from comment #1)
>  2/ Are we also seeing this <pthread.h> missing problem when building with no
> threads on i486+. If we also have this problem, then I don't see how the "none" 
> thread implementation can still be useful.

I just tested, it also fails with the same error on i486 with thread support disabled. I.E this defconfig:

BR2_x86_i486=y
BR2_PTHREADS_NONE=y

fails to build with:

../../../libgcc/generic-morestack-thread.c:41:21: fatal error: pthread.h: No such file or directory
 #include <pthread.h>
                     ^
compilation terminated.
make[4]: *** [generic-morestack-thread.o] Error 1
make[4]: *** Waiting for unfinished jobs....
make[3]: *** [all-target-libgcc] Error 2
make[2]: *** [all] Error 2
make[1]: *** [/home/test/outputs/i486-nothread/build/host-gcc-final-4.9.3/.stamp_built] Error 2
make: *** [_all] Error 2
Comment 3 Thomas Petazzoni 2016-03-06 13:27:31 UTC
After some research, it seems to be an x86 specific issue. The file causing problems is libgcc/generic-morestack-thread.c, which gets included in the build by libgcc/config/t-stack. It is related to the implementation of -fsplit-stack, which is only supported on x86 32/64.

So on other architectures, a no thread configuration should still build fine. However, seeing that on a major arch like x86 the nothread support has been broken for a while (-fsplit-stack has been around since gcc 4.6) really makes me wonder if we should continue to support the no thread solution.
Comment 4 Peter Korsgaard 2016-03-08 21:07:55 UTC
(In reply to Thomas Petazzoni from comment #3)

I also doubt the no-thread option gets used very much. Perhaps the way forward is to deprecate it and then make threads always available, similar to how we did for largefile/IPv6?

If i386 support blocks this, then I suggest we drop the i386 variant.
Comment 5 Thomas Petazzoni 2016-04-19 21:26:58 UTC
i386 support has been deprecated as of https://git.buildroot.net/buildroot/commit/?id=6cb4814c87cb1282b4a1d35e73743e8dd1b12ec5.

x86 non-threaded configuration has been fixed as of https://git.buildroot.net/buildroot/commit/?id=2631219f648f4aa13fa36d06a483e4507cb6f3d7.