1

I want to know if compiling the Linux kernel with -Ofast is:

  1. Worth it.
  2. Supported (what level of optimization do the kernel writers take into account?)
  3. Secure.

The question arised because I compiled some small programs I wrote with -Ofast and it improved speed significantly compared with -O2 and -O0, then maybe I should try compiling programs I didn't write; since my computer is kind of old, I want to compile with the highest optimizations I can.

2

As in "can", go ahead! Open Source and all that. Does it explode in your face? Probably not (if the GCC folks did it right, that is; quite sure if you don't use some experimental/unreleased version). But it is not one of the compiler options getting very extensive testing/vetting by kernel builders.

Go at your own risk. Do track down and report any resulting problems (to GCC and Linux).

3
  • 1
    So I guess your answer is: "it's not fully supported (is not one of the compiler options getting very extensive testing/vetting)" and "it's not secure (go at your own risk)" but "just do it if you want (go ahead!)" :P. However, do you consider it's worth it? Apr 4 '20 at 19:07
  • 4
    The "go at your own risk" part is more likely something like "the not-well-tested optimization may interact badly with some hand-optimized assembler routine deep within the kernel, and may in some specific situation cause your data to be corrupted". It might cause the kernel to crash at boot because some critical part of scheduling or memory allocation does not work right, or cause more subtle errors that you might not notice until the damage is already done. Don't keep non-backed-up data on a system you use for testing new kernel optimizations.
    – telcoM
    Apr 4 '20 at 21:36
  • There is nothing "non-backed up data" has to do with the kernel. I have been compiling different kernels with different options. If my system crashes, I chroot into the system, I then either run sudo pacman -S linux && grub-mkconfig -o /boot/grub/grub.cfg or just go with previous compiled kernel that is already on my SSD. So there's no fear of losing data if kernel is not booting.
    – S.Goswami
    Oct 13 '20 at 18:50

This site is temporarily in read only mode and not accepting new answers.

Not the answer you're looking for? Browse other questions tagged .