[RISC-V] Infinite loop when disabled Atomic

Hi devs,
please consider below scenario,
while compiling

with command(A extension disabled )
$clang --target=riscv64 -march=rv64imfdc -mabi=lp64d -c atomic.o atomic.c
after dumping atomic.o we see that
below call
(atomic.c#L95) lock -> (atomic.c#L198) __atomic_compare_exchange ->
(atomic.c#L95) lock

any thought on, how can we break this loop?
do we need to provide platform-specific lock here since the generic
lock is causing the problem?