<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 - After r356631, Sanitizer-i386-Test faills to link on FreeBSD"
   href="https://bugs.llvm.org/show_bug.cgi?id=42892">42892</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>After r356631, Sanitizer-i386-Test faills to link on FreeBSD
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>new-bugs
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>9.0
          </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>new bugs
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>dimitry@andric.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>htmldeveloper@gmail.com, llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Because we are still missing a proper libatomic on FreeBSD (see
<a href="https://bugs.freebsd.org/230888">https://bugs.freebsd.org/230888</a>), we do not have many of the builtins that
clang is calling after r356631 ("[X86] Add CMPXCHG8B feature flag. Set it for
all CPUs except i386/i486 including 'generic'. Disable use of CMPXCHG8B when
this flag isn't set.").

Specifically, this occurs because for the 32-bit x86 architecture (aka "i386")
FreeBSD still targets the i486 CPU by default, which does not support
cmpxchg8b.  (But note that it can also occur for e.g. 128-bit atomic loads on
64-bit architectures which do not have cmpxchg16b.)

To be able to build and test 9.0.0 rc1, I had to apply the following hack,
which basically sets the default target CPU for i386-unknown-freebsd to i586:

diff --git a/clang/lib/Driver/ToolChains/Arch/X86.cpp
b/clang/lib/Driver/ToolChains/Arch/X86.cpp
index 34be226b69e..f29948dab54 100644
--- a/clang/lib/Driver/ToolChains/Arch/X86.cpp
+++ b/clang/lib/Driver/ToolChains/Arch/X86.cpp
@@ -93,10 +93,10 @@ const char *x86::getX86TargetCPU(const ArgList &Args,
     return "x86-64";

   switch (Triple.getOS()) {
-  case llvm::Triple::FreeBSD:
   case llvm::Triple::NetBSD:
   case llvm::Triple::OpenBSD:
     return "i486";
+  case llvm::Triple::FreeBSD:
   case llvm::Triple::Haiku:
     return "i586";
   default:

I do not know a good way out of this conundrum.  We cannot come up with a quick
implementation of libatomic, as it has been an issue for years and nobody has
such an implementation.  On the other hand, our default target CPU has always
been i486, but realistically nobody in their right mind will run modern FreeBSD
on such CPUs.  Raising it to i586 (or even i686, woohoo) is most likely not
going to affect anybody, except for a few people insisting on running museum
hardware.</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>