<html>
    <head>
      <base href="https://bugs.llvm.org/">
    </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 compiled with mingw-w64 emits available_externally for IsWindowsXPOrGreater()"
   href="https://bugs.llvm.org/show_bug.cgi?id=39182">39182</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Clang compiled with mingw-w64 emits available_externally for IsWindowsXPOrGreater()
          </td>
        </tr>

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

        <tr>
          <th>Version</th>
          <td>7.0
          </td>
        </tr>

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

        <tr>
          <th>OS</th>
          <td>Windows NT
          </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>LLVM Codegen
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>6yearold@gmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>I've compiled release_70 branch with recent mingw-w64 toolchain (GCC 8.2.0) and
using produced Clang to compile following program:

#include <VersionHelpers.h>
#include <stdio.h>

int main(int argc, char* argv[])
{
    IsWindowsXPOrGreater();
    printf("OK\n");
    return 0;
}

It fails on linking stage with "undefined reference to IsWindowsXPOrGreater".
When I use clang.exe from the official installer, it works fine.

I examined -S -emit-llvm output and found that my clang emits

define available_externally dso_local i32 @IsWindowsXPOrGreater {
...
}

while official clang emits

define linkonce_odr dso_local i32 @IsWindowsXPOrGreater {
...
}

Am I missing something, or it is a bug in Clang?

For reference, here is VersionHelpers.h source:
<a href="https://github.com/mirror/mingw-w64/blob/master/mingw-w64-headers/include/versionhelpers.h">https://github.com/mirror/mingw-w64/blob/master/mingw-w64-headers/include/versionhelpers.h</a></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>