From 4a7f3ac8eb4381ea62caa1741eeeec28363245b4 Mon Sep 17 00:00:00 2001 From: Mauri de Souza Meneguzzo Date: Fri, 9 Feb 2024 11:47:26 +0000 Subject: [PATCH] runtime/cgo: ignore -Watomic-alignment in gcc_libinit.c When cross-compiling a cgo program with CC=clang for Linux/ARMv5, atomic warnings cause build errors, as cgo uses -Werror. These warnings seem to be harmless and come from the usage of __atomic_load_n, which is emulated due to the lack of atomic instructions in armv5. Fixes #65290 Change-Id: Ie72efb77468f06888f81f15850401dc8ce2c78f9 GitHub-Last-Rev: fbad847b962f6b4599cd843018e79f4b55be097e GitHub-Pull-Request: golang/go#65588 Reviewed-on: https://go-review.googlesource.com/c/go/+/562348 Auto-Submit: Ian Lance Taylor LUCI-TryBot-Result: Go LUCI Reviewed-by: Ian Lance Taylor Reviewed-by: Dmitri Shuralyov --- src/runtime/cgo/gcc_libinit.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/runtime/cgo/gcc_libinit.c b/src/runtime/cgo/gcc_libinit.c index 68f4a023795db..09ba38b6d039e 100644 --- a/src/runtime/cgo/gcc_libinit.c +++ b/src/runtime/cgo/gcc_libinit.c @@ -4,6 +4,12 @@ //go:build unix +// When cross-compiling with clang to linux/armv5, atomics are emulated +// and cause a compiler warning. This results in a build failure since +// cgo uses -Werror. See #65290. +#pragma GCC diagnostic ignored "-Wpragmas" +#pragma GCC diagnostic ignored "-Watomic-alignment" + #include #include #include