@@ -1069,8 +1069,7 @@ TARGET_FLAGS_TO_PASS = $(BASE_FLAGS_TO_PASS) $(EXTRA_TARGET_FLAGS)
EXTRA_GCC_FLAGS = \
"GCC_FOR_TARGET=$(GCC_FOR_TARGET) $$TFLAGS" \
"GM2_FOR_TARGET=$(GM2_FOR_TARGET) $$TFLAGS" \
- "`echo 'STMP_FIXPROTO=$(STMP_FIXPROTO)' | sed -e s'/[^=][^=]*=$$/XFOO=/'`" \
- "`echo 'LIMITS_H_TEST=$(LIMITS_H_TEST)' | sed -e s'/[^=][^=]*=$$/XFOO=/'`"
+ "`echo 'STMP_FIXPROTO=$(STMP_FIXPROTO)' | sed -e s'/[^=][^=]*=$$/XFOO=/'`"
GCC_FLAGS_TO_PASS = $(BASE_FLAGS_TO_PASS) $(EXTRA_HOST_FLAGS) $(EXTRA_GCC_FLAGS)
@@ -825,8 +825,7 @@ TARGET_FLAGS_TO_PASS = $(BASE_FLAGS_TO_PASS) $(EXTRA_TARGET_FLAGS)
EXTRA_GCC_FLAGS = \
"GCC_FOR_TARGET=$(GCC_FOR_TARGET) $$TFLAGS" \
"GM2_FOR_TARGET=$(GM2_FOR_TARGET) $$TFLAGS" \
- "`echo 'STMP_FIXPROTO=$(STMP_FIXPROTO)' | sed -e s'/[^=][^=]*=$$/XFOO=/'`" \
- "`echo 'LIMITS_H_TEST=$(LIMITS_H_TEST)' | sed -e s'/[^=][^=]*=$$/XFOO=/'`"
+ "`echo 'STMP_FIXPROTO=$(STMP_FIXPROTO)' | sed -e s'/[^=][^=]*=$$/XFOO=/'`"
GCC_FLAGS_TO_PASS = $(BASE_FLAGS_TO_PASS) $(EXTRA_HOST_FLAGS) $(EXTRA_GCC_FLAGS)
@@ -581,9 +581,6 @@ BUILD_SYSTEM_HEADER_DIR = `echo @BUILD_SYSTEM_HEADER_DIR@ | sed -e :a -e 's,[^/]
# Control whether to run fixincludes.
STMP_FIXINC = @STMP_FIXINC@
-# Test to see whether <limits.h> exists in the system header files.
-LIMITS_H_TEST = [ -f $(BUILD_SYSTEM_HEADER_DIR)/limits.h ]
-
# Directory for prefix to system directories, for
# each of $(system_prefix)/usr/include, $(system_prefix)/usr/lib, etc.
TARGET_SYSTEM_ROOT = @TARGET_SYSTEM_ROOT@
@@ -3327,11 +3324,7 @@ stmp-int-hdrs: $(STMP_FIXINC) $(T_GLIMITS_H) $(T_STDINT_GCC_H) $(USER_H) fixinc_
sysroot_headers_suffix=`echo $${ml} | sed -e 's/;.*$$//'`; \
multi_dir=`echo $${ml} | sed -e 's/^[^;]*;//'`; \
include_dir=include$${multi_dir}; \
- if $(LIMITS_H_TEST) ; then \
- cat $(srcdir)/limitx.h $(T_GLIMITS_H) $(srcdir)/limity.h > tmp-xlimits.h; \
- else \
- cat $(T_GLIMITS_H) > tmp-xlimits.h; \
- fi; \
+ cat $(srcdir)/limitx.h $(T_GLIMITS_H) $(srcdir)/limity.h > tmp-xlimits.h; \
$(mkinstalldirs) $${include_dir}; \
chmod a+rx $${include_dir} || true; \
$(SHELL) $(srcdir)/../move-if-change \
@@ -16,10 +16,6 @@
# along with GCC; see the file COPYING3. If not see
# <http://www.gnu.org/licenses/>.
-# cygwin and mingw always have a limits.h, but, depending upon how we are
-# doing the build, it may not be installed yet.
-LIMITS_H_TEST = true
-
winnt.o: $(srcdir)/config/i386/winnt.cc $(CONFIG_H) $(SYSTEM_H) coretypes.h \
$(TM_H) $(RTL_H) $(REGS_H) hard-reg-set.h output.h $(TREE_H) flags.h \
$(TM_P_H) $(HASH_TABLE_H) $(GGC_H) $(LTO_STREAMER_H)
@@ -1,2 +0,0 @@
-# RTEMS always has limits.h.
-LIMITS_H_TEST = true
@@ -40,12 +40,6 @@ vxworks-rust.o: $(srcdir)/config/vxworks-rust.cc
NATIVE_SYSTEM_HEADER_DIR =
-# Both the kernel and RTP headers provide limits.h. They embed VxWorks
-# specificities and are dated on some configurations so we both need to
-# provide our own version and make sure the system one gets exposed.
-
-LIMITS_H_TEST = true
-
# VxWorks system environments have been GCC based for a long time and
# we need to make sure that our files and the system ones use distinct
# macro names to protect against recursive inclusions. We achieve
@@ -16,8 +16,6 @@
# along with GCC; see the file COPYING3. If not see
# <http://www.gnu.org/licenses/>.
-LIMITS_H_TEST = false
-
vms-crtlmap.h: $(srcdir)/config/vms/vms-crtlmap.map \
$(srcdir)/config/vms/make-crtlmap.awk
$(AWK) -f $(srcdir)/config/vms/make-crtlmap.awk \
@@ -29,7 +29,7 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
#ifndef _GCC_LIMITS_H_ /* Terminated in limity.h. */
#define _GCC_LIMITS_H_
-#ifndef _LIBC_LIMITS_H_
+#if !defined(_LIBC_LIMITS_H_) && __has_include_next(<limits.h>)
/* Use "..." so that we find syslimits.h only in this same directory. */
#include "syslimits.h"
#endif
@@ -3,7 +3,7 @@
#else /* not _GCC_LIMITS_H_ */
-#ifdef _GCC_NEXT_LIMITS_H
+#if defined(_GCC_NEXT_LIMITS_H) && __has_include_next(<limits.h>)
#include_next <limits.h> /* recurse down to the real one */
#endif
The definition of LIMITS_H_TEST evaluates its existence in BUILD_SYSTEM_HEADER_DIR, but we'd actually need it to check a target version. Hence this check occasionally produces misdetections when build and target differ. In some cases such as cygming, the header is only installed after performing the build. Instead of resolving these situations by guessing, defer the test to the time of use and check for the header using __has_include_next which will use the correct include search path. 2024-04-30 Helmut Grohne <helmut@subdivi.de> PR bootstrap/80677 * gcc/limitx.h: Only #include syslimits.h when another <limits.h> exists. * gcc/limity.h: Only #include limits.h when another <limits.h> exists. * gcc/Makefile.in: Delete LIMITS_H_TEST default and always wrap limits.h with limitx.h and limity.h. * Makefile.tpl: Drop forwarding of LIMITS_H_TEST * Makefile.in: Regenerate. * gcc/config/i386/t-cygming: Delete unused LIMITS_H_TEST. * gcc/config/t-rtems: Likewise. * gcc/config/t-vxworks: Likewise. * gcc/config/vms/t-vms: Likewise. Signed-off-by: Helmut Grohne <helmut@subdivi.de> --- Makefile.in | 3 +-- Makefile.tpl | 3 +-- gcc/Makefile.in | 9 +-------- gcc/config/i386/t-cygming | 4 ---- gcc/config/t-rtems | 2 -- gcc/config/t-vxworks | 6 ------ gcc/config/vms/t-vms | 2 -- gcc/limitx.h | 2 +- gcc/limity.h | 2 +- 9 files changed, 5 insertions(+), 28 deletions(-) Please Cc me in replies. "make bootstrap" passes on today's gcc master. Bootstrapping Debian without this patch produces a broken toolchain that assumes absent <limits.h> and thus defines limits inconsistently with glibc.