[cfe-dev] Trying to add __atomic_load_x support to a sparc-gaisler-elf-clang++ project
David Chisnall via cfe-dev
cfe-dev at lists.llvm.org
Tue Aug 7 05:09:14 PDT 2018
> On 7 Aug 2018, at 13:06, Pete Blacker via cfe-dev <cfe-dev at lists.llvm.org> wrote:
>
> Hi There,
>
> I'm currently trying to setup a build system using the tensorflow XLA compiler and the gaisler version of clang which generates code for the LEON family of CPU's.
>
> The problem I've hit is that the C++11 support in this version of clang doesn't appear to be complete, it doesn't support std::atomic. Meanwhile the XLA compiler is producing an IR as well as a header file for inclusion in the project, when compiled and linked this has a dependency on the library call __atomic_load_1. Which then causes a linker error : undefined reference to `__atomic_load_1'
>
> How would I go about adding these functions into this project so that the XLA compiler output can be successfully linked?
>
> I've tried adding the compiler-rt/lib/builtins/atomic.c source into the project but it produced the following compiler warning and failed to link with the same error as above:
>
> sparc-gaisler-elf-clang: warning: treating 'c' input as 'c++' when in C++ mode, this behavior is deprecated [-Wdeprecated]
> atomic.c:162:6: warning: #pragma redefine_extname is applicable to external C declarations only; not applied to function '__atomic_load_c' [-Wpragmas]
> void __atomic_load_c(int size, void *src, void *dest, int model) {
>
> Am I remotely on the right track to add support for atomic operations?
Yes, I believe that the only thing that you’re doing wrong is passing atomic.c to clang++ instead of clang. If you compile it with clang (or, I believe, with 'clang++ -x c’) separately and then link the resulting .o file, then it is likely to work.
David
More information about the cfe-dev
mailing list