Discussion:
Bug#1098791: kicad: Please include patch to link against libatomic on powerpc
Add Reply
John Paul Adrian Glaubitz
2025-02-24 09:10:02 UTC
Reply
Permalink
Source: kicad
Version: 9.0.0+dfsg-1
Severity: normal
Tags: patch
User: debian-***@lists.debian.org
Usertags: powerpc
X-Debbugs-Cc: debian-***@lists.debian.org

Hi,

src:kicad currently fails to build from source due to missing linking against libatomic:

[ 34%] Linking CXX executable bitmap2component
cd /build/reproducible-path/kicad-9.0.0+dfsg/debian/build/bitmap2component && /usr/bin/cmake -E cmake_link_script CMakeFiles/bitmap2component.dir/link.txt --verbose=1
/usr/bin/ld: ../common/libcommon.a(wx_view_controls.cpp.o): undefined reference to symbol '__atomic_fetch_add_8@@LIBATOMIC_1.0'
/usr/bin/ld: /lib/powerpc-linux-gnu/libatomic.so.1: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status

This can be fixed by patching debian/rules to append -latomic to DEB_LDFLAGS_MAINT_APPEND:

--- debian/rules.orig 2025-02-23 07:00:36.000000000 -0800
+++ debian/rules 2025-02-23 22:43:58.488539668 -0800
@@ -9,6 +9,11 @@
CFLAGS+=$(CPPFLAGS)
CXXFLAGS+=$(CPPFLAGS)

+# workaround for https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81358
+ifneq (,$(filter $(DEB_HOST_ARCH), armel m68k powerpc sh4))
+export DEB_LDFLAGS_MAINT_APPEND += -Wl,--no-as-needed -latomic -Wl,--as-needed
+endif
+
# out of tree build folder for kicad application
DEB_BUILD_DIR=debian/build
# default install folder

Please see the attached patch. I have also included armel, m68k and sh4 in the
architecture list as this should also be necessary on these architectures.

PS: Would be nice if kicad could be built for any architecture.

Thanks,
Adrian

--
.''`. John Paul Adrian Glaubitz
: :' : Debian Developer
`. `' Physicist
`- GPG: 62FF 8A75 84E0 2956 9546 0006 7426 3B37 F5B5 F913
Simon Richter
2025-02-24 10:50:01 UTC
Reply
Permalink
Hi,
Post by John Paul Adrian Glaubitz
+export DEB_LDFLAGS_MAINT_APPEND += -Wl,--no-as-needed -latomic -Wl,--as-needed
That smells wrong, there should be no need for --no-as-needed, and
without that, this can just be linked unconditionally everywhere.

It should be fixed upstream though, by making libatomic a PUBLIC
dependency of libcommon.
Post by John Paul Adrian Glaubitz
Please see the attached patch. I have also included armel, m68k and sh4 in the
architecture list as this should also be necessary on these architectures.
Probably also riscv.
Post by John Paul Adrian Glaubitz
PS: Would be nice if kicad could be built for any architecture.
The main problem would probably be below "thirdparty/libcontext", which
has some assembler code.

Simon
John Paul Adrian Glaubitz
2025-02-24 11:10:01 UTC
Reply
Permalink
Post by Simon Richter
Hi,
Post by John Paul Adrian Glaubitz
+export DEB_LDFLAGS_MAINT_APPEND += -Wl,--no-as-needed -latomic -Wl,--as-needed
That smells wrong, there should be no need for --no-as-needed, and
without that, this can just be linked unconditionally everywhere.
It's commonly used across Debian like that. But feel free to adjust the
flags to suit your own preferences. I'm just suggesting a patch that is
known to work and that I have verified on powerpc (perotto.debian.net).
Post by Simon Richter
It should be fixed upstream though, by making libatomic a PUBLIC
dependency of libcommon.
I fully agree.
Post by Simon Richter
Post by John Paul Adrian Glaubitz
Please see the attached patch. I have also included armel, m68k and sh4 in the
architecture list as this should also be necessary on these architectures.
Probably also riscv.
Post by John Paul Adrian Glaubitz
PS: Would be nice if kicad could be built for any architecture.
The main problem would probably be below "thirdparty/libcontext", which
has some assembler code.
Okay, fair enough. I will look into adding sparc64 in the future then as it's
actually supported even by Kicad's libcontext fork [1].

Adrian
Post by Simon Richter
[1] https://github.com/twlostow/libcontext
--
.''`. John Paul Adrian Glaubitz
: :' : Debian Developer
`. `' Physicist
`- GPG: 62FF 8A75 84E0 2956 9546 0006 7426 3B37 F5B5 F913
Loading...