public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Adhemerval Zanella <adhemerval.zanella@linaro.org>
To: "Fāng-ruì Sòng" <maskray@google.com>
Cc: libc-alpha@sourceware.org
Subject: Re: [PATCH] Remove fno-unit-at-a-time make variable
Date: Tue, 5 Apr 2022 13:40:10 -0300	[thread overview]
Message-ID: <4570fa06-24b0-873a-09b6-d57c85dd1191@linaro.org> (raw)
In-Reply-To: <CAFP8O3LY_8kiGTSydwMpURHFBCTeYZ97HBq=kU7mA9EoJVie6A@mail.gmail.com>



On 05/04/2022 13:22, Fāng-ruì Sòng wrote:
> On Tue, Apr 5, 2022 at 8:35 AM Adhemerval Zanella
> <adhemerval.zanella@linaro.org> 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

  reply	other threads:[~2022-04-05 16:40 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-30  5:07 Fangrui Song
2022-03-30 12:46 ` Adhemerval Zanella
2022-03-30 16:23   ` Fangrui Song
2022-03-30 16:28     ` Adhemerval Zanella
2022-03-31  3:43       ` Fangrui Song
2022-03-31 11:33         ` Adhemerval Zanella
2022-04-04 15:57           ` Fangrui Song
2022-04-05 14:35             ` Adhemerval Zanella
2022-04-05 16:22               ` Fāng-ruì Sòng
2022-04-05 16:40                 ` Adhemerval Zanella [this message]
2022-04-05 16:44                   ` Fāng-ruì Sòng
2022-04-05 16:49                     ` Adhemerval Zanella
2022-04-05 17:53                       ` Florian Weimer
2022-04-05 20:01                         ` Adhemerval Zanella
2022-04-05 20:26                           ` Florian Weimer
2022-04-05 20:30                             ` Adhemerval Zanella
2022-04-05 20:40                               ` Florian Weimer
2022-04-05 21:15                                 ` Adhemerval Zanella
2022-04-06 15:35                                   ` Adhemerval Zanella
2022-04-07  7:02                       ` Fāng-ruì Sòng

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4570fa06-24b0-873a-09b6-d57c85dd1191@linaro.org \
    --to=adhemerval.zanella@linaro.org \
    --cc=libc-alpha@sourceware.org \
    --cc=maskray@google.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).