<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 doesn't link __init_array properly"
   href="https://llvm.org/bugs/show_bug.cgi?id=26727">26727</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>clang doesn't link __init_array properly
          </td>
        </tr>

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

        <tr>
          <th>Version</th>
          <td>3.7
          </td>
        </tr>

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

        <tr>
          <th>OS</th>
          <td>Linux
          </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>C++
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>jeff.crowell+llvm-list@gmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>dgregor@apple.com, llvm-bugs@lists.llvm.org
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>In ngx_pagespeed <a href="https://github.com/pagespeed/ngx_pagespeed">https://github.com/pagespeed/ngx_pagespeed</a> build instructions,
a static .a library which has an __init_array (prebuilt with gcc and provideed)
in it doesn't link properly.

If nginx is built with gcc, the __init_array gets populated

if nginx is built with clang, the __init_array is empty.

for an example see <a href="https://gist.github.com/crowell/9952fa514e8b861e5d66">https://gist.github.com/crowell/9952fa514e8b861e5d66</a>

I've tried using clang 3.4 which came with epel, and the gcc toolchain from
devtoolset, as well as the gcc toolchain from a source built gcc 5.1, and a
source built clang 3.7 with both gcc toolchains.

the gcc compiled code always has the __init_array populated, and the clang
compiled code never does.


to reproduce follow these instructions on centos 6.7

<a href="https://developers.google.com/speed/pagespeed/module/build_ngx_pagespeed_from_source">https://developers.google.com/speed/pagespeed/module/build_ngx_pagespeed_from_source</a>

but export CC="clang --gcc-toolchain=/opt/rh/devtoolset-2/root/usr/" or
whatever path points to a c++11 compatible gcc toolchain.</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>