From aa327348768581165f6952b89f1800b87e4dbdd9 Mon Sep 17 00:00:00 2001 From: Joel Winarske Date: Wed, 2 Sep 2026 09:53:07 -0700 Subject: [PATCH] capnproto: build position independent code The recipe produces static archives only, and does not compile them PIC, so linking capnp or kj into a shared library fails: libkj.a(exception.c++.o): relocation R_X86_64_TPOFF32 against `kj::(anonymous namespace)::threadLocalCallback' can not be used when making a shared object; local-exec is incompatible with -shared kj/exception.c++ has a file-scope thread_local, which non-PIC code compiles to the local-exec TLS model. A shared object cannot use that model, so the link fails on any consumer that puts capnp inside a .so. Debian and Fedora do not hit this because they ship shared libcapnp. Set CMAKE_POSITION_INDEPENDENT_CODE. Packaging is unchanged: still static, still no .so, no new packages and no ABI surface, only the code model differs. Backport of the same change sent for master, where the recipe is 1.5.0. Signed-off-by: Joel Winarske Signed-off-by: Anuj Mittal --- meta-oe/recipes-devtools/capnproto/capnproto_1.4.0.bb | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/meta-oe/recipes-devtools/capnproto/capnproto_1.4.0.bb b/meta-oe/recipes-devtools/capnproto/capnproto_1.4.0.bb index a42131b6e2..0c1a06698a 100644 --- a/meta-oe/recipes-devtools/capnproto/capnproto_1.4.0.bb +++ b/meta-oe/recipes-devtools/capnproto/capnproto_1.4.0.bb @@ -19,8 +19,17 @@ CXXFLAGS:append:mips = " -latomic" CXXFLAGS:append:powerpc = " -latomic" CXXFLAGS:append:riscv32 = " -latomic" +# The build produces static archives only. Compile them position independent so +# they can be linked into shared libraries; without this any consumer that does +# so fails on the thread-local in kj/exception.c++, which non-PIC code compiles +# to the local-exec TLS model: +# +# libkj.a(exception.c++.o): relocation R_X86_64_TPOFF32 against +# `kj::(anonymous namespace)::threadLocalCallback' can not be used when making +# a shared object; local-exec is incompatible with -shared EXTRA_OECMAKE += "\ -DBUILD_TESTING=OFF \ + -DCMAKE_POSITION_INDEPENDENT_CODE=ON \ " FILES:${PN}-compiler = "${bindir}"