Closed sergi0g closed 9 months ago
try adding -v
to see what cross is doing
Most likely you're getting limited by memory, and it's rustup that is failing
Try directly calling the rustup command you see with -v
I ran the same command but with cargo instead of cross and it seems to be building now. If I get an error I will follow your suggestion with cross.
My build failed and so I tried running the docker command from cross -v
. The docker container exits with code 2 and has no logs.
alright, sounds like you're running out of memory but let's validate that.
Instead of running cross build ...
, can you run cross-util run --interactive --target x86_64-pc-windows-gnu -- bash
you should get a prompt, now try
cargo -V
should give you the version of the toolchain
and then
cargo build --target x86_64-pc-windows-gnu
should build the crate
@Emilgardis I tried running the cross-util command but it returns to my normal shell without any prompt.
ok, can you try
docker run --rm -it ubuntu:20.04 bash
does that work?
If yes, then lets try mounting the current directory and see if we can find it.
docker run --rm -v $PWD:$PWD -it ubuntu:20.04 ls $PWD
I can confirm both commands work properly
ok, can you post the docker command that cross-util wants to do?
cross-util run --interactive --target x86_64-pc-windows-gnu -v -- bash
what I then want you to do is remove some of the arguments, i suspect it's something that's not working well.
This is not a cross issue anymore, but we can keep trying here anyway :)
It tries to run this:
/usr/bin/docker run --userns host --platform linux/amd64 -e 'PKG_CONFIG_ALLOW_CROSS=1' -e 'XARGO_HOME=/home/pi/.xargo' -e 'CARGO_HOME=/home/pi/.cargo' -e 'CROSS_RUST_SYSROOT=/ext/home/.rustup/toolchains/stable-x86_64-unknown-linux-gnu' -e 'CARGO_TARGET_DIR=/target' -e 'CROSS_RUNNER=' -e TERM -e 'USER=pi' -e 'CROSS_RUSTC_MAJOR_VERSION=1' -e 'CROSS_RUSTC_MINOR_VERSION=0' -e 'CROSS_RUSTC_PATCH_VERSION=0' -v /ext/home/dev/tpscube/lib:/ext/home/dev/tpscube/lib:z --name cross-stable-x86_64-unknown-linux-gnu-0d377-79e9716c9-x86_64-pc-windows-gnu-70fa0-1700321377385 --rm --user 1000:1000 -v /ext/home/.xargo:/home/pi/.xargo:z -v /ext/home/.cargo:/home/pi/.cargo:z -v /home/pi/.cargo/bin -v /ext/home/dev/tpscube:/ext/home/dev/tpscube:z -v /ext/home/.rustup/toolchains/stable-x86_64-unknown-linux-gnu:/ext/home/.rustup/toolchains/stable-x86_64-unknown-linux-gnu:z,ro -v /ext/home/dev/tpscube/target:/target:z -w /ext/home/dev/tpscube -t -i ghcr.io/cross-rs/x86_64-pc-windows-gnu:main sh -c 'PATH="$PATH":"/ext/home/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/bin" sh -c bash'
oh yeah, forgot that the pi isn't x86_64 hehe, should've ran the previous ubuntu commands with --platform linux/amd64
can you try
docker run --rm --userns host --platform linux/amd64 -v /ext/home/.rustup/toolchains/stable-x86_64-unknown-linux-gnu:/ext/home/.rustup/toolchains/stable-x86_64-unknown-linux-gnu:z,ro -it ubuntu:20.04 ls /ext/home/.rustup/toolchains/stable-x86_64-unknown-linux-gnu
and then for the actual cross image, let's try
docker run --userns host --platform linux/amd64 -v /ext/home/dev/tpscube/lib:/ext/home/dev/tpscube/lib:z --rm --user 1000:1000 -v /home/pi/.cargo/bin -v /ext/home/dev/tpscube:/ext/home/dev/tpscube:z -v /ext/home/.rustup/toolchains/stable-x86_64-unknown-linux-gnu:/ext/home/.rustup/toolchains/stable-x86_64-unknown-linux-gnu:z,ro -v /ext/home/dev/tpscube/target:/target:z -w /ext/home/dev/tpscube -t -i ghcr.io/cross-rs/x86_64-pc-windows-gnu:main /ext/home/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/bin/cargo -V
@Emilgardis the first command works and the second fails with no output
ok, does
docker run --userns host --platform linux/amd64 -v /ext/home/dev/tpscube/lib:/ext/home/dev/tpscube/lib:z --rm --user 1000:1000 -v /home/pi/.cargo/bin -v /ext/home/dev/tpscube:/ext/home/dev/tpscube:z -v /ext/home/.rustup/toolchains/stable-x86_64-unknown-linux-gnu:/ext/home/.rustup/toolchains/stable-x86_64-unknown-linux-gnu:z,ro -v /ext/home/dev/tpscube/target:/target:z -w /ext/home/dev/tpscube -t -i ghcr.io/cross-rs/x86_64-pc-windows-gnu:main ls
work?
No it does not. I still get no output.
ok, can you try to reduce the command a bit and see if you can figure out what is causing it to fail?
docker run --userns host --platform linux/amd64 --rm --user 1000:1000 -t -i ghcr.io/cross-rs/x86_64-pc-windows-gnu:main ls
It still fails, without output.
ok, try removing some of the arguments, maybe it's the --user 1000:1000
that's causing it
Still getting an error. I can't understand.
you're getting an error now?
I'm trying to help you but you have to try to work with me so that we can find the problem
does
docker run --platform linux/amd64 --rm -t -i ghcr.io/cross-rs/x86_64-pc-windows-gnu:main ls
docker run --platform linux/amd64 --rm -t -i ubuntu:20.04 ls
or
docker run --userns host --platform linux/amd64 --rm -t -i ghcr.io/cross-rs/x86_64-pc-windows-gnu:main ls
or
docker run --userns host --platform linux/amd64 --rm -t -i ubuntu:20.04 ls
docker run --userns host --user 1000:1000 --platform linux/amd64 --rm -t -i ubuntu:20.04 ls
work?
All commands for the ubuntu:20.04 image are working. The others aren't. It seems there is some problem with the entrypoint of the container
I see, I haven't heard of problems with https://github.com/cross-rs/cross/blob/main/docker/windows-entry.sh but you may be right (and I was under the impression that we didn't have a entrypoint on our windows images but you're right, we do)
if it is the entry, I suspect the problem is wine with qemu. We can override the entrypoint with --entrypoint
docker run --platform linux/amd64 --entrypoint /bin/bash --rm -t -i ghcr.io/cross-rs/x86_64-pc-windows-gnu:main bash
and then you can run the same commands as done in the windows-entry.sh
file, except don't redirect winebot &> /dev/null
and maybe you'll get an error message
export HOME=/tmp/home
mkdir -p "${HOME}"
# Initialize the wine prefix (virtual windows installation)
export WINEPREFIX=/tmp/wine
mkdir -p "${WINEPREFIX}"
# FIXME: Make the wine prefix initialization faster
wineboot &> /dev/null
wineboot
returns an exec format error for /usr/bin/wine
.
then it's probably qemu messing up, I'm not sure how I could help you specifically, maybe try installing a specific version
docker run --privileged --pull always --rm tonistiigi/binfmt:qemu-v8.0.4 -uninstall amd64 -install amd64
I found the problem. Wine is installed for i386 in the container. When I installed binfmt for i386 I could run wine. I will try a proper build now.
perfect! I think we can make this experience a bit better and warn if i386 is not executable
I tried running a build and it fails again. Wineboot fails with the message wine: chdir to /tmp/.wine-0/server-30-30dbdd : No such file or directory
.
I'm not an expert with wine, but I think wine should be looking in /tmp/wine due to the WINEPREFIX we've set
it could just be using /tmp/.wine-x to hold the environment
maybe wine failed to boot or crashed after some time?
It doesn't boot. I am currently starting a codespace so I can see if there is an issue there.
@Emilgardis cross works fine in the codespace. I will close this issue as I can still build with cargo. However I recommend testing cross with windows as a target in arm64 environments, so you can make your docker container work. Thank you very much for trying to help me solve the problem.
I've made the command fallible in #1373, so you should be able to build after that and pulling the new image, however you won't be able to test using wine
Checklist
Describe your issue
I wanted to compile a project for Windows on my Raspberry Pi. I ran
cross build --target x86_64-pc-windows-gnu --release
in my project directory. It started pulling a docker image and tried to run it when it was done pulling. Cross crashed with an exec format error. I realized I hadn't installed amd64 binfmt support on my system so I installed it (usingdocker run --rm --privileged tonistiigi/binfmt --install amd64
). I also manually tested if I can run the image. After confirming that I can run it, I ran the cross command again. The command exited right away, without any output. I tried again a few more times with no luck. I also tried other cross commands. Reinstalling cross or even Rust didn't help.Here is the terminal output:
How can I further debug this issue?
What target(s) are you cross-compiling for?
x86_64-pc-windows-gnu
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 (44011c8 2023-10-23)
Example
No response
Additional information / notes
No response