GLibc optimization required

Why is it not possible to recompile GLibc by disabling all optimizations (i.e. -O0)?

In particular, in this case:

make CFLAGS='-O0 -w' CXXFLAGS='-O0 -w'

      

I get:

 #error "glibc cannot be compiled without optimization"

      

+3


source to share


2 answers


If you're literally just doing it wrong on Google, the first result tells you exactly why.



"If you run the dynamic loader early ( _dl_start

) before moving the PLT, you cannot make function calls. You must inline the functions that you will use during early startup, or the compiler's builtins ( __builtin_*

) call .

Without optimizations enabled, GCC will not have built-in functionality. Early launch of the dynamic loader will cause function calls through the unrelocated PLT and crash. "- Carlos O'Donell

+5


source


Basically: " glibc

- this is voodoo!" This "library of all libraries" has a special place in any system because in fact (?) Everything else in the entire system relies on it.



So if "someone out there" takes the time to prevent you from compiling this library "without optimization", I cordially invite you to grab him / her at their word. "There must be a [very good] reason."

+1


source







All Articles