Buildroot Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [Buildroot] [PATCH] package/nginx: fix sparc compile
@ 2024-08-04 11:20 Waldemar Brodkorb
  2024-08-04 21:12 ` Thomas Petazzoni via buildroot
  0 siblings, 1 reply; 4+ messages in thread
From: Waldemar Brodkorb @ 2024-08-04 11:20 UTC (permalink / raw)
  To: buildroot

When libatomic_ops are enabled the shared library is using symbols
from libatomic.

In output/build/nginx-1.24.0/objs/autoconf.err
You get:
checking for atomic_ops library

/home/wbx/buildroot/output/host/lib/gcc/sparc-buildroot-linux-uclibc/13.3.0/../../../../sparc-buildroot-linux-uclibc/bin/ld:
/tmp/ccx4rHjO.o: in function `main':
autotest.c:(.text.startup+0x30): undefined reference to
`__atomic_fetch_add_4'
collect2: error: ld returned 1 exit status

Fixes:
 - http://autobuild.buildroot.net/results/5de/5de45530bbc615b1c44cc73a0ae7bf4cff5f1a56/

Signed-off-by: Waldemar Brodkorb <wbx@openadk.org>
---
 package/nginx/nginx.mk | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/package/nginx/nginx.mk b/package/nginx/nginx.mk
index 7bd2173b48..c462c1f265 100644
--- a/package/nginx/nginx.mk
+++ b/package/nginx/nginx.mk
@@ -75,6 +75,7 @@ NGINX_CONF_OPTS += --with-libatomic
 NGINX_CONF_ENV += ngx_force_have_libatomic=yes
 ifeq ($(BR2_sparc_v8)$(BR2_sparc_leon3),y)
 NGINX_CFLAGS += "-DAO_NO_SPARC_V9"
+NGINX_LDFLAGS += -latomic
 endif
 else
 NGINX_CONF_ENV += ngx_force_have_libatomic=no
@@ -300,7 +301,8 @@ define NGINX_CONFIGURE_CMDS
 	cd $(@D) ; $(NGINX_CONF_ENV) \
 		PKG_CONFIG="$(PKG_CONFIG_HOST_BINARY)" \
 		./configure $(NGINX_CONF_OPTS) \
-			--with-cc-opt="$(TARGET_CFLAGS) $(NGINX_CFLAGS)"
+			--with-cc-opt="$(TARGET_CFLAGS) $(NGINX_CFLAGS)" \
+			--with-ld-opt="$(NGINX_LDFLAGS)"
 endef
 
 define NGINX_BUILD_CMDS
-- 
2.30.2

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

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [Buildroot] [PATCH] package/nginx: fix sparc compile
  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
  0 siblings, 1 reply; 4+ messages in thread
From: Thomas Petazzoni via buildroot @ 2024-08-04 21:12 UTC (permalink / raw)
  To: Waldemar Brodkorb; +Cc: buildroot

On Sun, 4 Aug 2024 13:20:18 +0200
Waldemar Brodkorb <wbx@openadk.org> wrote:

> When libatomic_ops are enabled the shared library is using symbols
> from libatomic.
> 
> In output/build/nginx-1.24.0/objs/autoconf.err
> You get:
> checking for atomic_ops library
> 
> /home/wbx/buildroot/output/host/lib/gcc/sparc-buildroot-linux-uclibc/13.3.0/../../../../sparc-buildroot-linux-uclibc/bin/ld:
> /tmp/ccx4rHjO.o: in function `main':
> autotest.c:(.text.startup+0x30): undefined reference to
> `__atomic_fetch_add_4'
> collect2: error: ld returned 1 exit status
> 
> Fixes:
>  - http://autobuild.buildroot.net/results/5de/5de45530bbc615b1c44cc73a0ae7bf4cff5f1a56/

Do you have a minimal reproducer for this issue?

>  NGINX_CONF_ENV += ngx_force_have_libatomic=yes
>  ifeq ($(BR2_sparc_v8)$(BR2_sparc_leon3),y)
>  NGINX_CFLAGS += "-DAO_NO_SPARC_V9"
> +NGINX_LDFLAGS += -latomic
>  endif

Basically, I am wondering if this is the correct condition to put this.
Other architecture than SPARC may need to link against libatomic. So
perhaps it should instead be:

ifeq ($(BR2_TOOLCHAIN_HAS_LIBATOMIC),y)
NGINX_LDFLAGS += -latomic
endif

but as I am not 100% sure, I wanted to first reproduce the issue.

Thomas
-- 
Thomas Petazzoni, co-owner and CEO, Bootlin
Embedded Linux and Kernel engineering and training
https://bootlin.com
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Buildroot] [PATCH] package/nginx: fix sparc compile
  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
  0 siblings, 1 reply; 4+ messages in thread
From: Waldemar Brodkorb @ 2024-08-05  7:24 UTC (permalink / raw)
  To: Thomas Petazzoni; +Cc: buildroot

Hi Thomas,
Thomas Petazzoni wrote,

> On Sun, 4 Aug 2024 13:20:18 +0200
> Waldemar Brodkorb <wbx@openadk.org> wrote:
> 
> > When libatomic_ops are enabled the shared library is using symbols
> > from libatomic.
> > 
> > In output/build/nginx-1.24.0/objs/autoconf.err
> > You get:
> > checking for atomic_ops library
> > 
> > /home/wbx/buildroot/output/host/lib/gcc/sparc-buildroot-linux-uclibc/13.3.0/../../../../sparc-buildroot-linux-uclibc/bin/ld:
> > /tmp/ccx4rHjO.o: in function `main':
> > autotest.c:(.text.startup+0x30): undefined reference to
> > `__atomic_fetch_add_4'
> > collect2: error: ld returned 1 exit status
> > 
> > Fixes:
> >  - http://autobuild.buildroot.net/results/5de/5de45530bbc615b1c44cc73a0ae7bf4cff5f1a56/
> 
> Do you have a minimal reproducer for this issue?
> 
> >  NGINX_CONF_ENV += ngx_force_have_libatomic=yes
> >  ifeq ($(BR2_sparc_v8)$(BR2_sparc_leon3),y)
> >  NGINX_CFLAGS += "-DAO_NO_SPARC_V9"
> > +NGINX_LDFLAGS += -latomic
> >  endif
> 
> Basically, I am wondering if this is the correct condition to put this.
> Other architecture than SPARC may need to link against libatomic. So
> perhaps it should instead be:
> 
> ifeq ($(BR2_TOOLCHAIN_HAS_LIBATOMIC),y)
> NGINX_LDFLAGS += -latomic
> endif
> 
> but as I am not 100% sure, I wanted to first reproduce the issue.

The minimal reproducer is:
BR2_sparc=y
BR2_PACKAGE_NGINX=y

For sparc only libatomic_ops is selected via
package/nginx/Config.in. So I think the build issue is unique to
sparcv8/leon.

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

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Buildroot] [PATCH] package/nginx: fix sparc compile
  2024-08-05  7:24   ` Waldemar Brodkorb
