* Why GLIBC requires compiler optimizations to build @ 2018-06-11 21:38 Adhemerval Zanella 2018-06-11 21:49 ` H.J. Lu 0 siblings, 1 reply; 6+ messages in thread From: Adhemerval Zanella @ 2018-06-11 21:38 UTC (permalink / raw) To: GNU C Library 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? ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Why GLIBC requires compiler optimizations to build 2018-06-11 21:38 Why GLIBC requires compiler optimizations to build Adhemerval Zanella @ 2018-06-11 21:49 ` H.J. Lu 2018-06-20 10:35 ` Gary Benson 0 siblings, 1 reply; 6+ messages in thread From: H.J. Lu @ 2018-06-11 21:49 UTC (permalink / raw) To: Adhemerval Zanella; +Cc: GNU C Library 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. -- H.J. ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Why GLIBC requires compiler optimizations to build 2018-06-11 21:49 ` H.J. Lu @ 2018-06-20 10:35 ` Gary Benson 2018-06-20 12:51 ` Carlos O'Donell 0 siblings, 1 reply; 6+ messages in thread From: Gary Benson @ 2018-06-20 10:35 UTC (permalink / raw) To: H.J. Lu; +Cc: Adhemerval Zanella, GNU C Library 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? Thanks, Gary ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Why GLIBC requires compiler optimizations to build 2018-06-20 10:35 ` Gary Benson @ 2018-06-20 12:51 ` Carlos O'Donell 2018-06-20 15:22 ` Gary Benson 0 siblings, 1 reply; 6+ messages in thread From: Carlos O'Donell @ 2018-06-20 12:51 UTC (permalink / raw) To: Gary Benson, H.J. Lu; +Cc: Adhemerval Zanella, GNU C Library 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. 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. Cheers, Carlos. ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Why GLIBC requires compiler optimizations to build 2018-06-20 12:51 ` Carlos O'Donell @ 2018-06-20 15:22 ` Gary Benson 2018-06-21 17:16 ` Carlos O'Donell 0 siblings, 1 reply; 6+ messages in thread From: Gary Benson @ 2018-06-20 15:22 UTC (permalink / raw) To: Carlos O'Donell; +Cc: H.J. Lu, Adhemerval Zanella, GNU C Library 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! Gary ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Why GLIBC requires compiler optimizations to build 2018-06-20 15:22 ` Gary Benson @ 2018-06-21 17:16 ` Carlos O'Donell 0 siblings, 0 replies; 6+ messages in thread From: Carlos O'Donell @ 2018-06-21 17:16 UTC (permalink / raw) To: Gary Benson; +Cc: H.J. Lu, Adhemerval Zanella, GNU C Library 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. ^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2018-06-21 17:16 UTC | newest] Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2018-06-11 21:38 Why GLIBC requires compiler optimizations to build 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 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).