[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 06:20:08 PDT 2018


On 7 Aug 2018, at 14:10, Pete Blacker <pete.blacker at gmail.com> wrote:
> 
> atomic.c now compiles without warning but it's failing to link with a lot of undefined reference to `__atomic_is_lock_free' errors. This is definitely progress!
> 
> Is this simply a case of adding another source file from the llvm builtins?

This one is harder.  These are all meant to be compiler-provided builtins that tell the system whether it can do atomic operations of a particular size or whether it needs to do a library call (or, in the case of the stuff in atomic.c, use a lock).

You might be able to get away with providing a stub definition of __atomic_is_lock_free that always returns false.  This should then cause the library functions to use a mutex.  You will need a compiler that can at least provide a simple compare and swap to implement a spinlock though… (or you’ll need to add a new locking implementation in atomic.c that uses some assembly for your target).

David





More information about the cfe-dev mailing list