From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-qk1-x729.google.com (mail-qk1-x729.google.com [IPv6:2607:f8b0:4864:20::729]) by sourceware.org (Postfix) with ESMTPS id 5F4A83858002 for ; Tue, 23 Mar 2021 17:59:58 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 5F4A83858002 Received: by mail-qk1-x729.google.com with SMTP id q3so15280113qkq.12 for ; Tue, 23 Mar 2021 10:59:58 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=dAKGY8cxGe/BIVUxyUGDGrALqzP3zbj3SVd2YMqgiCM=; b=Y8egZyCqlweEpzlK4yrGFmGJdoFYKTxnrx6SGPkLSuQWbyf0foq82qd3FZFckY8y/b LKI9utw1fy9Lhxopjct3+svSu5WBPrhgqWB6xjyg0JGcyk75z9UZs0ISQuC/nwLzsF5N aeXh2UOiNxrtev6rVySBFCk8fb5lfw8qo2c4MTHkeL0LdCfC7MEk/sy25zuBsrTqgjBC TAOTH7cqaoUGOK0V+zWiGLV3VqTDecVm4zKll4NtTf+qlLi1WrQ7r2xsdXSAM8V/CJHM nBGYnK1FaH1xF0cQdUynipczbBBqROrH+5GkPwSUiln0CyPOtFmHKpgFVoOEYhYUZB39 g0Nw== X-Gm-Message-State: AOAM531tdGy7KY6oOUlAc3PxAhaKU34B3xs67jolxY8A0TeYCyxl0siu E6fN+VB6sWN6eP4IenAJyF9RrbzbAwmwBQ== X-Google-Smtp-Source: ABdhPJyafrhwdceqfgqOO9/Uui8U0+OaUTtXfk49+CMI94kJpS+MM+ByWI7K6+HRUrC1ogPyNDVQaw== X-Received: by 2002:a37:a085:: with SMTP id j127mr6292941qke.206.1616522397708; Tue, 23 Mar 2021 10:59:57 -0700 (PDT) Received: from [192.168.1.132] ([177.194.41.149]) by smtp.gmail.com with ESMTPSA id e14sm13792754qka.56.2021.03.23.10.59.56 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 23 Mar 2021 10:59:57 -0700 (PDT) Subject: Re: [PATCH] stdio: Move include of bits/stdio-ldbl.h before bits/stdio.h To: John Paul Adrian Glaubitz , libc-alpha@sourceware.org References: <20210322111530.3215018-1-glaubitz@physik.fu-berlin.de> From: Adhemerval Zanella Message-ID: <9dedf9b9-5af3-3f3b-e749-2c8e50ec5dc4@linaro.org> Date: Tue, 23 Mar 2021 14:59:54 -0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.8.1 MIME-Version: 1.0 In-Reply-To: <20210322111530.3215018-1-glaubitz@physik.fu-berlin.de> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-12.7 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, NICE_REPLY_A, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) 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: Tue, 23 Mar 2021 18:00:06 -0000 On 22/03/2021 08:15, John Paul Adrian Glaubitz wrote: > On targets where long double math is optional and the architecture > does not support support long double, glibc defines a number of > redirection macros which alias "foo" with "__nldbl_foo" while > applying an __asm__ label. > > As a result, the __asm__ label gets applied after vfprintf() has > already been used which is not allowed. Moving bits/stdio-ldbl.h > bits/stdio.h in libio/stdio.h avoids this problem. > > Fixes bug 27558. > --- > libio/stdio.h | 10 +++++----- > 1 file changed, 5 insertions(+), 5 deletions(-) > > diff --git a/libio/stdio.h b/libio/stdio.h > index 144137cf67..ae5337e855 100644 > --- a/libio/stdio.h > +++ b/libio/stdio.h > @@ -857,6 +857,11 @@ extern void funlockfile (FILE *__stream) __THROW; > extern int __uflow (FILE *); > extern int __overflow (FILE *, int); > > +#include > +#if defined __LDBL_COMPAT || __LDOUBLE_REDIRECTS_TO_FLOAT128_ABI == 1 > +# include > +#endif > + > /* If we are compiling with optimizing read this file. It contains > several optimizing inline functions and macros. */ > #ifdef __USE_EXTERN_INLINES > @@ -866,11 +871,6 @@ extern int __overflow (FILE *, int); > # include > #endif > > -#include > -#if defined __LDBL_COMPAT || __LDOUBLE_REDIRECTS_TO_FLOAT128_ABI == 1 > -# include > -#endif > - > __END_DECLS > > #endif /* included. */ > 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.