GCC does not emit sub-word atomic operations inline.  As a result any application that directly or indirectly uses sub-word atomics must explicit link in the atomic library.  This causes major problems for the distros because they do not want to adjust all the affected packages to work around this quirk of the GCC RISC-V implementation.  The implementation should be adjusted to emit sub-word atomics inline to fix this problem.

GCC needs to implement atomic mappings that match the A.6 specification and which are forward compatible with the A.7 specification.  It is critical that all compilers implement a common standard for atomic mappings so that developers can rely on the compilers having the same visibility and forward progress guarantees.

The Ztso extension provides additional ordering guarantees which in turn allow both GCC and LLVM to emit more efficient atomic mappings than the RVWMO mappings.  Given the work already done on inline subword atomics and A.6→A.7 forward compatible mappings tracking the Ztso work here seemed reasonable.  Note that there are psabi dependencies, though Kito has indicated that a GCC review would help move psabi along in its process.



Ventana: Oversight/Review

Rivos: Patrick O'Neill for all the implementation work

Google: Design/Evaluation of desired sequences


The vast majority of the development work in this space was performed by engineers at Rivos.




Development Timeline2H2023


Upstream Version

gcc-13.2 (Inline subword atomic)

gcc-13 RISC-V Coordination Branch (Compatible mappings, Ztso)

gcc-14 (Compatible mappings, Ztso)

August 2023

Patrick O'Neill (Rivos)

Jeff Law (Ventana)





  • Ztso optimizations integrated.  Marking as complete again.


  • Ztso optimizations approved in GCC – just waiting on final ACK from PSABI.
  • Kito indicates that PSABI issues moving forward, expecting resolution soon
  • Open question if we'll push for Ztso bits to be included in gcc-13.3 near end of year
  • A.6/A.7 mappings were somehow missed in the gcc-13.2 backport list
    • Won't land until gcc-13.3 near the end of the year
    • Not ideal, but not the end of world either


  • Re-opening upstreaming to cover Ztso work that's hoping to land shortly
  • Patrick's got the Ztso work ready for review in GCC.  LLVM has an implementation behind an experimental flag
  • Kito has indicated getting GCC review work done can help move things from a psabi standpoint
    • Jeff L. owns review work given prior experience in this space


  • Note stakeholders/partners in consistent way

 – dates on or before June 15 are approximate.

  • Integration to gcc trunk complete
  • Implementation cherry-picked to gcc-13 branch
  • Considered complete


  • Project reported as priority for 2H23