[llvm-bugs] [Bug 31979] New: __atomic_* builtins need to link -latomic with -rtlib=libgcc

via llvm-bugs llvm-bugs at lists.llvm.org
Thu Feb 16 05:55:30 PST 2017


http://bugs.llvm.org/show_bug.cgi?id=31979

            Bug ID: 31979
           Summary: __atomic_* builtins need to link -latomic with
                    -rtlib=libgcc
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Driver
          Assignee: unassignedclangbugs at nondot.org
          Reporter: mgorny at gentoo.org
                CC: llvm-bugs at lists.llvm.org

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.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20170216/fe4f2d17/attachment.html>


More information about the llvm-bugs mailing list