blob: 6d93eb5ec7aa17d6e134c10ed551f818663ead2a [file] [log] [blame]
#!/bin/bash
# Copyright 2021 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
# Wrapper for `ldd` in cross-compilation situations.
#
# gobject-introspection uses `ldd` to inspect the dynamically linked
# dependencies of small binaries it compiles during its build process, but doing
# so requires executing the dynamic loader for that target. This is typically
# not possible in a cross-compilation environment so chromite provides a pure
# Python script that mimics the interface of `ldd` for inspecting dynamically
# linked dependencies.
#
# We explicitly pass $SYSROOT as the "root" argument so that `lddtree` knows to
# look for all dependencies in the build target's sysroot.
# We also pass the --no-auto-root option so that `lddtree` won't implicitly add
# the provided root as a prefix to all paths passed as arguments, otherwise
# paths would end up doubly-prefixed, e.g.
# '/build/$board/build/$board/usr/lib/foo'.
"${CHROMITE_BIN_DIR}"/lddtree \
-R "${SYSROOT}" \
--no-auto-root \
"${@}"