cross-rs/cross

`cross-util run` can't access the file in host FS if there is symlink in the file's path

art-den opened this issue · 2 comments

Checklist

Describe your issue

My project's target directory is symlink to ramdisk folder

sudo mkdir /mnt/ramdisk/target_astralite
sudo chmod 777 /mnt/ramdisk/target_astralite
ln -s /mnt/ramdisk/target_astralite /home/denis/Projects/astra_lite/target

I have no problem with building project by cross build. After successful cross build I execute

cross-util run --target x86_64-unknown-linux-gnu -- "stat /home/denis/Projects/astra_lite/target/x86_64-unknown-linux-gnu/release/astra_lite"

and I got error

stat: cannot stat '/home/denis/Projects/astra_lite/target/x86_64-unknown-linux-gnu/release/astra_lite': No such file or directory

If to run stat /home/denis/Projects/astra_lite/target/x86_64-unknown-linux-gnu/release/astra_lite directly everything is Ok:

  File: /home/denis/Projects/astra_lite/target/x86_64-unknown-linux-gnu/release/astra_lite
  Size: 8113112   	Blocks: 15848      IO Block: 4096   regular file
Device: 24h/36d	Inode: 32653       Links: 2
Access: (0755/-rwxr-xr-x)  Uid: ( 1000/   denis)   Gid: ( 1000/   denis)
Access: 2024-02-04 13:13:19.643710959 +0500
Modify: 2024-02-04 13:13:19.651710791 +0500
Change: 2024-02-04 13:13:19.695709875 +0500
 Birth: 2024-02-04 13:13:19.403715962 +0500

PS: and I have no problems at all if target directory is not symlink

What target(s) are you cross-compiling for?

No response

Which operating system is the host (e.g computer cross is on) running?

  • macOS
  • Windows
  • Linux / BSD
  • other OS (specify in description)

What architecture is the host?

  • x86_64 / AMD64
  • arm32
  • arm64 (including Mac M1)

What container engine is cross using?

  • docker
  • podman
  • other container engine (specify in description)

cross version

cross 0.2.5 (db4761b 2024-01-31)

Example

No response

Additional information / notes

No response

can you post the full build logs, preferably with -v added for more verbosity

I think you need to do

# Cross.toml
[build.env]
volumes = ["_T=/mnt/ramdisk/target_astralite"]

If you mount the target dir in docker, can the container stat the executable? I suspect not, docker doesn't follow symlinks.

docker run --rm -v /home/denis/Projects/astra_lite/target/x86_64-unknown-linux-gnu/release/astra_lite:/home/denis/Projects/astra_lite/target/x86_64-unknown-linux-gnu/release/astra_lite-it ubuntu:20.04 ls -la /home/denis/Projects/astra_lite/

The output for command

denis@denis-xubuntu:~/Projects/astra_lite$ cross-util -v run --target x86_64-unknown-linux-gnu -- "stat /home/denis/Projects/astra_lite/target/x86_64-unknown-linux-gnu/release/astra_lite"

is

+ /usr/bin/podman
+ /usr/bin/podman version -f '{{ .Server.Os }},,,{{ .Server.Arch }}'
+ /usr/bin/podman info -f '{{ .Version.OsArch }}'
+ cargo metadata --format-version 1 --filter-platform x86_64-unknown-linux-gnu
+ rustc --print sysroot
+ /usr/bin/podman
+ /usr/bin/podman version -f '{{ .Server.Os }},,,{{ .Server.Arch }}'
+ /usr/bin/podman info -f '{{ .Version.OsArch }}'
+ /usr/bin/podman buildx build --progress auto --label 'org.cross-rs.for-cross-target=x86_64-unknown-linux-gnu' --label 'org.cross-rs.runs-with=x86_64-unknown-linux-gnu' --label 'org.cross-rs.workspace_root=/home/denis/Projects/astra_lite' --tag localhost/cross-rs/cross-custom-astra_lite:x86_64-unknown-linux-gnu-5f8ae-pre-build --build-arg 'CROSS_CMD=dpkg --add-architecture $CROSS_DEB_ARCH
apt-get update
DEBIAN_FRONTEND=noninteractive TZ=Etc/UTC apt-get -y install tzdata
apt-get install -y libgtk-3-dev:$CROSS_DEB_ARCH dpkg dpkg-dev' --build-arg 'CROSS_DEB_ARCH=amd64' --file /home/denis/Projects/astra_lite/target/x86_64-unknown-linux-gnu/Dockerfile.x86_64-unknown-linux-gnu-custom /home/denis/Projects/astra_lite
STEP 1/4: FROM ghcr.io/cross-rs/x86_64-unknown-linux-gnu:main
STEP 2/4: ARG CROSS_DEB_ARCH=
--> Using cache acb6e470cd0039f71852bf18f3773780e7a175d1bc2124090dd802858f2c66b2
--> acb6e470cd0
STEP 3/4: ARG CROSS_CMD
--> Using cache f156e32a61b80c63e683d7a1193849318bfe5b02ebb64d7d21596fe9047eacfd
--> f156e32a61b
STEP 4/4: RUN eval "${CROSS_CMD}"
--> Using cache 811de8be035be1123a4eca7ea7841fb0085442ac83a3c57d9d2c447128f30a64
COMMIT localhost/cross-rs/cross-custom-astra_lite:x86_64-unknown-linux-gnu-5f8ae-pre-build
--> 811de8be035
Successfully tagged localhost/cross-rs/cross-custom-astra_lite:x86_64-unknown-linux-gnu-5f8ae-pre-build
Successfully tagged localhost/cross-rs/cross-custom-astra_lite_release:x86_64-unknown-linux-gnu-40e28-pre-build
811de8be035be1123a4eca7ea7841fb0085442ac83a3c57d9d2c447128f30a64
+ /usr/bin/podman run --userns host -e 'XARGO_HOME=/home/denis/.xargo' -e 'CARGO_HOME=/home/denis/.cargo' -e 'CROSS_RUST_SYSROOT=/home/denis/.rustup/toolchains/stable-x86_64-unknown-linux-gnu' -e 'CARGO_TARGET_DIR=/target' -e 'CROSS_RUNNER=' -e TERM -e 'USER=denis' -e 'CROSS_RUSTC_MAJOR_VERSION=1' -e 'CROSS_RUSTC_MINOR_VERSION=0' -e 'CROSS_RUSTC_PATCH_VERSION=0' --name cross-stable-x86_64-unknown-linux-gnu-8ded4-82e1608df-x86_64-unknown-linux-gnu-5f8ae-1707071806142 --rm -v /home/denis/.xargo:/home/denis/.xargo:z -v /home/denis/.cargo:/home/denis/.cargo:z -v /home/denis/.cargo/bin -v /home/denis/Projects/astra_lite:/home/denis/Projects/astra_lite:z -v /home/denis/.rustup/toolchains/stable-x86_64-unknown-linux-gnu:/home/denis/.rustup/toolchains/stable-x86_64-unknown-linux-gnu:z,ro -v /home/denis/Projects/astra_lite/target:/target:z -w /home/denis/Projects/astra_lite -t localhost/cross-rs/cross-custom-astra_lite:x86_64-unknown-linux-gnu-5f8ae-pre-build sh -c 'PATH="$PATH":"/home/denis/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/bin" sh -c '\''stat /home/denis/Projects/astra_lite/target/x86_64-unknown-linux-gnu/release/astra_lite'\'''
stat: cannot stat '/home/denis/Projects/astra_lite/target/x86_64-unknown-linux-gnu/release/astra_lite': No such file or directory

If this is podman/docker problem I'll just not use symlinks in the target folder path