@ 2024-08-05  7:31     ` Thomas Petazzoni via buildroot
  0 siblings, 0 replies; 4+ messages in thread
From: Thomas Petazzoni via buildroot @ 2024-08-05  7:31 UTC (permalink / raw)
  To: Waldemar Brodkorb; +Cc: buildroot

On Mon, 5 Aug 2024 09:24:49 +0200
Waldemar Brodkorb <wbx@openadk.org> wrote:

> The minimal reproducer is:
> BR2_sparc=y
> BR2_PACKAGE_NGINX=y

Weird, I didn't reproduce it with the Bootlin SPARC toolchain.

> For sparc only libatomic_ops is selected via
> package/nginx/Config.in. So I think the build issue is unique to
> sparcv8/leon.

Correct, but in the .mk file we have:

ifeq ($(BR2_PACKAGE_LIBATOMIC_OPS),y)
NGINX_DEPENDENCIES += libatomic_ops
NGINX_CONF_OPTS += --with-libatomic
NGINX_CONF_ENV += ngx_force_have_libatomic=yes
ifeq ($(BR2_sparc_v8)$(BR2_sparc_leon3),y)
NGINX_CFLAGS += "-DAO_NO_SPARC_V9"
endif
else
NGINX_CONF_ENV += ngx_force_have_libatomic=no
endif

and BR2_PACKAGE_LIBATOMIC_OPS can very well be enabled on non-SPARC
architectures. Yes nginx only forces BR2_PACKAGE_LIBATOMIC_OPS on
Sparc, but nothing prevents another package (or even the user) to
enable BR2_PACKAGE_LIBATOMIC_OPS on non-Sparc architectures.

Thomas
-- 
Thomas Petazzoni, co-owner and CEO, Bootlin
Embedded Linux and Kernel engineering and training
https://bootlin.com
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2024-08-05  7:31 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox