On Tue, 2023-11-21 at 08:00 +0800, Xi Ruoyao wrote: /* snip */ > > This has broken libgcc builds when target libc isn't yet available. > > > > In file included from /scratch/jmyers/glibc-bot/src/gcc/libgcc/../gcc/config/loongarch/loongarch-def.h:49, > >                  from /scratch/jmyers/glibc-bot/src/gcc/libgcc/../gcc/config/loongarch/loongarch-opts.h:24, > >                  from ../.././gcc/options.h:8, > >                  from ../.././gcc/tm.h:49, > >                  from /scratch/jmyers/glibc-bot/src/gcc/libgcc/libgcc2.c:29: > > /scratch/jmyers/glibc-bot/build/compilers/loongarch64-linux-gnu-lp64d/gcc-first/gcc/include/stdint.h:9:16: fatal error: stdint.h: No such file or directory > >     9 | # include_next > >       |                ^~~~~~~~~~ > > compilation terminated. > > make[3]: *** [Makefile:505: _muldi3.o] Error 1 > > > > https://sourceware.org/pipermail/libc-testresults/2023q4/012109.html > > > > My guess would be that the definitions needing are not actually > > needed in code built for the target, and so there should be more > > > > #if !defined(IN_LIBGCC2) && !defined(IN_TARGET_LIBS) && !defined(IN_RTS) > > > > conditions like the one already present in loongarch-opts.h, to avoid > > depending on a target header like this being present. > > Ah, makes sense.  I thought stdint.h was usable without libc but it's > not true. > > The only use for stdint.h is in struct loongarch_isa (using int64_t for > a 64-bit bitset).  This struct is not used by target code. > > I'll test building a cross compiler from x86_64 with stdint.h and struct > loongarch_isa guarded with the ifdef. Pushed the attached patch r14-5634. Tested building a cross compiler from x86_64 with cross Binutils but not target libc. Also tested bootstrapping on loongarch64-linux-gnu. -- Xi Ruoyao School of Aerospace Science and Technology, Xidian University