gdesmott / system-deps

Run pkg-config from declarative dependencies in Cargo.toml
Apache License 2.0
89 stars 21 forks source link

are you able to support musl based rust targets? #66

Open stefson opened 1 year ago

stefson commented 1 year ago

hey there,

it just happened that I ran into an issue compiling librsvg with a musl based armv7a toolchain. rustc is armv7a-unknown-linux-musleabihf , still I end up with this error when compiling your system-deps crate:

env RUST_BACKTRACE=1 make -j4
make  all-recursive
make[1]: Entering directory '/tmp/librsvg'
Making all in .
make[2]: Entering directory '/tmp/librsvg'
cd . &&                                                 \
PKG_CONFIG_ALLOW_CROSS=1                                                \
PKG_CONFIG='/usr/bin/pkg-config'                                                \
CARGO_TARGET_DIR=/tmp/librsvg/target                                    \
cargo --locked build   --release --lib \
&& cd /tmp/librsvg && /bin/sh ./libtool --silent --tag=CC   --mode=link gcc  -g -O2   -o librsvg_c_api.la _rsvg_dummy.lo && mv /tmp/librsvg/target/release/liblibrsvg.a .libs/librsvg_c_api.a
   Compiling librsvg v2.55.0 (/tmp/librsvg)
   Compiling selectors v0.23.0
   Compiling rayon v1.6.0
   Compiling url v2.3.1
error: failed to run custom build command for `librsvg v2.55.0 (/tmp/librsvg)`

