https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80677
--- Comment #10 from Helmut Grohne <helmut at subdivi dot de> --- Sam James, please give the patch at https://gcc.gnu.org/pipermail/gcc-patches/2024-April/650271.html a try. It entirely removes LIMITS_H_TEST and defers the check to runtime. To verify the patch, it is not sufficient to merely build gcc, but also attempt to compile something that #includes <limits.h> and observe whether it picks up the right header. The main idea behind the patch is that the resulting compiler will have correct search paths and that deferring the lookup to those paths will work more reliably. Regarding the need for a proper sysroot, I contend that what is mainly broken here is the case of absence of a sysroot. It just happens that few people outside the Debian ecosystem build cross toolchains without a sysroot.