From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id 656A03858439 for ; Mon, 21 Nov 2022 23:31:52 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 656A03858439 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1669073512; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=CUSVcce2m/MCHU4PaG12hYXWHcHMLHGXM8Kl3L2NKb8=; b=bhrW4ZyEbOfMwkjS8wYvrrHlnPPWYI/7XCwnHvkn/KWxU/udDrxcNp4v6i2MyptOhFywSp vLRRd/WK6yUE6DytvfVj9Z3botNnOkY8CSDzb8BC2rMn22RUNt+blnXNwBggNmFHM+drbU K5E7y6rULXD2WD5dkbQ4KdvhI2B8Ftw= Received: from mail-qv1-f72.google.com (mail-qv1-f72.google.com [209.85.219.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-558-Nvii5BxBO7mFqoDGI80eBg-1; Mon, 21 Nov 2022 18:31:51 -0500 X-MC-Unique: Nvii5BxBO7mFqoDGI80eBg-1 Received: by mail-qv1-f72.google.com with SMTP id h15-20020a0cf8cf000000b004c6aea90e75so3225295qvo.8 for ; Mon, 21 Nov 2022 15:31:50 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=CUSVcce2m/MCHU4PaG12hYXWHcHMLHGXM8Kl3L2NKb8=; b=3E4ZPw/chfnPBP477eWdMNVwHXjcTNI27km2zY4MY979gchp7pSxoLPLZtbjYqsHlF uk+8wzp1Rs5SjQg4lBmIa1soQnN59uW8XqSnPPauo4XOCjX/OEtpaIUq8gFiliIZUkrR hsAarDecaM9rl/30QjnVs7MZfQ/4XENBNYY+ae1g+l21thyQu1Ln1L3UwJZY8K6o1v8o ccThqnCOIE8reaTngxXJgyWiNsCiBWk2yjFL1jZtJB9kBRv80kV51ld9EaTJuj+Pu1/U 6mEmAlBCtcOzqeCwoTLws2fFXYC2JmtiteU/fphjVCUDvRbJjp4Omiu/lkJKJzw3OF+x 9lYg== X-Gm-Message-State: ANoB5pkdLidzDMUu2fAfCk/jO4Ek8gaYLwoR9IyTJr3gFrClRrzKtsBc LE8TlNULyEzrui2NUFpITcxUdWNOpyuq+D/h2iskJ5zl+vqy5OoT5TLubjvSMRyiJdRhlFDTuwP 2hONGnIGe81641t/6OeCShTF6HE43kKn7OrKojf+DU1JMgnDuZ/qTK7ewKipLExIotA== X-Received: by 2002:a05:6214:448b:b0:4bb:6419:ecfb with SMTP id on11-20020a056214448b00b004bb6419ecfbmr1726723qvb.109.1669073510317; Mon, 21 Nov 2022 15:31:50 -0800 (PST) X-Google-Smtp-Source: AA0mqf4MfvMDm8q6y39//vG6ax7c81L7UCkdsoVNi9gtlbMHwo5ScA0yonwevPKQ5B4tzVOUwnRGbg== X-Received: by 2002:a05:6214:448b:b0:4bb:6419:ecfb with SMTP id on11-20020a056214448b00b004bb6419ecfbmr1726697qvb.109.1669073509853; Mon, 21 Nov 2022 15:31:49 -0800 (PST) Received: from jason.com (130-44-159-43.s15913.c3-0.arl-cbr1.sbo-arl.ma.cable.rcncustomer.com. [130.44.159.43]) by smtp.gmail.com with ESMTPSA id k18-20020a05620a415200b006e54251993esm9221890qko.97.2022.11.21.15.31.49 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Nov 2022 15:31:49 -0800 (PST) From: Jason Merrill To: gcc-patches@gcc.gnu.org Subject: [PATCH RFA(configure)] c++: provide strchrnul on targets without it [PR107781] Date: Mon, 21 Nov 2022 18:31:47 -0500 Message-Id: <20221121233147.523576-1-jason@redhat.com> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="US-ASCII"; x-default=true X-Spam-Status: No, score=-12.5 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,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 List-Id: Tested x86_64-pc-linux-gnu, and also manually changing the HAVE_DECL_STRCHRNUL flag. OK for trunk? -- 8< -- The Contracts implementation uses strchrnul, which is a glibc extension, so bootstrap broke on non-glibc targets. I considered unconditionally using a local definition, but I guess we might as well use the libc version if it exists. PR c++/107781 gcc/cp/ChangeLog: * contracts.cc (strchrnul): Define if needed. gcc/ChangeLog: * configure.ac: Check for strchrnul. * config.in, configure: Regenerate. --- gcc/cp/contracts.cc | 12 ++++++++++++ gcc/config.in | 7 +++++++ gcc/configure.ac | 2 +- 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/gcc/cp/contracts.cc b/gcc/cp/contracts.cc index 26396439361..8b11f26ca27 100644 --- a/gcc/cp/contracts.cc +++ b/gcc/cp/contracts.cc @@ -204,6 +204,18 @@ lookup_concrete_semantic (const char *name) return CCS_INVALID; } +#if !HAVE_DECL_STRCHRNUL +/* strchrnul is a glibc extension. */ + +static const char * +strchrnul (const char *s, char c) +{ + if (auto p = strchr (s, c)) + return p; + return strchr (s, '\0'); +} +#endif + /* Compare role and name up to either the NUL terminator or the first occurrence of colon. */ diff --git a/gcc/config.in b/gcc/config.in index 38ef792bd67..4a5dfb4151c 100644 --- a/gcc/config.in +++ b/gcc/config.in @@ -1126,6 +1126,13 @@ #endif +/* Define to 1 if we found a declaration for 'strchrnul', otherwise define to 0. + */ +#ifndef USED_FOR_TARGET +#undef HAVE_DECL_STRCHRNUL +#endif + + /* Define to 1 if we found a declaration for 'strnlen', otherwise define to 0. */ #ifndef USED_FOR_TARGET diff --git a/gcc/configure.ac b/gcc/configure.ac index 7c55bff6cb0..1124ecfa218 100644 --- a/gcc/configure.ac +++ b/gcc/configure.ac @@ -1581,7 +1581,7 @@ CXXFLAGS="$CXXFLAGS -I${srcdir} -I${srcdir}/../include $GMPINC" # normal autoconf function for these. But force definition of # HAVE_DECL_BASENAME like gcc_AC_CHECK_DECLS does, to suppress the bizarre # basename handling in libiberty.h. -AC_CHECK_DECLS([basename(const char*), strstr(const char*,const char*)], , ,[ +AC_CHECK_DECLS([basename(const char*), strchrnul(const char*, int), strstr(const char*,const char*)], , ,[ #undef HAVE_DECL_BASENAME #define HAVE_DECL_BASENAME 1 #include "ansidecl.h" base-commit: 5c0d171f67d082c353ddc319859111d3b9126c17 prerequisite-patch-id: 275d90e1bd8b940c1cca2840bc38dc4fafa0797b -- 2.31.1