Caused by:
  process didn't exit successfully: `/tmp/librsvg/target/release/build/librsvg-e80ec40cb3b31f0b/build-script-build` (exit status: 101)
  --- stdout
  cargo:rerun-if-env-changed=CAIRO_PDF_NO_PKG_CONFIG
  cargo:rerun-if-env-changed=PKG_CONFIG_armv7a-unknown-linux-musleabihf
  cargo:rerun-if-env-changed=PKG_CONFIG_armv7a_unknown_linux_musleabihf
  cargo:rerun-if-env-changed=HOST_PKG_CONFIG
  cargo:rerun-if-env-changed=PKG_CONFIG
  cargo:rerun-if-env-changed=PKG_CONFIG_PATH_armv7a-unknown-linux-musleabihf
  cargo:rerun-if-env-changed=PKG_CONFIG_PATH_armv7a_unknown_linux_musleabihf
  cargo:rerun-if-env-changed=HOST_PKG_CONFIG_PATH
  cargo:rerun-if-env-changed=PKG_CONFIG_PATH
  cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR_armv7a-unknown-linux-musleabihf
  cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR_armv7a_unknown_linux_musleabihf
  cargo:rerun-if-env-changed=HOST_PKG_CONFIG_LIBDIR
  cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR
  cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR_armv7a-unknown-linux-musleabihf
  cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR_armv7a_unknown_linux_musleabihf
  cargo:rerun-if-env-changed=HOST_PKG_CONFIG_SYSROOT_DIR
  cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR
  cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR
  cargo:rerun-if-env-changed=SYSROOT
  cargo:rerun-if-env-changed=PKG_CONFIG_armv7a-unknown-linux-musleabihf
  cargo:rerun-if-env-changed=PKG_CONFIG_armv7a_unknown_linux_musleabihf
  cargo:rerun-if-env-changed=HOST_PKG_CONFIG
  cargo:rerun-if-env-changed=PKG_CONFIG
  cargo:rerun-if-env-changed=PKG_CONFIG_PATH_armv7a-unknown-linux-musleabihf
  cargo:rerun-if-env-changed=PKG_CONFIG_PATH_armv7a_unknown_linux_musleabihf
  cargo:rerun-if-env-changed=HOST_PKG_CONFIG_PATH
  cargo:rerun-if-env-changed=PKG_CONFIG_PATH
  cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR_armv7a-unknown-linux-musleabihf
  cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR_armv7a_unknown_linux_musleabihf
  cargo:rerun-if-env-changed=HOST_PKG_CONFIG_LIBDIR
  cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR
  cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR_armv7a-unknown-linux-musleabihf
  cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR_armv7a_unknown_linux_musleabihf
  cargo:rerun-if-env-changed=HOST_PKG_CONFIG_SYSROOT_DIR
  cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR
  cargo:rerun-if-env-changed=CAIRO_PS_NO_PKG_CONFIG
  cargo:rerun-if-env-changed=PKG_CONFIG_armv7a-unknown-linux-musleabihf
  cargo:rerun-if-env-changed=PKG_CONFIG_armv7a_unknown_linux_musleabihf
  cargo:rerun-if-env-changed=HOST_PKG_CONFIG
  cargo:rerun-if-env-changed=PKG_CONFIG
  cargo:rerun-if-env-changed=PKG_CONFIG_PATH_armv7a-unknown-linux-musleabihf
  cargo:rerun-if-env-changed=PKG_CONFIG_PATH_armv7a_unknown_linux_musleabihf
  cargo:rerun-if-env-changed=HOST_PKG_CONFIG_PATH
  cargo:rerun-if-env-changed=PKG_CONFIG_PATH
  cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR_armv7a-unknown-linux-musleabihf
  cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR_armv7a_unknown_linux_musleabihf
  cargo:rerun-if-env-changed=HOST_PKG_CONFIG_LIBDIR
  cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR
  cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR_armv7a-unknown-linux-musleabihf
  cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR_armv7a_unknown_linux_musleabihf
  cargo:rerun-if-env-changed=HOST_PKG_CONFIG_SYSROOT_DIR
  cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR
  cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR
  cargo:rerun-if-env-changed=SYSROOT
  cargo:rerun-if-env-changed=PKG_CONFIG_armv7a-unknown-linux-musleabihf
  cargo:rerun-if-env-changed=PKG_CONFIG_armv7a_unknown_linux_musleabihf
  cargo:rerun-if-env-changed=HOST_PKG_CONFIG
  cargo:rerun-if-env-changed=PKG_CONFIG
  cargo:rerun-if-env-changed=PKG_CONFIG_PATH_armv7a-unknown-linux-musleabihf
  cargo:rerun-if-env-changed=PKG_CONFIG_PATH_armv7a_unknown_linux_musleabihf
  cargo:rerun-if-env-changed=HOST_PKG_CONFIG_PATH
  cargo:rerun-if-env-changed=PKG_CONFIG_PATH
  cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR_armv7a-unknown-linux-musleabihf
  cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR_armv7a_unknown_linux_musleabihf
  cargo:rerun-if-env-changed=HOST_PKG_CONFIG_LIBDIR
  cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR
  cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR_armv7a-unknown-linux-musleabihf
  cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR_armv7a_unknown_linux_musleabihf
  cargo:rerun-if-env-changed=HOST_PKG_CONFIG_SYSROOT_DIR
  cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR
  cargo:rerun-if-env-changed=CAIRO_SVG_NO_PKG_CONFIG
  cargo:rerun-if-env-changed=PKG_CONFIG_armv7a-unknown-linux-musleabihf
  cargo:rerun-if-env-changed=PKG_CONFIG_armv7a_unknown_linux_musleabihf
  cargo:rerun-if-env-changed=HOST_PKG_CONFIG
  cargo:rerun-if-env-changed=PKG_CONFIG
  cargo:rerun-if-env-changed=PKG_CONFIG_PATH_armv7a-unknown-linux-musleabihf
  cargo:rerun-if-env-changed=PKG_CONFIG_PATH_armv7a_unknown_linux_musleabihf
  cargo:rerun-if-env-changed=HOST_PKG_CONFIG_PATH
  cargo:rerun-if-env-changed=PKG_CONFIG_PATH
  cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR_armv7a-unknown-linux-musleabihf
  cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR_armv7a_unknown_linux_musleabihf
  cargo:rerun-if-env-changed=HOST_PKG_CONFIG_LIBDIR
  cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR
  cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR_armv7a-unknown-linux-musleabihf
  cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR_armv7a_unknown_linux_musleabihf
  cargo:rerun-if-env-changed=HOST_PKG_CONFIG_SYSROOT_DIR
  cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR
  cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR
  cargo:rerun-if-env-changed=SYSROOT
  cargo:rerun-if-env-changed=PKG_CONFIG_armv7a-unknown-linux-musleabihf
  cargo:rerun-if-env-changed=PKG_CONFIG_armv7a_unknown_linux_musleabihf
  cargo:rerun-if-env-changed=HOST_PKG_CONFIG
  cargo:rerun-if-env-changed=PKG_CONFIG
  cargo:rerun-if-env-changed=PKG_CONFIG_PATH_armv7a-unknown-linux-musleabihf
  cargo:rerun-if-env-changed=PKG_CONFIG_PATH_armv7a_unknown_linux_musleabihf
  cargo:rerun-if-env-changed=HOST_PKG_CONFIG_PATH
  cargo:rerun-if-env-changed=PKG_CONFIG_PATH
  cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR_armv7a-unknown-linux-musleabihf
  cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR_armv7a_unknown_linux_musleabihf
  cargo:rerun-if-env-changed=HOST_PKG_CONFIG_LIBDIR
  cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR
  cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR_armv7a-unknown-linux-musleabihf
  cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR_armv7a_unknown_linux_musleabihf
  cargo:rerun-if-env-changed=HOST_PKG_CONFIG_SYSROOT_DIR
  cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR

  --- stderr
  thread 'main' panicked at 'Invalid TARGET: armv7a-unknown-linux-musleabihf', /root/.cargo/registry/src/github.com-1285ae84e5963aae/system-deps-6.0.3/src/lib.rs:807:32
  stack backtrace:
     0: rust_begin_unwind
     1: core::panicking::panic_fmt
     2: system_deps::Config::check_cfg::{{closure}}
     3: core::option::Option<T>::unwrap_or_else
     4: system_deps::Config::check_cfg
     5: system_deps::Config::probe_pkg_config
     6: system_deps::Config::probe_full
     7: system_deps::Config::probe
     8: build_script_build::main
     9: core::ops::function::FnOnce::call_once
  note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
warning: build failed, waiting for other jobs to finish...
make[2]: *** [Makefile:1554: librsvg_c_api.la] Error 101
make[2]: Leaving directory '/tmp/librsvg'
make[1]: *** [Makefile:1077: all-recursive] Error 1
make[1]: Leaving directory '/tmp/librsvg'
make: *** [Makefile:712: all] Error 2

Can you maybe improve the target detection, to allow for musleabihf instead of gnueabihf?

gdesmott commented 1 year ago

This is handled by the cfg-expr crate.

It seems get_builtin_target_by_triple() does not recognize your target so I'd suggest to report this problem there.