<html>
    <head>
      <base href="https://bugs.webkit.org/" />
    </head>
    <body><span class="vcard"><a class="email" href="mailto:jfbastien&#64;apple.com" title="JF Bastien &lt;jfbastien&#64;apple.com&gt;"> <span class="fn">JF Bastien</span></a>
</span> changed
              <a class="bz_bug_link 
          bz_status_ASSIGNED "
   title="ASSIGNED - build fails with memory model cannot be stronger than success memory model for ‘__atomic_compare_exchange’"
   href="https://bugs.webkit.org/show_bug.cgi?id=155371">bug 155371</a>
        <br>
             <table border="1" cellspacing="0" cellpadding="8">
          <tr>
            <th>What</th>
            <th>Removed</th>
            <th>Added</th>
          </tr>

         <tr>
           <td style="text-align:right;">Status</td>
           <td>NEW
           </td>
           <td>ASSIGNED
           </td>
         </tr>

         <tr>
           <td style="text-align:right;">Assignee</td>
           <td>webkit-unassigned&#64;lists.webkit.org
           </td>
           <td>jfbastien&#64;apple.com
           </td>
         </tr>

         <tr>
           <td style="text-align:right;">Attachment #283631 is obsolete</td>
           <td>
               &nbsp;
           </td>
           <td>1
           </td>
         </tr>

         <tr>
           <td style="text-align:right;">Attachment #288772 Flags</td>
           <td>
               &nbsp;
           </td>
           <td>review?
           </td>
         </tr></table>
      <p>
        <div>
            <b><a class="bz_bug_link 
          bz_status_ASSIGNED "
   title="ASSIGNED - build fails with memory model cannot be stronger than success memory model for ‘__atomic_compare_exchange’"
   href="https://bugs.webkit.org/show_bug.cgi?id=155371#c12">Comment # 12</a>
              on <a class="bz_bug_link 
          bz_status_ASSIGNED "
   title="ASSIGNED - build fails with memory model cannot be stronger than success memory model for ‘__atomic_compare_exchange’"
   href="https://bugs.webkit.org/show_bug.cgi?id=155371">bug 155371</a>
              from <span class="vcard"><a class="email" href="mailto:jfbastien&#64;apple.com" title="JF Bastien &lt;jfbastien&#64;apple.com&gt;"> <span class="fn">JF Bastien</span></a>
</span></b>
        <pre>Created <span class=""><a href="attachment.cgi?id=288772&amp;action=diff" name="attach_288772" title="patch which inlines all atomics instead">attachment 288772</a> <a href="attachment.cgi?id=288772&amp;action=edit" title="patch which inlines all atomics instead">[details]</a></span>
patch which inlines all atomics instead

I don't think this is the right fix. I've attached a different one. TL;DR the quick fix is to make these wrapper function ALWASY_INLINE.

Details:

I tested with a few GCC versions, and the problem is specific to pre-5 revisions of GCC at Os only. The reason is that libstdc++ tries to be clever about enforcing the C++ standard's clause [atomics.types.operations.req] ¶21 which states:

    Requires: The failure argument shall not be `memory_order_release` nor
    `memory_order_acq_rel`. The failure argument shall be no stronger than the
    success argument.

It fails at doing this because its inlining heuristics are modified by Os, and they're not quite as dumb as O0 but not smart enough to get to the good code at O1. Adding ALWAYS_INLINE fixes the silliness at Os, leaves O1 great, and makes O0 slightly less bad but still pretty bad.

Try it out here: <a href="https://godbolt.org/g/8FPxWt">https://godbolt.org/g/8FPxWt</a>


The other good news is that I'm going to get this particular problem fixed in the version of C++ which will come after C++17:
<a href="https://github.com/jfbastien/papers/blob/master/source/P0418r1.bs">https://github.com/jfbastien/papers/blob/master/source/P0418r1.bs</a></pre>
        </div>
      </p>
      <hr>
      <span>You are receiving this mail because:</span>
      
      <ul>
          <li>You are the assignee for the bug.</li>
      </ul>
    </body>
</html>