cross-rs / cross-toolchains

Additional Dockerfiles and crosstool-ng config files to build additional toolchains.
Apache License 2.0
88 stars 16 forks source link

Instructions unclear for msvc build #38

Open alshdavid opened 1 year ago

alshdavid commented 1 year ago

Hi all, I'm trying to cross compile for Windows amd64 and arm64 while on a Windows host.

I'm attempting to follow the instructions for the msvc build but am failing - probably on something simple.

I'm using a Github Actions host using windows-latest. My build script looks like:

curl https://sh.rustup.rs -sSf | sh -s -- -y
cargo install cross

git clone https://github.com/cross-rs/cross /cross
cd /cross
git submodule update --init --remote

# I have tried with and without the following line
cargo xtask configure-crosstool x86_64-pc-windows-msvc

cargo build-docker-image x86_64-pc-windows-msvc --tag local

# Never gets this far
echo '\n' >> Cargo.toml
echo '[target.x86_64-pc-windows-msvc]\n' >> Cargo.toml
echo 'image = "ghcr.io/cross-rs/x86_64-pc-windows-msvc:local"\n' >> Cargo.toml

cross run --release --target x86_64-pc-windows-msvc

You can see the logs here: https://github.com/alshdavid-labs/cross-platform-binary-template/actions/runs/5892634303/job/15982367248

This results in the following error:

Run git clone https://github.com/cross-rs/cross /cross
Cloning into '/cross'...
Submodule 'docker/cross-toolchains' (https://github.com/cross-rs/cross-toolchains.git) registered for path 'docker/cross-toolchains'
Cloning into 'D:/cross/docker/cross-toolchains'...
Submodule path 'docker/cross-toolchains': checked out '4299096a1468f91aa9a[7](https://github.com/alshdavid-labs/cross-platform-binary-template/actions/runs/5892357823/job/15981437973#step:4:8)430e4763de6[8](https://github.com/alshdavid-labs/cross-platform-binary-template/actions/runs/5892357823/job/15981437973#step:4:9)5cb386a1'
    Updating crates.io index
 Downloading crates ...
  Downloaded same-file v1.0.6
  Downloaded thiserror-impl v1.0.40
   ....
   ....
   ....
   Compiling wildmatch v2.1.1
   Compiling xtask v0.0.0-dev.0 (D:\cross\xtask)
    Finished dev [unoptimized + debuginfo] target(s) in 1m 56s
     Running `target\debug\xtask.exe configure-crosstool x86_64-pc-windows-msvc`
Error: 
   0: unable to find config for target "x86_64-pc-windows-msvc"

Location:
   xtask\src\crosstool.rs:73

Backtrace omitted. Run with RUST_BACKTRACE=1 environment variable to display it.
Run with RUST_BACKTRACE=full to include source snippets.
error: process didn't exit successfully: `target\debug\xtask.exe configure-crosstool x86_64-pc-windows-msvc` (exit code: 1)
    Finished dev [unoptimized + debuginfo] target(s) in 0.21s
     Running `target\debug\xtask.exe build-docker-image x86_64-pc-windows-msvc --tag local`
Error: 
   0: unable to find dockerfile for target "x86_64-pc-windows-msvc"

Location:
   xtask\src\build_docker_image.rs:105

Backtrace omitted. Run with RUST_BACKTRACE=1 environment variable to display it.
Run with RUST_BACKTRACE=full to include source snippets.
error: process didn't exit successfully: `target\debug\xtask.exe build-docker-image x86_64-pc-windows-msvc --tag local` (exit code: 1)
Error: Process completed with exit code 1.
AregevDev commented 2 months ago

Bump Seems like your image files are incorrect. Make sure you build the x86_64-pc-windows-msvc-cross docker image (and not x86_64-pc-windows-msvc. Your cross configuration should be in Cross.toml, not Cargo.toml.

#inside the cross directory with git submodules updated
cargo xtask configure-crosstool #configure
cargo build-docker-image x86_64-pc-windows-msvc-cross --tag local #notice the cross suffix
rustup target add x86_64-pc-windows-msvc

Then add the following to the Cross.toml file in your crate root directory

[target.x86_64-pc-windows-msvc]
image = "ghcr.io/cross-rs/x86_64-pc-windows-msvc-cross:local"

Finally, run cross build --target x86_64-pc-windows-msvc Works for me under Linux.