<html>
    <head>
      <base href="http://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 - __atomic_* builtins need to link -latomic with -rtlib=libgcc"
   href="http://bugs.llvm.org/show_bug.cgi?id=31979">31979</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>__atomic_* builtins need to link -latomic with -rtlib=libgcc
          </td>
        </tr>

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

        <tr>
          <th>Version</th>
          <td>trunk
          </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>enhancement
          </td>
        </tr>

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

        <tr>
          <th>Component</th>
          <td>Driver
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>mgorny@gentoo.org
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>While running libomp tests, I've noticed that some tests fail with undefined
references for 32-bit x86:

$ "/usr/lib/llvm/5/bin/i686-pc-linux-gnu-clang" "-fopenmp" "-I"
"/tmp/portage/sys-libs/libomp-9999/work/libomp-9999/runtime/test" "-I"
"/tmp/portage/sys-libs/libomp-9999/work/libomp-9999-abi_x86_32.x86/runtime/src"
"-L"
"/tmp/portage/sys-libs/libomp-9999/work/libomp-9999-abi_x86_32.x86/runtime/src"
"/tmp/portage/sys-libs/libomp-9999/work/libomp-9999/runtime/test/atomic/omp_atomic.c"
"-o"
"/tmp/portage/sys-libs/libomp-9999/work/libomp-9999-abi_x86_32.x86/runtime/test/atomic/Output/omp_atomic.c.tmp"
"-lm"
# command stderr:
/tmp/portage/sys-libs/libomp-9999/temp/omp_atomic-bc2a2f.o: In function
`.omp_outlined..4':
/tmp/portage/sys-libs/libomp-9999/work/libomp-9999/runtime/test/atomic/omp_atomic.c:(.text+0xe14):
undefined reference to `__atomic_load'
/tmp/portage/sys-libs/libomp-9999/temp/omp_atomic-bc2a2f.o: In function
`.omp_outlined..6':
/tmp/portage/sys-libs/libomp-9999/work/libomp-9999/runtime/test/atomic/omp_atomic.c:(.text+0x1044):
undefined reference to `__atomic_load'
/tmp/portage/sys-libs/libomp-9999/temp/omp_atomic-bc2a2f.o: In function
`.omp_outlined..12':
/tmp/portage/sys-libs/libomp-9999/work/libomp-9999/runtime/test/atomic/omp_atomic.c:(.text+0x154a):
undefined reference to `__atomic_load'
clang-5.0: error: linker command failed with exit code 1 (use -v to see
invocation)

error: command failed with exit status: 1

[this is using default -rtlib=libgcc]

After some investigation, it seems that when using -rtlib=libgcc, the __atomic*
functions are provided by libatomic rather than libgcc*. I'm not sure if we
should link it in unconditionally, or if we can do some heuristic to determine
if it should be linked in.

Furthermore, I don't know how many GCC versions actually supply the library.</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>