[Buildroot] [PATCH v6 3/6] package/pocketpy: link with libatomic

Dario Binacchi <[email protected]>
Newsgroups net.busybox.buildroot
Message-ID <[email protected]>
pocketpy uses C11 atomics, which require libatomic on architectures
where GCC does not provide native support, such as sparc.

The missing symbols are only exposed when linking an executable against
libpocketpy.so, so the issue is not detected by `test-pkg` when testing
pocketpy alone.

Indeed, in my use case, which was integrating the canopenterm package
into Buildroot, running:

  $ utils/test-pkg -p canopenterm -c canopenterm.config -T bootlin-sparc-uclibc

raised the following error:

  ld: .../sysroot/usr/lib/libpocketpy.so: undefined reference to `__atomic_fetch_sub_4'
  ld: .../sysroot/usr/lib/libpocketpy.so: undefined reference to `__atomic_fetch_add_4'
  collect2: error: ld returned 1 exit status

Signed-off-by: Dario Binacchi <[email protected]>
---
 package/pocketpy/pocketpy.mk | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/package/pocketpy/pocketpy.mk b/package/pocketpy/pocketpy.mk
index 23789dd62028..c738e21855a7 100644
--- a/package/pocketpy/pocketpy.mk
+++ b/package/pocketpy/pocketpy.mk
@@ -12,6 +12,14 @@ POCKETPY_INSTALL_STAGING = YES
 
 POCKETPY_CONF_OPTS = -DPK_BUILD_SHARED_LIB=ON
 
+# pocketpy uses C11 atomics, which on some architectures are provided by
+# libatomic
+ifeq ($(BR2_TOOLCHAIN_HAS_LIBATOMIC),y)
+POCKETPY_CONF_OPTS += \
+	-DCMAKE_EXE_LINKER_FLAGS=-latomic \
+	-DCMAKE_SHARED_LINKER_FLAGS=-latomic
+endif
+
 define POCKETPY_INSTALL_TARGET_CMDS
 	$(INSTALL) -D -m 0755 $(@D)/libpocketpy.so* $(TARGET_DIR)/usr/lib
 endef
-- 
2.43.0

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.