From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-ot1-x32e.google.com (mail-ot1-x32e.google.com [IPv6:2607:f8b0:4864:20::32e]) by sourceware.org (Postfix) with ESMTPS id 6F84B3858D20 for ; Thu, 3 Mar 2022 19:25:37 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 6F84B3858D20 Received: by mail-ot1-x32e.google.com with SMTP id g6-20020a9d6486000000b005acf9a0b644so5449019otl.12 for ; Thu, 03 Mar 2022 11:25:37 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:from:to:cc:references:in-reply-to :content-transfer-encoding; bh=URmYfc5RPDVHkozbxfJamOnntO6od07WRU+ftInOivs=; b=rqoUnO0lFDmswlZl+66pfPNkwhsZUHZmkJNxTHJb5Ns0Wb+3uThkCgjuHFOZB2/1gR TP7FdmABiTTEiWOh0dJ8WD/titE4ntimlBmXfWBlp8R1sF61e+woasWuZZKpd39vYXCz ZpH6Tr46ePrPZA3lBlh+cIf1cYUeHcdqZdUXe5wFuXt183qYdku1vYVhibPBZyf8kLb7 tI99Rb2b0l8UfwsWS8Bn/XGDp0m+gH8/NggEISgNRIGpiSuQI5ljRood9OZydb0sSwrg 2X47QmF0BwDleSa5f75k85fbWU9eVqe6xfRtOKW80xtXWhl5NXZYkJolKMh3dpcyHPj6 V9fQ== X-Gm-Message-State: AOAM532KEHF0+CG2CqQDhd765fMGiuIUJ7AOwEai47K1K7C876CWM8Ln 4yY7+Gqt0UE205NypCqqeN/xcjBcGYXgkw== X-Google-Smtp-Source: ABdhPJxFSR4LLUiuKz/QD8ruCVFjW8IS+FqiZf9VoeqH31KIwwZUpkQn5qF5Dl1EOoPw32AnDjT/rg== X-Received: by 2002:a05:6830:1e8a:b0:5ad:1ed4:d2b6 with SMTP id n10-20020a0568301e8a00b005ad1ed4d2b6mr19722945otr.56.1646335536679; Thu, 03 Mar 2022 11:25:36 -0800 (PST) Received: from ?IPV6:2804:431:c7ca:2dcb:bbe7:c0fe:2b74:5aaa? ([2804:431:c7ca:2dcb:bbe7:c0fe:2b74:5aaa]) by smtp.gmail.com with ESMTPSA id c1-20020a056808138100b002d4b30ab04esm1643658oiw.32.2022.03.03.11.25.34 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 03 Mar 2022 11:25:35 -0800 (PST) Message-ID: <95fece0c-8a1c-ce5c-f378-3cda419308ea@linaro.org> Date: Thu, 3 Mar 2022 16:25:33 -0300 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.6.1 Subject: Re: [PATCH] stdio: Move include of bits/stdio-ldbl.h before bits/stdio.h Content-Language: en-US From: Adhemerval Zanella To: John Paul Adrian Glaubitz Cc: libc-alpha@sourceware.org References: <20210322111530.3215018-1-glaubitz@physik.fu-berlin.de> <9dedf9b9-5af3-3f3b-e749-2c8e50ec5dc4@linaro.org> <4439e314-dd0d-fb57-0a68-83c3e6f36c20@physik.fu-berlin.de> <00f81cc7-ae24-f055-9bd5-42169c6c3a61@linaro.org> In-Reply-To: <00f81cc7-ae24-f055-9bd5-42169c6c3a61@linaro.org> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-5.3 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, NICE_REPLY_A, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 03 Mar 2022 19:25:39 -0000 On 24/02/2022 14:10, Adhemerval Zanella wrote: > > > On 23/02/2022 17:51, John Paul Adrian Glaubitz wrote: >> Hi Adhemerval! >> >> On 3/23/21 18:59, Adhemerval Zanella wrote: >>> I am not sure if this is the correct approach, I am seeing it building for powerpc64le with gcc version 10.2.1 20210126: >>> >>> | powerpc64le-glibc-linux-gnu-gcc nscd.c -c [...] >>> | In file included from ../include/sys/cdefs.h:3, >>> | from ../include/features.h:484, >>> | from ../sysdeps/powerpc/bits/floatn.h:22, >>> | from ../include/stdio.h:7, >>> | from ../argp/argp.h:23, >>> | from ../include/argp.h:2, >>> | from nscd.c:20: >>> | ../misc/sys/cdefs.h:503:20: error: ‘__dprintf_chk’ undeclared here (not in a function); did you mean ‘__sprintf_chk’? >>> | 503 | extern __typeof (__##name) __##name \ >>> | ^~ >>> | ../libio/bits/stdio-ldbl.h:98:1: note: in expansion of macro ‘__LDBL_REDIR2_DECL’ >>> | 98 | __LDBL_REDIR2_DECL (dprintf_chk) >>> | | ^~~~~~~~~~~~~~~~~~ >>> | [...] >>> >>> The postprocessor output shows: >>> >>> | [...] >>> | 2820 extern __typeof (__dprintf_chk) __dprintf_chk __asm ("" "__" "dprintf_chk" "ieee128"); >>> | [...] >>> | 3067 extern int __dprintf_chk (int __fd, int __flag, const char *__restrict __fmt, >>> | 3068 ...) __attribute__ ((__format__ (__printf__, 3, 4))); >>> >>> Meaning we are not using __typeof *before* the function prototype >>> is define. >>> >>> I think to proper handle this LLVM limitation we will need to fully >>> rework how __LDBL_REDIR2_DECL does the redirect by something similar >>> to what __REDIRECT does by defining something like: >>> >>> | #if __LDOUBLE_REDIRECTS_TO_FLOAT128_ABI == 1 >>> | # ifdef __REDIRECT >>> | >>> | /* Alias name defined automatically. */ >>> | # define __LDBL_REDIR(name, proto) \ >>> | extern name proto __asm__ (__ASMNAME ("__" #name "ieee128")); >>> | >>> | /* Alias name defined automatically, with leading underscores. */ >>> | # define __LDBL_REDIR2_DECL(name) \ >>> | extern __##name proto __asm__ (__ASMNAME ("__" #name "ieee128")); >>> >>> | >>> | /* Alias name defined manually. */ >>> | # define __LDBL_REDIR1(name, proto, alias) \ >>> | extern name proto __asm__ (__ASMNAME (alias)); >>> >>> And replace __LDBL_REDIR_DECL with __LDBL_REDIR and __LDBL_REDIR1_DECL >>> with __LDBL_REDIR1 (while adding the require argument prototype). It >>> will allow to move the stdio-ldbl.h definitions to stdio and remove the >>> header. >> >> I don't fully understand how to implement this but I would like to fix this because >> this the main remaining issue with glibc that keeps LLVM from successfully building >> on sparc64. >> >> Could you maybe help me come up with a patch to fix this issue? > > The idea is to refactor the way we define both the external alias and the > internal ones to remove the libc_hidden_ldbl_proto, __LDBL_REDIR_DECL, and > associate macros. > > We will have only one definition, we glibc will define all the expected aliase > (for float128 or nldbl if the case), instead of redefine the function prototype > after the initial prototype (as bits/stdio-ldbl.h). Afaik this is essentially > what clang does not support and most likely won't. Could you check if this WIP patches help in our case [1]? It essentially removes all the *-ldbl.h headers and move the alias redirection on the function prototype itself. I am still polishing and checking if this breaks something, so if you find any issue let me know. https://sourceware.org/git/?p=glibc.git;a=shortlog;h=refs/heads/azanella/redir-refactor