package/nginx: fix sparc compile
PATCH 1/1 package/nginx: fix sparc compile
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/
--- package/nginx/nginx.mk | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
package/nginx/nginx.mk +3 -1
@@ -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
Signature · 6 lines
2.30.2 _______________________________________________ buildroot mailing list [email protected] https://lists.buildroot.org/mailman/listinfo/buildroot
Quoted 7 lines · On Sun, 4 Aug 2024 13:20:18 +0200 Waldemar Brodkorb <[email protected]> wrote:
When
libatomic_opsare enabled the shared library is using symbols from libatomic.In output/build/nginx-1.24.0/objs/autoconf.err
You get:
checking foratomic_opslibrary
Quoted 8 lines
/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 statusFixes:
- http://autobuild.buildroot.net/results/5de/5de45530bbc615b1c44cc73a0ae7bf4cff5f1a56/
Do you have a minimal reproducer for this issue?
Quoted 5 lines
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
Signature · 7 lines
Thomas Petazzoni, co-owner and CEO, Bootlin Embedded Linux and Kernel engineering and training https://bootlin.com _______________________________________________ buildroot mailing list [email protected] https://lists.buildroot.org/mailman/listinfo/buildroot
Hi Thomas,
Thomas Petazzoni wrote,
Quoted 31 lines
Quoted 7 lines · On Sun, 4 Aug 2024 13:20:18 +0200 Waldemar Brodkorb <[email protected]> wrote:
When
libatomic_opsare enabled the shared library is using symbols from libatomic.In output/build/nginx-1.24.0/objs/autoconf.err
You get:
checking foratomic_opslibraryQuoted 8 lines
/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 statusFixes:
- http://autobuild.buildroot.net/results/5de/5de45530bbc615b1c44cc73a0ae7bf4cff5f1a56/Do you have a minimal reproducer for this issue?
Quoted 5 lines
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
endifBasically, 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:
Quoted 5 lines
ifeq ($(BR2_TOOLCHAIN_HAS_LIBATOMIC),y)
NGINX_LDFLAGS+= -latomic
endifbut 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
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
Quoted 3 lines · On Mon, 5 Aug 2024 09:24:49 +0200 Waldemar Brodkorb <[email protected]> wrote:
The minimal reproducer is:
BR2_sparc=y
BR2_PACKAGE_NGINX=y
Weird, I didn't reproduce it with the Bootlin SPARC toolchain.
Quoted 3 lines
For sparc only
libatomic_opsis 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_opsNGINX_CONF_OPTS += --with-libatomicNGINX_CONF_ENV += ngx_force_have_libatomic=yes
ifeq ($(BR2_sparc_v8)$(BR2_sparc_leon3),y)NGINX_CFLAGS += "-DAO_NO_SPARC_V9"
endif
elseNGINX_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
Signature · 7 lines
Thomas Petazzoni, co-owner and CEO, Bootlin Embedded Linux and Kernel engineering and training https://bootlin.com _______________________________________________ buildroot mailing list [email protected] https://lists.buildroot.org/mailman/listinfo/buildroot
Hello Waldemar,
Do you have any updates on the feedback below?
Thanks!
Thomas
Quoted 40 lines · Thomas Petazzoni via buildroot
Quoted 3 lines · On Mon, 5 Aug 2024 09:24:49 +0200 Waldemar Brodkorb <[email protected]> wrote:
The minimal reproducer is:
BR2_sparc=y
BR2_PACKAGE_NGINX=yWeird, I didn't reproduce it with the Bootlin SPARC toolchain.
Quoted 3 lines
For sparc only
libatomic_opsis 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_opsNGINX_CONF_OPTS+= --with-libatomicNGINX_CONF_ENV+= ngx_force_have_libatomic=yes
ifeq ($(BR2_sparc_v8)$(BR2_sparc_leon3),y)NGINX_CFLAGS+= "-DAO_NO_SPARC_V9"
endif
elseNGINX_CONF_ENV+= ngx_force_have_libatomic=no
endifand
BR2_PACKAGE_LIBATOMIC_OPScan very well be enabled on non-SPARC architectures. Yes nginx only forcesBR2_PACKAGE_LIBATOMIC_OPSon Sparc, but nothing prevents another package (or even the user) to enableBR2_PACKAGE_LIBATOMIC_OPSon non-Sparc architectures.Thomas
Signature · 7 lines
Thomas Petazzoni, co-owner and CEO, Bootlin Embedded Linux and Kernel engineering and training https://bootlin.com _______________________________________________ buildroot mailing list [email protected] https://lists.buildroot.org/mailman/listinfo/buildroot
Signature · 7 lines
Thomas Petazzoni, co-owner and CEO, Bootlin Embedded Linux and Kernel engineering and training https://bootlin.com _______________________________________________ buildroot mailing list [email protected] https://lists.buildroot.org/mailman/listinfo/buildroot
Hi Thomas,
Thomas Petazzoni wrote,
Quoted 3 lines
Hello Waldemar,
Do you have any updates on the feedback below?
Not really I have forgotten about it.
How should we proceed? Any patch suggestion from you?
best regards
Waldemar
_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
PATCH v2 1/1 package/nginx: fix sparc compile
From: Waldemar Brodkorb <[email protected]>
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").
---
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/[email protected]/
package/nginx/nginx.mk | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
package/nginx/nginx.mk +5 -1
@@ -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
Signature · 6 lines
2.53.0 _______________________________________________ buildroot mailing list [email protected] https://lists.buildroot.org/mailman/listinfo/buildroot