On Mon, 2023-11-20 at 23:15 +0000, Joseph Myers wrote: > On Sat, 18 Nov 2023, Xi Ruoyao wrote: > > > diff --git a/gcc/config/loongarch/loongarch-def.h > > b/gcc/config/loongarch/loongarch-def.h > > index b319cded456..6123c8e0f19 100644 > > --- a/gcc/config/loongarch/loongarch-def.h > > +++ b/gcc/config/loongarch/loongarch-def.h > > @@ -46,6 +46,7 @@ along with GCC; see the file COPYING3. If not see > > #ifndef LOONGARCH_DEF_H > > #define LOONGARCH_DEF_H > > > > +#include <stdint.h> > > #include "loongarch-tune.h" > > > > #ifdef __cplusplus > > 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 <stdint.h> > | ^~~~~~~~~~ > 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 <stdint.h> 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. -- Xi Ruoyao <xry...@xry111.site> School of Aerospace Science and Technology, Xidian University