Announcement

Collapse
No announcement yet.

Clang 11 Changes -O To Match GCC Behavior

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

  • Clang 11 Changes -O To Match GCC Behavior

    Phoronix: Clang 11 Changes -O To Match GCC Behavior

    Clang 11.0 has changed its "-O" optimization flag to match the defaults of GCC...

    Phoronix, Linux Hardware Reviews, Linux hardware benchmarks, Linux server benchmarks, Linux benchmarking, Desktop Linux, Linux performance, Open Source graphics, Linux How To, Ubuntu benchmarks, Ubuntu hardware, Phoronix Test Suite

  • #2
    Actually -O is a flag that shouldn't exist at all (it means "optimize what you want --I don't care", which in the end means "I don't care about the object code quality"). On the other hand, flags that do have a meaning are -O0 (don't optimize), -O1 (light optimization for speed), -O2 (moderate optimization for speed) -O3 (aggressive optimization for speed, that can have undesired results in some cases), and -Os (optimize for size). Apart from these, you also have more detailed flags for fine-tuning how to optimize.

    So, basically, you use -O when you should actually be using the -O1/2/3/s flag appropriate for what you really want.

    Comment


    • #3
      Originally posted by cesarcafe View Post
      Actually -O is a flag that shouldn't exist at all (it means "optimize what you want --I don't care", which in the end means "I don't care about the object code quality"). On the other hand, flags that do have a meaning are -O0 (don't optimize), -O1 (light optimization for speed), -O2 (moderate optimization for speed) -O3 (aggressive optimization for speed, that can have undesired results in some cases), and -Os (optimize for size). Apart from these, you also have more detailed flags for fine-tuning how to optimize.
      Cool story bro. You missed -Og.

      Comment


      • #4
        You both missed -Ofast

        Comment


        • #5
          Originally posted by skeevy420 View Post
          You both missed -Ofast
          You missed -O9.

          Comment


          • #6
            Originally posted by cesarcafe View Post
            Actually -O is a flag that shouldn't exist at all (it means "optimize what you want --I don't care", which in the end means "I don't care about the object code quality"). On the other hand, flags that do have a meaning are -O0 (don't optimize), -O1 (light optimization for speed), -O2 (moderate optimization for speed) -O3 (aggressive optimization for speed, that can have undesired results in some cases), and -Os (optimize for size). Apart from these, you also have more detailed flags for fine-tuning how to optimize.

            So, basically, you use -O when you should actually be using the -O1/2/3/s flag appropriate for what you really want.
            Since the programmer has no idea what O1 or O2 will actually do using just O makes as much sense.

            If they cared they'd specify each optimization specifically on the command line.

            Comment


            • #7
              Originally posted by Zan Lynx View Post

              Since the programmer has no idea what O1 or O2 will actually do using just O makes as much sense.

              If they cared they'd specify each optimization specifically on the command line.
              They don't have to, but the maintainer of the project's build system should. Sometimes those are the same person, sometimes not. In any case, using a specific level makes a lot of sense.

              Comment


              • #8
                Originally posted by oleid View Post
                ...but the maintainer of the project's build system should.
                Why..?
                Last edited by JustinTurdeau; 19 May 2020, 11:36 AM.

                Comment


                • #9
                  Originally posted by cesarcafe View Post
                  So, basically, you use -O when you should actually be using the -O1/2/3/s flag appropriate for what you really want.
                  No, no, no. You got that wrong.
                  -O is the equivalent of you walking into a bar and telling the bartender: surprise me

                  Comment


                  • #10
                    Originally posted by JustinTurdeau View Post

                    Why..?
                    Well, to give your project sane defaults for release build.

                    Your project could be dead slow with the wrong compiler settings or even worse, yield incorrect results due to broken optimization.

                    Other projects need the extra speed (and have no hard floating point Arithmetic requirements) an might want -O3.

                    In any case, it is the responsibility of the maintainer of the project's build system to implement the specifications.

                    Comment

                    Working...
                    X