Re: GCC-11.2.0 libatomic for bare-metal (riscv64-unknown-elf)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sat, Aug 21, 2021 at 1:56 PM Aileen Honess <aileen@xxxxxxxxxxxxxxxxx>
wrote:

> When I configure and create a gcc cross-compiler for aarch64-unknown-elf,
> I get a valid and working libatomic.  Critically, this contains
> implementations of the methods that underlie the gcc atomic builtins
> (__atomic_load(), etc.).  I mean things like '__atomic_fetch_and_1()'.
> When I do similar for riscv64-unknown-elf, I do not get libatomic. The
> “configure.tgt” for libatomic says that the platform is UNSUPPORTED.  The
> build continues, but if I use the atomic builtins, I’ll get undefined
> references to those underlying functions.
>

libatomic fails to build for all *-elf targets.  So it is failing to build
for both aarch64-elf and riscv-elf.  The difference here is that rv32 only
has atomic support for 32-bit words, and rv64 only has atomic support for
32-bit words and 64-bit double words.  Whereas aarch64 v8.1-a has atomic
support for all integer types, so can emit code directly for operations
like __atomic_fetch_and_1.  If compiling for RISC-V or armv8.0 then you
will get calls to functions for unsupported types.  aarch64 apparently has
a library somewhere to implement these functions for *-elf toolchains.
RISC-V does not yet.  We have long term plans to open code the char and
short operations using lr.[wd] and sc.[wd] but we don't know when this work
will be done.

Meanwhile, you should avoid char/short atomic operations.  Or you could
write your own library routines.  You could take the linux riscv libatomic
and disassemble it to get the code you need.

Jim




[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux