<html>
    <head>
      <base href="https://llvm.org/bugs/" />
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW --- - clang's -O implies -O2 whereas gcc's -O implies -O1"
   href="https://llvm.org/bugs/show_bug.cgi?id=23581">23581</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>clang's -O implies -O2 whereas gcc's -O implies -O1
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>clang
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>3.6
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>FreeBSD
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>normal
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>Frontend
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedclangbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>yanegomi@gmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvmbugs@cs.uiuc.edu
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>I've been tracking down issues with debuggability on FreeBSD. It turns out that
the -O with clang means -O2, not -O1 like it does with gcc. From man gcc for
4.8.3:

       -O
       -O1 Optimize.  Optimizing compilation takes somewhat more time, and a
           lot more memory for a large function.

           With -O, the compiler tries to reduce code size and execution time,
           without performing any optimizations that take a great deal of
           compilation time.

           -O turns on the following optimization flags:

           -fauto-inc-dec -fcompare-elim -fcprop-registers -fdce -fdefer-pop
           -fdelayed-branch -fdse -fguess-branch-probability -fif-conversion2
           -fif-conversion -fipa-pure-const -fipa-profile -fipa-reference
           -fmerge-constants -fsplit-wide-types -ftree-bit-ccp
           -ftree-builtin-call-dce -ftree-ccp -ftree-ch -ftree-copyrename
           -ftree-dce -ftree-dominator-opts -ftree-dse -ftree-forwprop
           -ftree-fre -ftree-phiprop -ftree-slsr -ftree-sra -ftree-pta
           -ftree-ter -funit-at-a-time

           -O also turns on -fomit-frame-pointer on machines where doing so
           does not interfere with debugging.

>From man clang for 3.6.0:

             -O      Equivalent to -O2.

     -g      Generate debug information.  Note that Clang debug information
             works best at -O0.

It seems counterintuitive for projects that have used gcc for over a decade to
change behavior in this way. Why was this done/shouldn't clang pattern itself
after gcc to some degree?</pre>
        </div>
      </p>
      <hr>
      <span>You are receiving this mail because:</span>
      
      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>