jansson already has pkgconfig files. .la files break cross-compilation (got a powerpc failure today): libtool: link: powerpc-unknown-linux-gnu-gcc -shared -fPIC -DPIC .libs/utils.o .libs/batch.o .libs/buffer.o .libs/common.o .libs/gen.o .libs/table.o .libs/trace.o .libs/chain.o .libs/object.o .libs/rule.o .libs/set.o .libs/set_elem.o .libs/ruleset.o .libs/jansson.o .libs/udata.o .libs/expr.o .libs/expr_ops.o expr/.libs/bitwise.o expr/.libs/byteorder.o expr/.libs/cmp.o expr/.libs/range.o expr/.libs/counter.o expr/.libs/ct.o expr/.libs/data_reg.o expr/.libs/dup.o expr/.libs/exthdr.o expr/.libs/fib.o expr/.libs/fwd.o expr/.libs/limit.o expr/.libs/log.o expr/.libs/lookup.o expr/.libs/dynset.o expr/.libs/immediate.o expr/.libs/match.o expr/.libs/meta.o expr/.libs/numgen.o expr/.libs/nat.o expr/.libs/objref.o expr/.libs/payload.o expr/.libs/queue.o expr/.libs/quota.o expr/.libs/reject.o expr/.libs/rt.o expr/.libs/target.o expr/.libs/masq.o expr/.libs/redir.o expr/.libs/hash.o obj/.libs/counter.o obj/.libs/ct_helper.o obj/.libs/quota.o obj/.libs/limit.o -Wl,--as-needed -lmnl /usr/lib/libjansson.so -O2 -Wl,--version-script=./libnftnl.map -Wl,-O1 -Wl,-soname -Wl,libnftnl.so.7 -o .libs/libnftnl.so.7.0.0 /usr/lib/libjansson.so: error adding symbols: File in wrong format
The following patch makes libnftnl compile fine: diff --git a/dev-libs/jansson/jansson-2.10.ebuild b/dev-libs/jansson/jansson-2.10.ebuild index 87de9efc93f..a1249addf19 100644 --- a/dev-libs/jansson/jansson-2.10.ebuild +++ b/dev-libs/jansson/jansson-2.10.ebuild @@ -37,3 +37,11 @@ multilib_src_compile() { HTML_DOCS=( "${BUILD_DIR}"/doc/_build/html/. ) fi } + +multilib_src_install() { + default + + if ! use static-libs; then + find "${D}" -name '*.la' -delete || die + fi +}
I'm kind of confused about how this failure is occurring. Do you think you could explain this a little more? I'm still relatively new to packaging, so forgive me if this is obvious.
[sorry about the delay] No problem! This is relatively obscure case of cross-compilation failure. Tl;DR: presence of .la files forces '-ljansson' linker option to expand to /usr/lib/libjansson.so and breaks crosscompilation (native compilation is unaffected). More words: How to reproduce: I've built a cross-compiler to cross-compile libnftnl as: # crossdev -t powerpc-unknown-linux-gnu # USE=json powerpc-unknown-linux-gnu-emerge -v1 libnftnl the build fails as in comment 1. Why breakage happens: Cross-compilers are tricky because there is usually two environments to look at: 1. real root (/, amd64) 2. sysroot (/usr/powerpc-unknown-linux-gnu/, powerpc) Normally when you ask linker to find a file for you as: $ powerpc-unknown-linux-gnu-gcc ... -ljansson sysroot path is prepended to existing search paths: /usr/lib => /usr/powerpc-unknown-linux-gnu/usr/lib. Thus correct /usr/powerpc-unknown-linux-gnu/usr/lib/libjansson.so would be found. Gentoo's cross-compilers have --with-sysroot=/usr/powerpc-unknown-linux-gnu config option so above would Just Work. On the other hand if absolute path is specified: $ powerpc-unknown-linux-gnu-gcc ... /usr/lib/libjansson.so sysroot prefix is not applied and library is loaded from real root (amd64 binaries). linker complains about architecture mismatch. Now, the decision to use '-ljansson' or '/usr/lib/libjansson.so' is done by the client (libnftl in our case) via: - libtool package of autotools (preferred if by autotools .la file is present) - or pkg-config if client knows how to query pkg-config .pc files. .la and .pc files are competing mechanisms to describe library dependencies and linker command for consumers: - libtool describes it via /usr/powerpc-unknown-linux-gnu/usr/lib/libjansson.la - pkg-config describes it via /usr/powerpc-unknown-linux-gnu/usr/lib/pkgconfig/jansson.pc pkg-config happens to provide more cross-compiler friendly command: Libs: -L${libdir} -ljansson instead of libtool's absolute path: library_names='libjansson.so.4.11.0 libjansson.so.4 libjansson.so' libdir='/usr/lib' https://wiki.gentoo.org/wiki/Pkg-config has a few words on it. Why removing .la file helps: In this case jansson provides single library: libjansson.so. Thus dynamic linking using '...gcc ... -ljansson' just works with or without presence of .la files. .la files only bring in the confusion because client autotools based project tries to use .la file as a library description instead of using raw '-ljansson' or pkg-config setup. It happens automatically inside libtool wrapper. Note how -ljansson is expanded into /usr/lib/libjansson.so: $ /bin/sh ../libtool --tag=CC --mode=link powerpc-unknown-linux-gnu-gcc ... -lmnl -ljansson libtool: link: powerpc-unknown-linux-gnu-gcc -shared ...-lmnl /usr/lib/libjansson.so ... /usr/lib/libjansson.so: error adding symbols: File in wrong format libtool has some support for sysroot as well. But gentoo's build system does not pass required flags to libtool (as there is no generic way to do it). Other benefits: Removal of .la files (when it does not break any clients) decreases unnecessary overlinking: https://blog.flameeyes.eu/2011/08/library-soname-bumps-and-la-files-some-visual-clues/ QA team has a chart of how to deal with .la files: https://wiki.gentoo.org/wiki/Project:Quality_Assurance/Handling_Libtool_Archives I hope that makes at least some sense :)
The bug has been closed via the following commit(s): https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=1652c10044cb2924a505186846bffbbb05ef152f commit 1652c10044cb2924a505186846bffbbb05ef152f Author: David Zero <zero-one@zer0-one.net> AuthorDate: 2018-05-06 23:47:18 +0000 Commit: Michał Górny <mgorny@gentoo.org> CommitDate: 2018-05-18 15:00:31 +0000 dev-libs/jansson: Remove libtool archives This commit adds a multilib_src_install() hook that removes any generated libtool archives. Closes: https://bugs.gentoo.org/642174 Closes: https://github.com/gentoo/gentoo/pull/8294 dev-libs/jansson/jansson-2.11.ebuild | 6 ++++++ 1 file changed, 6 insertions(+)