I had a go using cross-rs (which is wonderful so far!) to build a binary rust crate which depends on the fuser crate (https://crates.io/crates/fuser). I'm targeting FreeBSD whilst using a Linux host. The fuser crate has some dependencies when building on FreeBSD:
pkg install fusefs-libs pkgconf
This is handled nicely in the Cross.toml file:
[target.x86_64-unknown-freebsd]
# Install these build time dependencies.
pre-build = ["""
bash -c ". /freebsd-install.sh && install_freebsd_package pkgconf fusefs-libs"
"""]
When I come to build my binary crate I hit an issue relating to the finding of the fuse library:
$ cross build --target x86_64-unknown-freebsd
[+] Building 3.9s (6/6) FINISHED docker:default
=> [internal] load build definition from Dockerfile.x86_64-unkno 0.0s
=> => transferring dockerfile: 241B 0.0s
=> [internal] load .dockerignore 0.0s
=> => transferring context: 2B 0.0s
=> [internal] load metadata for ghcr.io/cross-rs/x86_64-unknown- 0.7s
=> CACHED [1/2] FROM ghcr.io/cross-rs/x86_64-unknown-freebsd:mai 0.0s
=> [2/2] RUN eval "bash -c ". /freebsd-install.sh && install_fre 3.2s
=> exporting to image 0.0s
=> => exporting layers 0.0s
=> => writing image sha256:e7f897516143667e72c175b06dafee59fdd72 0.0s
=> => naming to localhost/cross-rs/cross-custom-crfs:x86_64-unkn 0.0s
Compiling fuser v0.13.0
error: failed to run custom build command for `fuser v0.13.0`
Caused by:
process didn't exit successfully: `/target/debug/build/fuser-b92eb39599dcea98/build-script-build` (exit status: 101)
--- stdout
cargo:rerun-if-env-changed=FUSE3_NO_PKG_CONFIG
cargo:rerun-if-env-changed=PKG_CONFIG_ALLOW_CROSS_x86_64-unknown-freebsd
cargo:rerun-if-env-changed=PKG_CONFIG_ALLOW_CROSS_x86_64_unknown_freebsd
cargo:rerun-if-env-changed=TARGET_PKG_CONFIG_ALLOW_CROSS
cargo:rerun-if-env-changed=PKG_CONFIG_ALLOW_CROSS
cargo:rerun-if-env-changed=PKG_CONFIG_x86_64-unknown-freebsd
cargo:rerun-if-env-changed=PKG_CONFIG_x86_64_unknown_freebsd
cargo:rerun-if-env-changed=TARGET_PKG_CONFIG
cargo:rerun-if-env-changed=PKG_CONFIG
cargo:rerun-if-env-changed=FUSE3_STATIC
cargo:rerun-if-env-changed=FUSE3_DYNAMIC
cargo:rerun-if-env-changed=PKG_CONFIG_ALL_STATIC
cargo:rerun-if-env-changed=PKG_CONFIG_ALL_DYNAMIC
cargo:rerun-if-env-changed=PKG_CONFIG_PATH_x86_64-unknown-freebsd
cargo:rerun-if-env-changed=PKG_CONFIG_PATH_x86_64_unknown_freebsd
cargo:rerun-if-env-changed=TARGET_PKG_CONFIG_PATH
cargo:rerun-if-env-changed=PKG_CONFIG_PATH
cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR_x86_64-unknown-freebsd
cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR_x86_64_unknown_freebsd
cargo:rerun-if-env-changed=TARGET_PKG_CONFIG_LIBDIR
cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR
cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR_x86_64-unknown-freebsd
cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR_x86_64_unknown_freebsd
cargo:rerun-if-env-changed=TARGET_PKG_CONFIG_SYSROOT_DIR
cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR
cargo:rerun-if-env-changed=FUSE_NO_PKG_CONFIG
cargo:rerun-if-env-changed=PKG_CONFIG_ALLOW_CROSS_x86_64-unknown-freebsd
cargo:rerun-if-env-changed=PKG_CONFIG_ALLOW_CROSS_x86_64_unknown_freebsd
cargo:rerun-if-env-changed=TARGET_PKG_CONFIG_ALLOW_CROSS
cargo:rerun-if-env-changed=PKG_CONFIG_ALLOW_CROSS
cargo:rerun-if-env-changed=PKG_CONFIG_x86_64-unknown-freebsd
cargo:rerun-if-env-changed=PKG_CONFIG_x86_64_unknown_freebsd
cargo:rerun-if-env-changed=TARGET_PKG_CONFIG
cargo:rerun-if-env-changed=PKG_CONFIG
cargo:rerun-if-env-changed=FUSE_STATIC
cargo:rerun-if-env-changed=FUSE_DYNAMIC
cargo:rerun-if-env-changed=PKG_CONFIG_ALL_STATIC
cargo:rerun-if-env-changed=PKG_CONFIG_ALL_DYNAMIC
cargo:rerun-if-env-changed=PKG_CONFIG_PATH_x86_64-unknown-freebsd
cargo:rerun-if-env-changed=PKG_CONFIG_PATH_x86_64_unknown_freebsd
cargo:rerun-if-env-changed=TARGET_PKG_CONFIG_PATH
cargo:rerun-if-env-changed=PKG_CONFIG_PATH
cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR_x86_64-unknown-freebsd
cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR_x86_64_unknown_freebsd
cargo:rerun-if-env-changed=TARGET_PKG_CONFIG_LIBDIR
cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR
cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR_x86_64-unknown-freebsd
cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR_x86_64_unknown_freebsd
cargo:rerun-if-env-changed=TARGET_PKG_CONFIG_SYSROOT_DIR
cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR
--- stderr
`PKG_CONFIG_ALLOW_SYSTEM_CFLAGS="1" PKG_CONFIG_ALLOW_SYSTEM_LIBS="1" "pkg-config" "--libs" "--cflags" "fuse3" "fuse3 >= 3.0.0"` did not exit successfully: exit status: 1
error: could not find system library 'fuse3' required by the 'fuser' crate
--- stderr
Package fuse3 was not found in the pkg-config search path.
Perhaps you should add the directory containing `fuse3.pc'
to the PKG_CONFIG_PATH environment variable
No package 'fuse3' found
Package fuse3 was not found in the pkg-config search path.
Perhaps you should add the directory containing `fuse3.pc'
to the PKG_CONFIG_PATH environment variable
No package 'fuse3' found
`PKG_CONFIG_ALLOW_SYSTEM_CFLAGS="1" PKG_CONFIG_ALLOW_SYSTEM_LIBS="1" "pkg-config" "--libs" "--cflags" "fuse" "fuse >= 2.6.0"` did not exit successfully: exit status: 1
error: could not find system library 'fuse' required by the 'fuser' crate
--- stderr
Package fuse was not found in the pkg-config search path.
Perhaps you should add the directory containing `fuse.pc'
to the PKG_CONFIG_PATH environment variable
No package 'fuse' found
Package fuse was not found in the pkg-config search path.
Perhaps you should add the directory containing `fuse.pc'
to the PKG_CONFIG_PATH environment variable
No package 'fuse' found
thread 'main' panicked at /home/peter/.cargo/registry/src/index.crates.io-6f17d22bba15001f/fuser-0.13.0/build.rs:41:22:
called `Result::unwrap()` on an `Err` value: ()
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
$
Which is odd given than pkgconf successfully installed thanks to the pre-build hook.
After some investigation I found that PKG_CONFIG_PATH is not set in the FreeBSD Dockerfile (it is set in all the other target docker files).
It all seems to work. I'll send a PR for this change, though am cautious in case there is something I'm doing wrong here in terms of my use of cross-rs.
Thanks!
Peter
What target(s) are you cross-compiling for?
FreeBSD x86_64
Which operating system is the host (e.g computer cross is on) running?
[ ] macOS
[ ] Windows
[X] Linux / BSD
[ ] other OS (specify in description)
What architecture is the host?
[X] x86_64 / AMD64
[ ] arm32
[ ] arm64 (including Mac M1)
What container engine is cross using?
[X] docker
[ ] podman
[ ] other container engine (specify in description)
Checklist
Describe your issue
Hello,
I had a go using cross-rs (which is wonderful so far!) to build a binary rust crate which depends on the fuser crate (https://crates.io/crates/fuser). I'm targeting FreeBSD whilst using a Linux host. The fuser crate has some dependencies when building on FreeBSD:
This is handled nicely in the Cross.toml file:
When I come to build my binary crate I hit an issue relating to the finding of the fuse library:
Which is odd given than pkgconf successfully installed thanks to the pre-build hook.
After some investigation I found that PKG_CONFIG_PATH is not set in the FreeBSD Dockerfile (it is set in all the other target docker files).
After adding this entry:
It all seems to work. I'll send a PR for this change, though am cautious in case there is something I'm doing wrong here in terms of my use of cross-rs.
Thanks! Peter
What target(s) are you cross-compiling for?
FreeBSD x86_64
Which operating system is the host (e.g computer cross is on) running?
What architecture is the host?
What container engine is cross using?
cross version
cross 0.2.5 (666344e 2023-12-14)
Example
No response
Additional information / notes
No response