Skip to content

xx-cargo fails with crates using pkg-config in build scripts #107

@jprendes

Description

@jprendes

The following Dockerfile fails to build when target platform != build platform:

# syntax=docker/dockerfile:1
FROM --platform=$BUILDPLATFORM tonistiigi/xx:1.2.1 AS xx
FROM --platform=$BUILDPLATFORM rust:1.69.0 AS base
COPY --from=xx / /
RUN apt-get update -y && apt-get install --no-install-recommends -y clang pkg-config dpkg-dev
WORKDIR /work
ARG TARGETPLATFORM
RUN xx-apt-get install -y gcc libdbus-1-dev
RUN xx-cargo install dbus --example client --root /usr/local
RUN xx-verify /usr/local/bin/client

Building on an amd64 machine with

docker buildx build --platform=linux/arm64 .

results in the following error

#0 70.24   --- stderr
#0 70.24   pkg_config failed: pkg-config has not been configured to support cross-compilation.
#0 70.24 
#0 70.24   Install a sysroot for the target platform and configure it via
#0 70.24   PKG_CONFIG_SYSROOT_DIR and PKG_CONFIG_PATH, or install a
#0 70.24   cross-compiling wrapper for pkg-config and set it via
#0 70.24   PKG_CONFIG environment variable.
#0 70.24   One possible solution is to check whether packages
#0 70.24   'libdbus-1-dev' and 'pkg-config' are installed:
#0 70.24   On Ubuntu:
#0 70.24   sudo apt install libdbus-1-dev pkg-config
#0 70.24   On Fedora:
#0 70.24   sudo dnf install dbus-devel pkgconf-pkg-config
#0 70.24 
#0 70.24   thread 'main' panicked at 'explicit panic', /usr/local/cargo/registry/src/git.colasdn.top-1ecc6299db9ec823/libdbus-sys-0.2.5/build.rs:25:9
#0 70.24   note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions