Announcement

Collapse
No announcement yet.

-O3 Compiler Optimization Level Still Deemed Too Unsafe For The Linux Kernel

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • -O3 Compiler Optimization Level Still Deemed Too Unsafe For The Linux Kernel

    Phoronix: -O3 Compiler Optimization Level Still Deemed Too Unsafe For The Linux Kernel

    Due to not too old versions of the GNU Compiler Collection (GCC) possibly generating bad code with the "-O3" compiler optimization level and sometimes there not being performance benefits, Linus Torvalds remains against using this optimization flag when compiling the Linux kernel...

    https://www.phoronix.com/scan.php?pa...r-Linux-Kernel

  • #2
    -O3 turned me into a newt.

    A newt?

    I got better.

    Burn -O3 anyway.

    Comment


    • #3
      Forget -O3. Build the kernel with Clang and enable LTO. Simply pass LLVM=1 and LLVM_IAS=1 as arguments to make and you should be able to switch on LTO optimisation (works so far for x86 and 64-bit Arm, with a few exceptions, see arch/Kconfig for details).

      Code:
      $ make LLVM=1 LLVM_IAS=1 gconfig
      ‚Äč

      Compiling the kernel, normal or as a cross-compile, works in the same way:

      Code:
      make LLVM=1 LLVM_IAS=1 all
      or
      Code:
      make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- LLVM=1 LLVM_IAS=1 all

      It is so simple, even Michael should be able to do it.
      Last edited by sdack; 06 June 2021, 03:44 AM.

      Comment


      • #4
        Originally posted by sdack View Post
        Forget -O3. Build the kernel with Clang and enable LTO. Simply pass LLVM=1 and LLVM_IAS=1 as arguments to make and you should be able to switch on LTO optimisation (there are a few exceptions where it does not work, see arch/Kconfig for details).

        Code:
        $ make LLVM=1 LLVM_IAS=1 gconfig
        It is so simple, even Michael should be able to do it.
        That's nice. "xconfig" I assume? Looks like Qt. I've basically stuck to "make menuconfig" for like 15 years.

        Comment


        • #5
          Originally posted by skeevy420 View Post
          That's nice. "xconfig" I assume? Looks like Qt. I've basically stuck to "make menuconfig" for like 15 years.
          gconfig is the GTK frontend. It should work with menuconfig, too. It is just easier to make a quick snapshot and post a picture of it. Who does not like a nice picture, right?

          Comment


          • #6
            Originally posted by sdack View Post
            Forget -O3. Build the kernel with Clang and enable LTO. Simply pass LLVM=1 and LLVM_IAS=1 as arguments to make and you should be able to switch on LTO optimisation (there are a few exceptions where it does not work, see arch/Kconfig for details).

            Code:
            $ make LLVM=1 LLVM_IAS=1 gconfig


            It is so simple, even Michael should be able to do it.
            LLVM? Even -O3 in its worst days is a lot better and more trustworthy then building the kernel with this unreliable untrustable mess.

            Comment


            • #7
              This Torvalds quote is funny -
              honestly, judging by the last report the gcc people don't care about being careful. They literally are ok with knowingly generating an off-by-one range check, because "it's undefined behavior".
              And up until a few weeks ago, Linus was literally accepting any garbage patches from University of Minnesota delinquents for no reason whatsoever and without subjecting them to even the most cursory review.

              So, who cares about being "careful" more, I wonder?

              Comment


              • #8
                The GentooLTO project is quite a good resource for keeping track of what packages benefit from -O3 and LTO and which ones do not or simply break.

                Comment


                • #9
                  Originally posted by andyprough View Post
                  This Torvalds quote is funny -


                  And up until a few weeks ago, Linus was literally accepting any garbage patches from University of Minnesota delinquents for no reason whatsoever and without subjecting them to even the most cursory review.

                  So, who cares about being "careful" more, I wonder?
                  IIRC, it wasn't Linus who accepted the patches - it was Greg.

                  Comment


                  • #10
                    Doesn't RedHat backport fixes to such known bugs to previous compiler versions? Or maybe does -O3 need to be split into -O3 and -Oe (e for experimental) ?

                    I'd think this would be a priority.

                    Comment

                    Working...
                    X