From patchwork Mon Nov 21 23:31:47 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Merrill X-Patchwork-Id: 24047 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp1893218wrr; Mon, 21 Nov 2022 15:32:42 -0800 (PST) X-Google-Smtp-Source: AA0mqf6C8yNUokCBFxEwG82EYlVmRH+ukPmigC6GsqmhlZh0kZaFfiaKMOMaCon86SwpTDIb3bmG X-Received: by 2002:aa7:c98e:0:b0:469:39:1f30 with SMTP id c14-20020aa7c98e000000b0046900391f30mr10004611edt.238.1669073562799; Mon, 21 Nov 2022 15:32:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669073562; cv=none; d=google.com; s=arc-20160816; b=BoajhNcn23TTQO5WbLEBnEMvEEu9nJd4782CvbAz8uRs7tsSYyD0hMSZFPMXw2SZpo m3xAnfdACj3s8Qxn0rhUXc3pRx6AAj2gztoFKSjrgl5CXqL5yZXMDzeOBtGoRQsn/wwu oFWE68tUGPrOafIsxdNaQKyLgJAKtumpWPU3OoRDwSK9hQ715J8JPCd2+nayZoCrvbvm ylaVQFk2NZ7jepeNpPfuURdRbtbj4yDq3/wUewTf4YGwnU6IOF8fzrpF0fVpeXAUwRJf vzPwsP2f+onxrFxIJ+L3tModXkgrdqLVM2QyGHXyG+xI29tJenR6Pe21Y3H96VmIn37S vYZw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:from:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence :content-transfer-encoding:mime-version:message-id:date:subject:to :dmarc-filter:delivered-to:dkim-signature:dkim-filter; bh=CUSVcce2m/MCHU4PaG12hYXWHcHMLHGXM8Kl3L2NKb8=; b=BYRaX8hlRnyCqep9+dqTNJ6+ohHFENz4N82i/UYlq4InWxZWNoZ/Yu6m0yaXjqbkcg 3cfslpsBMjmB7yehN4ExNDn8DEslgMMn9Yn6eMsq4eQMO5IbEztA2ItM/Dp2bATt6Vv2 JZVA8Gz4f4KAUQcfIAmgTMOleB5TxR813cG8OnCpUr4c2O90z/D8h6sDwAfAifRzmKcu O1nPwBcV9GYqOG+uf2lx6tnyMCRkHiv46E4l+K9zME37Bljwo/x37Aer7zy0uB320nOo ErLme7jD+TjfqP1kU9QoZwrelyd9gUUwr715JHZzGrm7CExBRfSnB6VJGtuPk+/yUmp/ yTOA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=apAEMCcp; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from sourceware.org (server2.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id gb28-20020a170907961c00b007a7d37e467csi10565719ejc.763.2022.11.21.15.32.42 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Nov 2022 15:32:42 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=apAEMCcp; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 8F0D53858439 for ; Mon, 21 Nov 2022 23:32:41 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 8F0D53858439 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1669073561; bh=CUSVcce2m/MCHU4PaG12hYXWHcHMLHGXM8Kl3L2NKb8=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=apAEMCcpcWaUP67ScQ9q153mJojUJ0PcR2L6u75b7yES61BaLXfpRG7TqfuiD01CR 4cR3HmUXAxZtnuODA5hRAnFWfn/Oyr+gPmrFE1T1S/lAFxSeZ6/KLys5CjYmXRKtKJ LUWEkR7tGHRyRLADXV0YjL7zuhEXpc8wK91lJBv8= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org 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 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-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) 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 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 X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Jason Merrill via Gcc-patches From: Jason Merrill Reply-To: Jason Merrill Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1750150480385157770?= X-GMAIL-MSGID: =?utf-8?q?1750150480385157770?= 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(-) base-commit: 5c0d171f67d082c353ddc319859111d3b9126c17 prerequisite-patch-id: 275d90e1bd8b940c1cca2840bc38dc4fafa0797b 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"