Skip to content

scanner: If using libtool with a wrapper, use libtool --mode=execute

Simon McVittie requested to merge wip/smcv/wrapper-libtool into main

The purpose of libtool's generated scripts is to automate setting the LD_LIBRARY_PATH that libtool knows is necessary to be able to find the library's dependencies. If we bypass the generated script and invoke the underlying binary directly, the LD_LIBRARY_PATH isn't set and the dependency isn't found.

Instead of working against libtool, we can work with it by turning a g-ir-scanner invocation like

g-ir-scanner \
    --use-binary-wrapper=qemu-aarch64 \
    --libtool-path="/bin/bash ./libtool" \
    ...

into a libtool invocation like:

/bin/bash ./libtool --mode=execute qemu-aarch64 /path/to/dumper

which is the same mechanism that's used to run gdb or strace on the underlying binary that is wrapped by libtool scripts. libtool will convert that into something more like the equivalent of:

LD_LIBRARY_PATH=/path/to/dependency/.libs \
qemu-aarch64 /path/to/.libs/dumper

which arranges for the dumper executable to be able to find its dependency library as intended.


Tested by cross-compiling libostree (an Autotools project) for aarch64 host on x86_64 build system, using a wrapper around g-ir-scanner which sets up --use-binary-wrapper=qemu-aarch64, --use-ldd-wrapper set to the ldd replacement from #482, an appropriate architecture-prefixed cross-CC and cross-PKG_CONFIG, and an appropriate GI_GIR_PATH.

Edited by Simon McVittie

Merge request reports