From patchwork Wed Dec 6 10:04:07 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 174441 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:bcd1:0:b0:403:3b70:6f57 with SMTP id r17csp4001921vqy; Wed, 6 Dec 2023 02:04:54 -0800 (PST) X-Google-Smtp-Source: AGHT+IHOATOV2N+WGmflc0oqY/UVf9c1cVzhcTWY8xiVrh6u/2hhXwmspO7BPuSWDv/UDeTWkKFa X-Received: by 2002:a05:6102:a4c:b0:464:a25f:442c with SMTP id i12-20020a0561020a4c00b00464a25f442cmr548763vss.51.1701857094512; Wed, 06 Dec 2023 02:04:54 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1701857094; cv=pass; d=google.com; s=arc-20160816; b=rQ4hcfujVcwYVQRl9Ee1lBj73PnVcazOgHtwrCQwMXfJhsNPFzK2duaNfFqNXM3gO5 pRCp7Vo/vIi8eWPdpIJ7lNs7nK8Gn51YZNA4ud+pEmgjeCa/wP3PVUhltCeQNJ1qChpu 00qXIZMJo8EDWXAXjRz1XRT0+rpDdrEnfrkIiufnoeoncoBweCi+pqpfUTPmrNFVdeYX pTwffytGWJb4oCGelEnKr8M0eaFo9IzvGmzP6gcDaPayw5ffW6ndnZ2WbzalbQ0vGp4N 7dweeDuCQX0tEbPozZj+Jy/LWXtdc5XapGAcFzBCy5FLLZt2ifEpK1rsiafQFO0wPT0W eLgw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:reply-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :content-disposition:mime-version:message-id:subject:cc:to:from:date :dkim-signature:arc-filter:dmarc-filter:delivered-to; bh=cC2DroFZbxqkSud7wIX3TxZxZAHI7lJlU8G98+5iI84=; fh=FCjeRajqaQYHMkQtfIia8KT5yBac53mYOLLyJhYG/AY=; b=YbaEtMAElK6MnCXh7k5tRmoK7siJbt6YXqXwnWNl/LWjd9d41BeWgjcue+bT+Q62CD bPQsIzY3m3E52p3GysuDs78iS5HlFSjKLklx7xjq3TBtscWX1IOaV1GHxp/F1SzZXkX0 c/kxE6Si5+w5R6EvVuSOT6DipPVyUjKhbna/DOoiuuXglwUgB3tSIlMFggGWqSfZKUNt SQ+O4t4mMFDf9uBBI60fVJOwmyntBE0LqyI/HuwFELBZjfXxV+cvI0A1nmmLxfHaEaGS HkggyPnYl1Jh0Bl6uV3oGtqcsAl05ML0MpMqRPuobDdDIwOdGlPUWIOv/TrYnAKVUZ9c +qkQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=eFamxPJW; arc=pass (i=1); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from server2.sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id g6-20020ad45146000000b0066d20896c5csi9342176qvq.409.2023.12.06.02.04.54 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Dec 2023 02:04:54 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=eFamxPJW; arc=pass (i=1); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 4B118385828D for ; Wed, 6 Dec 2023 10:04:54 +0000 (GMT) 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.129.124]) by sourceware.org (Postfix) with ESMTPS id E31D43858D3C for ; Wed, 6 Dec 2023 10:04:13 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org E31D43858D3C Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org E31D43858D3C Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1701857060; cv=none; b=cF2HDsmS5HpGgKPO6tjW274LQiVt5ux9xi7Si3sjXTZCc57BhuizzFGuE1kR0CnwHywd7OjdpsNn8E/wDiIk+4UqAj3y4cpMHwzOT5I8z/t3TceOyCFht3qMALOVHy/UdHV8/zXmFdK7LTcjotG58c/Ahy7XAFat6HN5zamfK8A= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1701857060; c=relaxed/simple; bh=MlkIrAE02TE04N6BYK/VojbHL2B+Vk5Z01Vj5E4FDAc=; h=DKIM-Signature:Date:From:To:Subject:Message-ID:MIME-Version; b=WPaIytiynuuVXSIW02pea+G70mrWky89IP8S9BLRWIxOyxItpoyTLo8hdEGuC72hjxRrT/0MlBW30m3FZC6ml5eooSNUB4RgWN4ZQy9RqrxbDPJM45mfohzsJlI6f5qsYni726D5d+rb9nLQ7nV0yzaqPQO9XB4Fv76MJu5KUQU= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1701857053; h=from:from:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=cC2DroFZbxqkSud7wIX3TxZxZAHI7lJlU8G98+5iI84=; b=eFamxPJWIYlsnoG0Yu1MnlHPTiCF5W76Qj2gIqT/SlF/IUkDH7oaLSqvZCitR5CiKz99Bw iC1x1CNwsbODUja2tT/tSEHW9znNr53/wH2eO0FgyAJoNYlFI1JKNpO+tUulm4fnc19Ir2 0L58LUuXWkTatUNSO89UtHnrJWcZt8Q= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-377-8P9KyQR2OK-bdfTTslw_1Q-1; Wed, 06 Dec 2023 05:04:12 -0500 X-MC-Unique: 8P9KyQR2OK-bdfTTslw_1Q-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id CF341833A06; Wed, 6 Dec 2023 10:04:11 +0000 (UTC) Received: from tucnak.zalov.cz (unknown [10.39.195.157]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 92BD11C060AF; Wed, 6 Dec 2023 10:04:11 +0000 (UTC) Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.17.1/8.17.1) with ESMTPS id 3B6A48KB1603208 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Wed, 6 Dec 2023 11:04:09 +0100 Received: (from jakub@localhost) by tucnak.zalov.cz (8.17.1/8.17.1/Submit) id 3B6A48VN1603207; Wed, 6 Dec 2023 11:04:08 +0100 Date: Wed, 6 Dec 2023 11:04:07 +0100 From: Jakub Jelinek To: Richard Biener Cc: gcc-patches@gcc.gnu.org Subject: [PATCH] libgcc: Avoid -Wbuiltin-declaration-mismatch warnings in emutls.c Message-ID: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.7 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline X-Spam-Status: No, score=-3.4 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE 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: , Reply-To: Jakub Jelinek Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1784526504411306227 X-GMAIL-MSGID: 1784526504411306227 Hi! When libgcc is being built in --disable-tls configuration or on a target without native TLS support, one gets annoying warnings: ../../../../libgcc/emutls.c:61:7: warning: conflicting types for built-in function ‘__emutls_get_address’; expected ‘void *(void *)’ [-Wbuiltin-declaration-mismatch] 61 | void *__emutls_get_address (struct __emutls_object *); | ^~~~~~~~~~~~~~~~~~~~ ../../../../libgcc/emutls.c:63:6: warning: conflicting types for built-in function ‘__emutls_register_common’; expected ‘void(void *, unsigned int, unsigned int, void *)’ [-Wbuiltin-declaration-mismatch] 63 | void __emutls_register_common (struct __emutls_object *, word, word, void *); | ^~~~~~~~~~~~~~~~~~~~~~~~ ../../../../libgcc/emutls.c:140:1: warning: conflicting types for built-in function ‘__emutls_get_address’; expected ‘void *(void *)’ [-Wbuiltin-declaration-mismatch] 140 | __emutls_get_address (struct __emutls_object *obj) | ^~~~~~~~~~~~~~~~~~~~ ../../../../libgcc/emutls.c:204:1: warning: conflicting types for built-in function ‘__emutls_register_common’; expected ‘void(void *, unsigned int, unsigned int, void *)’ [-Wbuiltin-declaration-mismatch] 204 | __emutls_register_common (struct __emutls_object *obj, | ^~~~~~~~~~~~~~~~~~~~~~~~ The thing is that in that case __emutls_get_address and __emutls_register_common are builtins, and are declared with void * arguments rather than struct __emutls_object *. Now, struct __emutls_object is a type private to libgcc/emutls.c and the middle-end creates on demand when calling the builtins a similar structure (with small differences, like not having the union in there). We have a precedent for this e.g. for fprintf or strftime builtins where the builtins are created with magic fileptr_type_node or const_tm_ptr_type_node types and then match it with user definition of pointers to some structure, but I think for this case users should never define these functions themselves nor call them and having special types for them in the compiler would mean extra compile time spent during compiler initialization and more GC data, so I think it is better to keep the compiler as is. On the library side, there is an option to just follow what the compiler is doing and do EMUTLS_ATTR void -__emutls_register_common (struct __emutls_object *obj, +__emutls_register_common (void *xobj, word size, word align, void *templ) { + struct __emutls_object *obj = (struct __emutls_object *) xobj; but that will make e.g. libabigail complain about ABI change in libgcc. So, the patch just turns the warning off. Tested on x86_64-linux with --disable-tls, ok for trunk? 2023-12-06 Thomas Schwinge Jakub Jelinek PR libgcc/109289 * emutls.c: Add GCC diagnostic ignored "-Wbuiltin-declaration-mismatch" pragma. Jakub --- libgcc/emutls.c.jj 2023-01-16 11:52:16.780723793 +0100 +++ libgcc/emutls.c 2023-12-06 10:49:46.438060090 +0100 @@ -57,6 +57,14 @@ struct __emutls_array # define EMUTLS_ATTR #endif +/* __emutls_get_address and __emutls_register_common are registered as + builtins, but the compiler struct __emutls_object doesn't have + a union in there and is only created when actually needed for + the calls to the builtins, so the builtins are created with void * + arguments rather than struct __emutls_object *. Avoid + -Wbuiltin-declaration-mismatch warnings. */ +#pragma GCC diagnostic ignored "-Wbuiltin-declaration-mismatch" + EMUTLS_ATTR void *__emutls_get_address (struct __emutls_object *); EMUTLS_ATTR