From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-ot1-x32a.google.com (mail-ot1-x32a.google.com [IPv6:2607:f8b0:4864:20::32a]) by sourceware.org (Postfix) with ESMTPS id 927893858D1E for ; Tue, 5 Apr 2022 16:49:32 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 927893858D1E Received: by mail-ot1-x32a.google.com with SMTP id d15-20020a9d72cf000000b005cda54187c3so9778305otk.2 for ; Tue, 05 Apr 2022 09:49:32 -0700 (PDT) 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:to:cc:references:from:in-reply-to :content-transfer-encoding; bh=haOkPkNjByWfHYufDh8VkTcQaQJn1QqFxPTE5ODpwds=; b=pzGMnRn9CQafeUbG0161WWivAwMHcIENnTttEzh7sBcZ2kESODmGYwqDP1avy/RLOR LES1LxQnkFDVBVxjVCXUMurIxrPOhVkS59lhIYvN9nhiiKp2qbPnsijrT3fZUoqpVIHy 2fmiz5dqprF7PL8wBNMayxnjKp+n9asHwoWIRPTkMTffPfLtTmkUvFVILRKUn3vX8Ipw LEOPz0RcoaDXFBaXWshVLpfAruIjZ9kXcS7/9YXm7nb2cKmwpdRaKYubx05Z+504iPhk ySXHmekrN1aZkAJl9GdeKGcXA6EMWAYFvkEkAvqoeGy0lqNSJ8KloEZzJMt2o5GJ/Jks 9F9A== X-Gm-Message-State: AOAM532D7Ic9pKKNx6qc6oOl4xkKPlGAM3BNRZJo2MsZ+P3HbD5XVU/D OzPRuSR8ZA7ZMWusAnOML6F9LQ== X-Google-Smtp-Source: ABdhPJxmdzJdp9tOigmk2GgahSK+zulGUcS18eaTsLR95Dx35HXbV0C2UIXeE4aLYVzgzoX7nLEsSQ== X-Received: by 2002:a05:6830:91e:b0:5b2:6983:9c14 with SMTP id v30-20020a056830091e00b005b269839c14mr1587233ott.58.1649177371807; Tue, 05 Apr 2022 09:49:31 -0700 (PDT) Received: from ?IPV6:2804:431:c7cb:a6c0:26f4:3c2a:73ae:3e2? ([2804:431:c7cb:a6c0:26f4:3c2a:73ae:3e2]) by smtp.gmail.com with ESMTPSA id g18-20020a9d6c52000000b005af7c7cb702sm5782181otq.34.2022.04.05.09.49.30 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 05 Apr 2022 09:49:31 -0700 (PDT) Message-ID: <914158c4-f52d-21ee-73e5-6ffe30faa0d4@linaro.org> Date: Tue, 5 Apr 2022 13:49:28 -0300 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.8.0 Subject: Re: [PATCH] Remove fno-unit-at-a-time make variable Content-Language: en-US To: =?UTF-8?B?RsSBbmctcnXDrCBTw7JuZw==?= Cc: libc-alpha@sourceware.org References: <20220330050729.2176630-1-maskray@google.com> <0295bfe2-2f44-c15e-1628-acaf94fc407c@linaro.org> <20220330162311.pwg52gcrr5vnlabe@google.com> <7e7fdfdc-ddc8-cf5a-0525-f927b4ae1e39@linaro.org> <20220331034302.rzcu6gllo7ltkhjh@google.com> <20220404155703.vefk66cwnsnkhsih@google.com> <22f8e3aa-5af9-93a2-65fc-1889674103d6@linaro.org> <4570fa06-24b0-873a-09b6-d57c85dd1191@linaro.org> From: Adhemerval Zanella In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-6.0 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: Tue, 05 Apr 2022 16:49:34 -0000 On 05/04/2022 13:44, Fāng-ruì Sòng wrote: > On Tue, Apr 5, 2022 at 10:40 AM Adhemerval Zanella > wrote: >> >> >> >> On 05/04/2022 13:22, Fāng-ruì Sòng wrote: >>> On Tue, Apr 5, 2022 at 8:35 AM Adhemerval Zanella >>> wrote: >>>> >>>> >>>> >>>> On 04/04/2022 12:57, Fangrui Song wrote: >>>>> >>>>> On 2022-03-31, Adhemerval Zanella wrote: >>>>>> >>>>>> >>>>>> On 31/03/2022 00:43, Fangrui Song wrote: >>>>>>> On 2022-03-30, Adhemerval Zanella wrote: >>>>>>>> >>>>>>>> >>>>>>>> On 30/03/2022 13:23, Fangrui Song wrote: >>>>>>>>> On 2022-03-30, Adhemerval Zanella wrote: >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> On 30/03/2022 02:07, Fangrui Song wrote: >>>>>>>>>>> 795985e4e751 in 2003 added -fno-unit-at-a-time to errlist.c and >>>>>>>>>>> siglist.c to "avoid reordering assembler output". -fno-toplevel-reorder >>>>>>>>>>> is a rough replacement for this legacy option >>>>>>>>>>> (https://sourceware.org/pipermail/gcc-patches/2006-January/186801.html). >>>>>>>>>>> >>>>>>>>>>> The reordering requirement does not seem to be needed any longer. >>>>>>>>>> >>>>>>>>>> We still need them for otherwise DEFINE_COMPAT_ERRLIST used on errlist-compat.c >>>>>>>>>> does not create _sys_errlist and _sys_siglist with expected sizes defined by >>>>>>>>>> glibc ABI. >>>>>>>>>> >>>>>>>>>> I am trying to fix without resorting to compiler options. >>>>>>>>> >>>>>>>>> DEFINE_COMPAT_ERRLIST does not expand to code/data, just reordeable directives: >>>>>>>>> >>>>>>>>> >>>>>>>>> .globl __GLIBC_2_1_sys_errlist >>>>>>>>> .set __GLIBC_2_1_sys_errlist, _sys_errlist_internal >>>>>>>>> .type __GLIBC_2_1_sys_errlist,@object >>>>>>>>> .size __GLIBC_2_1_sys_errlist, 1000 >>>>>>>>> .globl __GLIBC_2_1__sys_errlist >>>>>>>>> .set __GLIBC_2_1__sys_errlist, _sys_errlist_internal >>>>>>>>> .type __GLIBC_2_1__sys_errlist,@object >>>>>>>>> .size __GLIBC_2_1__sys_errlist, 1000 >>>>>>>>> .symver __GLIBC_2_1_sys_nerr, sys_nerr@GLIBC_2.2.5 >>>>>>>>> .symver __GLIBC_2_1__sys_nerr, _sys_nerr@GLIBC_2.2.5 >>>>>>>>> .symver __GLIBC_2_1_sys_errlist, sys_errlist@GLIBC_2.2.5 >>>>>>>>> .symver __GLIBC_2_1__sys_errlist, _sys_errlist@GLIBC_2.2.5 >>>>>>>>> .globl __GLIBC_2_3_sys_errlist >>>>>>>>> .set __GLIBC_2_3_sys_errlist, _sys_errlist_internal >>>>>>>>> .type __GLIBC_2_3_sys_errlist,@object >>>>>>>>> .size __GLIBC_2_3_sys_errlist, 1008 >>>>>>>>> .globl __GLIBC_2_3__sys_errlist >>>>>>>>> .set __GLIBC_2_3__sys_errlist, _sys_errlist_internal >>>>>>>>> .type __GLIBC_2_3__sys_errlist,@object >>>>>>>>> .size __GLIBC_2_3__sys_errlist, 1008 >>>>>>>>> .symver __GLIBC_2_3_sys_nerr, sys_nerr@GLIBC_2.3 >>>>>>>>> .symver __GLIBC_2_3__sys_nerr, _sys_nerr@GLIBC_2.3 >>>>>>>>> .symver __GLIBC_2_3_sys_errlist, sys_errlist@GLIBC_2.3 >>>>>>>>> .symver __GLIBC_2_3__sys_errlist, _sys_errlist@GLIBC_2.3 >>>>>>>>> .globl __GLIBC_2_4_sys_errlist >>>>>>>>> >>>>>>>>> I do not know whether GCC would reorder these macros. Even yes, >>>>>>>>> that'd just change the .symtab entries in the relocatable object file. >>>>>>>>> The linker behavior remains the same with reordering. >>>>>>>> >>>>>>>> It does not seem to, just remove the -fno-unit-at-a-time and issue make >>>>>>>> check-abi and you will see that object size for the compat symbols >>>>>>>> reference to _sys_err_internal instead of the define compat ones. >>>>>>> >>>>>>> I see. I think this is a brittle behavior in GNU assembler. Filed >>>>>>> https://sourceware.org/bugzilla/show_bug.cgi?id=29012 with detailed >>>>>>> information. I have created a patch but I know that will not solve >>>>>>> glibc's problem :( >>>>>> >>>>>> It would be good to have this fixes, but unfortunately we need a way >>>>>> to handle this on older binutils. I am kind worried that the only >>>>>> possible way to actually fix this without resorting to any compiler >>>>>> flags is coding the array definitions in assembly direct... >>>>> >>>>> The GNU assembler issue has been fixed https://sourceware.org/bugzilla/show_bug.cgi?id=29012 >>>>> (milestone 2.39, way larger than the current required version: 2.25) >>>>> >>>>> Switching to assembly output doesn't seem bad :-) >>>>> >>>>> If you keep the compiler driver option but need to refactor the nearby >>>>> code, you may drop -fno-unit-at-a-time. It was added in 2006 (somewhere >>>>> between GCC 4.1 and 4.4), while glibc requires GCC>=6.2. >>>> >>>> Good to know we won't need to rely on compiler flags to get the expected >>>> correct asm directives. I am still struggling to get a fix without resorting >>>> to compiler flags, but without much success. Trying to move it to assembly >>>> might be tricky, I am not sure if the data directives would be architecture >>>> agnostic. >>> >>> Many directives are architecture-independent: >>> https://sourceware.org/binutils/docs/as/Pseudo-Ops.html#Pseudo-Ops >>> binutils-gdb/gas/read.c:346 The `portable[]` array. >> >> I think we can make it work with asciz directive. >> >>> >>> To support Clang, no refactoring is probably needed: just change >>> fno_unit_at_a_time to only specify -fno-toplevel-reorder (and rename >>> it), not th legacy -fno-unit-at-a-time. >> >> Afaik llvm does not support -fno-toplevel-reorder > > It doesn't, but its integrated assembler does not need the option to > have the desired semantics. I have a note that the new GNU as behavior > is quite similar to LLVM's integrated assembler since 2014-03: > https://sourceware.org/bugzilla/show_bug.cgi?id=29012#c1 This is not what I am seeing on my clang branch, where clang with integrated moves the global asm directives to the top of the file. And it makes check-abi fail due the _sys_errlist/sys_errlist being with wrong value.