Buildroot Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Angelo Compagnucci <angelo.compagnucci@gmail.com>
To: buildroot@buildroot.org
Cc: Angelo Compagnucci <angelo.compagnucci@gmail.com>,
	Thomas Petazzoni <thomas.petazzoni@bootlin.com>
Subject: [Buildroot] [PATCH v2] package/nginx: fix sparc compile
Date: Mon, 23 Nov 2026 23:14:27 +0100	[thread overview]
Message-ID: <20261123221427.4028223-1-angelo.compagnucci@gmail.com> (raw)
In-Reply-To: <aqAyY__D1LhpPHDs@waldemar-brodkorb.de>

From: Waldemar Brodkorb <wbx@openadk.org>

When libatomic_ops is enabled, nginx fails to configure on sparc v8:

checking for atomic_ops library

.../sparc-buildroot-linux-uclibc/bin/ld: /tmp/ccmE9jc4.o: in function `main':
autotest.c:(.text.startup+0x58): undefined reference to `__atomic_fetch_add_4'
collect2: error: ld returned 1 exit status

./configure: error: libatomic_ops library was not found.

Since version 7.8.0, libatomic_ops uses the GCC __atomic built-ins on
SPARC with GCC 12 or later. SPARC v8 has no compare-and-swap
instruction, so these built-ins are calls into libatomic. nginx only
links with -latomic_ops.

Link with libatomic when the toolchain has it, as libdrm does in
6fec4282a0 ("package/libdrm: link with libatomic if needed").
libatomic_ops is not only used on SPARC: the upstream zone modules
select it on every architecture.

Pass -latomic through the existing --with-ld-opt option: nginx keeps
only the last --with-ld-opt, so a second one would drop TARGET_LDFLAGS.

The problem was introduced in 4b285598e8 ("package/libatomic_ops: bump
to version 7.8.0").

Fixes: https://autobuild.buildroot.net/results/4ef/4efd5ca93abb181d3a982938429db00f235031e1/
Signed-off-by: Waldemar Brodkorb <wbx@openadk.org>
Co-authored-by: Angelo Compagnucci <angelo.compagnucci@gmail.com>
Signed-off-by: Angelo Compagnucci <angelo.compagnucci@gmail.com>
---
Changes v1 -> v2:
  - link with libatomic when the toolchain has it, not only on SPARC
    v8: libatomic_ops is also enabled on other architectures
    [Thomas Petazzoni]
  - pass -latomic through the existing --with-ld-opt: nginx keeps only
    the last one, so a second --with-ld-opt dropped TARGET_LDFLAGS
  - reword the commit message with the cause and a recent autobuilder
    failure

Supersedes v1: https://patchwork.buildroot.org/project/buildroot/patch/Zq9j8m3YPt0Xh0gY@waldemar-brodkorb.de/

 package/nginx/nginx.mk | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/package/nginx/nginx.mk b/package/nginx/nginx.mk
index 187fb17eb5..1cdf001b38 100644
--- a/package/nginx/nginx.mk
+++ b/package/nginx/nginx.mk
@@ -17,7 +17,7 @@ NGINX_CONF_OPTS = \
 	--crossbuild=Linux::$(BR2_ARCH) \
 	--with-cc="$(TARGET_CC)" \
 	--with-cpp="$(TARGET_CC)" \
-	--with-ld-opt="$(TARGET_LDFLAGS)"
+	--with-ld-opt="$(TARGET_LDFLAGS) $(NGINX_LDFLAGS)"
 
 # www-data user and group are used for nginx. Because these user and group
 # are already set by buildroot, it is not necessary to redefine them.
@@ -76,6 +76,10 @@ NGINX_CONF_ENV += ngx_force_have_libatomic=yes
 ifeq ($(BR2_sparc_v8)$(BR2_sparc_leon3),y)
 NGINX_CFLAGS += "-DAO_NO_SPARC_V9"
 endif
+# libatomic_ops uses the __atomic built-ins, which may need libatomic
+ifeq ($(BR2_TOOLCHAIN_HAS_LIBATOMIC),y)
+NGINX_LDFLAGS += -latomic
+endif
 else
 NGINX_CONF_ENV += ngx_force_have_libatomic=no
 endif
-- 
2.53.0

_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

      reply	other threads:[~2026-11-23 22:14 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-08-04 11:20 [Buildroot] [PATCH] package/nginx: fix sparc compile Waldemar Brodkorb
2024-08-04 21:12 ` Thomas Petazzoni via buildroot
2024-08-05  7:24   ` Waldemar Brodkorb
2024-08-05  7:31     ` Thomas Petazzoni via buildroot
2026-09-07  8:43       ` Thomas Petazzoni via buildroot
2026-09-08 16:05         ` Waldemar Brodkorb
2026-11-23 22:14           ` Angelo Compagnucci [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261123221427.4028223-1-angelo.compagnucci@gmail.com \
    --to=angelo.compagnucci@gmail.com \
    --cc=buildroot@buildroot.org \
    --cc=thomas.petazzoni@bootlin.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox