From patchwork Tue Apr 30 18:45:39 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Helmut Grohne X-Patchwork-Id: 1929798 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=server2.sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=patchwork.ozlabs.org) Received: from server2.sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4VTTgL2ZKlz23jG for ; Wed, 1 May 2024 04:46:22 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 844703858428 for ; Tue, 30 Apr 2024 18:46:20 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from isilmar-4.linta.de (isilmar-4.linta.de [136.243.71.142]) by sourceware.org (Postfix) with ESMTPS id DFA0F3858D1E for ; Tue, 30 Apr 2024 18:45:57 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org DFA0F3858D1E Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=subdivi.de Authentication-Results: sourceware.org; spf=none smtp.mailfrom=subdivi.de ARC-Filter: OpenARC Filter v1.0.0 sourceware.org DFA0F3858D1E Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=136.243.71.142 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1714502760; cv=none; b=PXdIaiPSAthP00U+KIcZX9q4XmT7s3VV0xkJatcMc+9GItteMvSTkBhZmBnKT+8ekdaogqQK1NT4QFzR1bhCQyBKr8gjREaaquSZtQmRDM0lYeXSBi/H/JV/Hzv5SlZLSbWAYTjOlrT2JmQoPriN5icAEWF+6QZqfow7GmHpDBI= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1714502760; c=relaxed/simple; bh=vEMuSrs6MAcEkbnGsogJYdMiY1qnM0ch5nSOBksVQ9Q=; h=Date:From:To:Subject:Message-ID:MIME-Version; b=EbYvyedut6cgVuSzgMR+6Dljky5c9/DOmjXy77ViwALCrrUoV3bohukNCzoBvW3/knCoNfHjCH6I4SuhwgvpBXaPgF8MDVjQIM2Xii42KlooEjqo3Jz3PaiM6pVRBZHA/W0eQPQcGuduzkLUFgDGGuvVMcqohkLnJEqdfz4+g0o= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from isilmar-4.linta.de (isilmar.linta [10.0.0.1]) by isilmar-4.linta.de (Postfix) with ESMTP id B3C57200053 for ; Tue, 30 Apr 2024 18:45:54 +0000 (UTC) Date: Tue, 30 Apr 2024 20:45:39 +0200 From: Helmut Grohne To: gcc-patches@gcc.gnu.org Subject: [PATCH] defer test for limits.h existence to runtime [PR80677] Message-ID: <20240430184539.GA1403510@subdivi.de> MIME-Version: 1.0 Content-Disposition: inline X-Spam-Status: No, score=-13.3 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_STATUS, KAM_LAZY_DOMAIN_SECURITY, KAM_SHORT, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org 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 PR bootstrap/80677 * gcc/limitx.h: Only #include syslimits.h when another exists. * gcc/limity.h: Only #include limits.h when another 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 --- 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 and thus defines limits inconsistently with glibc. diff --git a/Makefile.in b/Makefile.in index db4fa6c6260..16785a98305 100644 --- a/Makefile.in +++ b/Makefile.in @@ -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) diff --git a/Makefile.tpl b/Makefile.tpl index 1d5813cd569..991d9738016 100644 --- a/Makefile.tpl +++ b/Makefile.tpl @@ -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) diff --git a/gcc/Makefile.in b/gcc/Makefile.in index a74761b7ab3..debcc5a6bb0 100644 --- a/gcc/Makefile.in +++ b/gcc/Makefile.in @@ -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 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 \ diff --git a/gcc/config/i386/t-cygming b/gcc/config/i386/t-cygming index af01f69acd1..50bf0c149e8 100644 --- a/gcc/config/i386/t-cygming +++ b/gcc/config/i386/t-cygming @@ -16,10 +16,6 @@ # along with GCC; see the file COPYING3. If not see # . -# 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) diff --git a/gcc/config/t-rtems b/gcc/config/t-rtems index baa00d83176..e69de29bb2d 100644 --- a/gcc/config/t-rtems +++ b/gcc/config/t-rtems @@ -1,2 +0,0 @@ -# RTEMS always has limits.h. -LIMITS_H_TEST = true diff --git a/gcc/config/t-vxworks b/gcc/config/t-vxworks index 6063943e346..a73759b29cc 100644 --- a/gcc/config/t-vxworks +++ b/gcc/config/t-vxworks @@ -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 diff --git a/gcc/config/vms/t-vms b/gcc/config/vms/t-vms index 251915ca017..08ac7352469 100644 --- a/gcc/config/vms/t-vms +++ b/gcc/config/vms/t-vms @@ -16,8 +16,6 @@ # along with GCC; see the file COPYING3. If not see # . -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 \ diff --git a/gcc/limitx.h b/gcc/limitx.h index e27597ef699..13b233b0090 100644 --- a/gcc/limitx.h +++ b/gcc/limitx.h @@ -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() /* Use "..." so that we find syslimits.h only in this same directory. */ #include "syslimits.h" #endif diff --git a/gcc/limity.h b/gcc/limity.h index 8bb398f6786..29998be8033 100644 --- a/gcc/limity.h +++ b/gcc/limity.h @@ -3,7 +3,7 @@ #else /* not _GCC_LIMITS_H_ */ -#ifdef _GCC_NEXT_LIMITS_H +#if defined(_GCC_NEXT_LIMITS_H) && __has_include_next() #include_next /* recurse down to the real one */ #endif