public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Carlos O'Donell <carlos@redhat.com>
To: Gary Benson <gbenson@redhat.com>
Cc: "H.J. Lu" <hjl.tools@gmail.com>,
	Adhemerval Zanella <adhemerval.zanella@linaro.org>,
	GNU C Library <libc-alpha@sourceware.org>
Subject: Re: Why GLIBC requires compiler optimizations to build
Date: Thu, 21 Jun 2018 17:16:00 -0000	[thread overview]
Message-ID: <3393b12d-3c81-ddf2-4ef6-6902c274a521@redhat.com> (raw)
In-Reply-To: <CAHegJiKjZKXpMYM_yaqFsA4Gab2xsvcc7a1Nsk_3Mmht21AwEw@mail.gmail.com>

On 06/20/2018 11:22 AM, Gary Benson wrote:
> On 20 June 2018 at 13:51, Carlos O'Donell <carlos@redhat.com> wrote:
>> On 06/20/2018 06:35 AM, Gary Benson wrote:
>>> On 11 June 2018 at 22:48, H.J. Lu <hjl.tools@gmail.com> wrote:
>>>> On Mon, Jun 11, 2018 at 2:38 PM, Adhemerval Zanella <adhemerval.zanella@linaro.org> wrote:
>>>>> It has been some time since I tried to build glibc without optimization
>>>>> as an exercise and I can't really recall what exactly has prevented me
>>>>> to accomplish it.  So the question is if it is make sense to add such
>>>>> requirement and if it is the case whether it would be a useful options
>>>>> and what prevents us to do so?
>>>>
>>>> The main issue is to bootstrap ld.so to prevent dynamic relocations
>>>> before it is ready.
>>>
>>> Is it only really elf/rtld.c that specifically requires optimization then?
>>
>> No.
>>
>> The dynamic loader has many functions it needs to execute the early startup.
>>
>> So there are a lot of dependencies on other *.c files here and there, which
>> must be callable directly and not through the PLT.
> 
> Ok. Thanks for explaining this.
> 
>> The perfect solution is a refactored build system that can distinguish what
>> is going into rtld that needs optimizations and what is not. Then apply
>> optimizations only to rtld.
>>
>> Even then, for debugging purposes, I have gotten away with using gcc's
>> function attributes to mark some function as -O0 to debug them more easily,
>> otherwise it's very hard to debug and _dl_debug_printf() is your highest
>> value tool.
> 
> I did not know about __attribute__ ((optimize ())), thank you!

I couldn't live without it when debugging complex code bases where using
-O0 makes the bug go away or breaks rtld in this case... so you can use
the function attribute to alter just a function at a time.

Cheers,
Carlos.

      reply	other threads:[~2018-06-21 17:16 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-06-11 21:38 Adhemerval Zanella
2018-06-11 21:49 ` H.J. Lu
2018-06-20 10:35   ` Gary Benson
2018-06-20 12:51     ` Carlos O'Donell
2018-06-20 15:22       ` Gary Benson
2018-06-21 17:16         ` Carlos O'Donell [this message]

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=3393b12d-3c81-ddf2-4ef6-6902c274a521@redhat.com \
    --to=carlos@redhat.com \
    --cc=adhemerval.zanella@linaro.org \
    --cc=gbenson@redhat.com \
    --cc=hjl.tools@gmail.com \
    --cc=libc-alpha@sourceware.org \
    /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).