From e93a1dccd82f831a2f0d2cc382d8af5e1fda55ed Mon Sep 17 00:00:00 2001 From: Tavian Barnes Date: Thu, 6 Jun 2024 10:23:14 -0400 Subject: atomic: Fix RISC-V build with GCC < 14 Prior to GCC 14.1, the __builtin_riscv_pause() can cause an error if the appropriate extension is not enabled in -march: /tmp/ccR1L1lA.s: Assembler messages: /tmp/ccR1L1lA.s:670: Error: unrecognized opcode `pause', extension `zihintpause' required Link: https://gcc.gnu.org/pipermail/gcc-patches/2023-August/626748.html Link: https://gcc.gnu.org/git/?p=gcc.git;a=commit;h=c2d04dd659c499d8df19f68d0602ad4c7d7065c2 Link: https://buildd.debian.org/status/fetch.php?pkg=bfs&arch=riscv64&ver=3.3.1-1&stamp=1717488400&raw=0 --- build/has/builtin-riscv-pause.c | 7 +++++++ build/header.mk | 1 + 2 files changed, 8 insertions(+) create mode 100644 build/has/builtin-riscv-pause.c (limited to 'build') diff --git a/build/has/builtin-riscv-pause.c b/build/has/builtin-riscv-pause.c new file mode 100644 index 0000000..24b0675 --- /dev/null +++ b/build/has/builtin-riscv-pause.c @@ -0,0 +1,7 @@ +// Copyright © Tavian Barnes +// SPDX-License-Identifier: 0BSD + +int main(void) { + __builtin_riscv_pause(); + return 0; +} diff --git a/build/header.mk b/build/header.mk index 09454c5..76e9562 100644 --- a/build/header.mk +++ b/build/header.mk @@ -16,6 +16,7 @@ HEADERS := \ gen/has/acl-is-trivial-np.h \ gen/has/acl-trivial.h \ gen/has/aligned-alloc.h \ + gen/has/builtin-riscv-pause.h \ gen/has/confstr.h \ gen/has/extattr-get-file.h \ gen/has/extattr-get-link.h \ -- cgit v1.2.3