Skip to content

Instantly share code, notes, and snippets.

@Jake-Shadle
Last active May 13, 2024 13:40
Show Gist options
  • Save Jake-Shadle/542dfa000a37c4d3c216c976e0fbb973 to your computer and use it in GitHub Desktop.
Save Jake-Shadle/542dfa000a37c4d3c216c976e0fbb973 to your computer and use it in GitHub Desktop.
Example dockerfile for cross compilation of `x86_64-pc-windows-msvc` Rust binaries in a Linux container
# We'll just use the official Rust image rather than build our own from scratch
FROM docker.io/library/rust:1.54.0-slim-bullseye
ENV KEYRINGS /usr/local/share/keyrings
RUN set -eux; \
mkdir -p $KEYRINGS; \
apt-get update && apt-get install -y gpg curl; \
# clang/lld/llvm
curl --fail https://apt.llvm.org/llvm-snapshot.gpg.key | gpg --dearmor > $KEYRINGS/llvm.gpg; \
# wine
curl --fail https://dl.winehq.org/wine-builds/winehq.key | gpg --dearmor > $KEYRINGS/winehq.gpg; \
echo "deb [signed-by=$KEYRINGS/llvm.gpg] http://apt.llvm.org/bullseye/ llvm-toolchain-bullseye-13 main" > /etc/apt/sources.list.d/llvm.list; \
echo "deb [signed-by=$KEYRINGS/winehq.gpg] https://dl.winehq.org/wine-builds/debian/ bullseye main" > /etc/apt/sources.list.d/winehq.list;
RUN set -eux; \
dpkg --add-architecture i386; \
# Skipping all of the "recommended" cruft reduces total images size by ~300MiB
apt-get update && apt-get install --no-install-recommends -y \
clang-13 \
# llvm-ar
llvm-13 \
lld-13 \
# get a recent wine so we can run tests
winehq-staging \
# Unpack xwin
tar; \
# ensure that clang/clang++ are callable directly
ln -s clang-13 /usr/bin/clang && ln -s clang /usr/bin/clang++ && ln -s lld-13 /usr/bin/ld.lld; \
# We also need to setup symlinks ourselves for the MSVC shims because they aren't in the debian packages
ln -s clang-13 /usr/bin/clang-cl && ln -s llvm-ar-13 /usr/bin/llvm-lib && ln -s lld-link-13 /usr/bin/lld-link; \
# Verify the symlinks are correct
clang++ -v; \
ld.lld -v; \
# Doesn't have an actual -v/--version flag, but it still exits with 0
llvm-lib -v; \
clang-cl -v; \
lld-link --version; \
# Use clang instead of gcc when compiling binaries targeting the host (eg proc macros, build files)
update-alternatives --install /usr/bin/cc cc /usr/bin/clang 100; \
update-alternatives --install /usr/bin/c++ c++ /usr/bin/clang++ 100; \
apt-get remove -y --auto-remove; \
rm -rf /var/lib/apt/lists/*;
# Retrieve the std lib for the target
RUN rustup target add x86_64-pc-windows-msvc
RUN set -eux; \
xwin_version="0.1.1"; \
xwin_prefix="xwin-$xwin_version-x86_64-unknown-linux-musl"; \
# Install xwin to cargo/bin via github release. Note you could also just use `cargo install xwin`.
curl --fail -L https://github.com/Jake-Shadle/xwin/releases/download/$xwin_version/$xwin_prefix.tar.gz | tar -xzv -C /usr/local/cargo/bin --strip-components=1 $xwin_prefix/xwin; \
# Splat the CRT and SDK files to /xwin/crt and /xwin/sdk respectively
xwin --accept-license 1 splat --output /xwin; \
# Remove unneeded files to reduce image size
rm -rf .xwin-cache /usr/local/cargo/bin/xwin;
# Note that we're using the full target triple for each variable instead of the
# simple CC/CXX/AR shorthands to avoid issues when compiling any C/C++ code for
# build dependencies that need to compile and execute in the host environment
ENV CC_x86_64_pc_windows_msvc="clang-cl" \
CXX_x86_64_pc_windows_msvc="clang-cl" \
AR_x86_64_pc_windows_msvc="llvm-lib" \
# wine can be quite spammy with log messages and they're generally uninteresting
WINEDEBUG="-all" \
# Use wine to run test executables
CARGO_TARGET_X86_64_PC_WINDOWS_MSVC_RUNNER="wine" \
# Note that we only disable unused-command-line-argument here since clang-cl
# doesn't implement all of the options supported by cl, but the ones it doesn't
# are _generally_ not interesting.
CL_FLAGS="-Wno-unused-command-line-argument -fuse-ld=lld-link /imsvc/xwin/crt/include /imsvc/xwin/sdk/include/ucrt /imsvc/xwin/sdk/include/um /imsvc/xwin/sdk/include/shared" \
# Let cargo know what linker to invoke if you haven't already specified it
# in a .cargo/config.toml file
CARGO_TARGET_X86_64_PC_WINDOWS_MSVC_LINKER="lld-link" \
RUSTFLAGS="-Lnative=/xwin/crt/lib/x86_64 -Lnative=/xwin/sdk/lib/um/x86_64 -Lnative=/xwin/sdk/lib/ucrt/x86_64"
# These are separate since docker/podman won't transform environment variables defined in the same ENV block
ENV CFLAGS_x86_64_pc_windows_msvc="$CL_FLAGS" \
CXXFLAGS_x86_64_pc_windows_msvc="$CL_FLAGS"
# Run wineboot just to setup the default WINEPREFIX so we don't do it every
# container run
RUN wine wineboot --init
@Jake-Shadle
Copy link
Author

This can be built via podman -t xwin -f xwin.dockerfile .

@P3GLEG
Copy link

P3GLEG commented Nov 22, 2021

Hey man, thanks for all your leg work on this. Awesome job. One additional improve for your own workflow could be using this with cross.

docker build -t jake/windows:latest .

then in your project folder next to Cargo.toml make a Cross.toml file add add

[target.x86_64-pc-windows-msvc]
image = "jake/windows:latest"

and then run

cross build --target x86_64-pc-windows-msvc

and you should see all your output in your project's target directory. Then you don't have to worry about mounting project files yourself and can be handy in your CI/CD pipeline.

@oberluz
Copy link

oberluz commented Jan 3, 2024

Hi @Jake-Shadle,

I've been able to use the xwin.dockerfile (modified to use docker.io/library/rust:1.67.0-slim-bullseye) to build a simple hello world rust app and it worked fine.

My real aim is to be able cross-compile a python app using https://github.com/ofek/pyapp.git, so that I end up with a windows executable that runs the python script.

I can create a linux executable using pyapp fine and it works. The command I use is:
cargo -v install pyapp --root ${CWD}/out

To create the windows executable I ran:
cross -v install pyapp --root ${CWD}/out --target x86_64-pc-windows-msvc

Most crates are created ok, but I have issues with some like bzip2. At a glance would you have any idea if I'm missing something in the docker image to make this work? I'm not a rust person so I'm a bit lost here...

[cross] warning: unable to get metadata for package [cross] note: Falling back tocargo` on the host.
Updating crates.io index
Installing pyapp v0.13.0
Updating crates.io index
Compiling libc v0.2.151
Compiling typenum v1.17.0
Compiling version_check v0.9.4
Compiling pkg-config v0.3.28
Compiling cfg-if v1.0.0
Compiling autocfg v1.1.0
Compiling windows_x86_64_msvc v0.48.5
Compiling windows_x86_64_msvc v0.52.0
Compiling pin-project-lite v0.2.13
Compiling httparse v1.8.0
Compiling windows-targets v0.48.5
Compiling rustls v0.21.10
Compiling windows-sys v0.48.0
Compiling bytes v1.5.0
Compiling generic-array v0.14.7
Compiling slab v0.4.9
Compiling windows-targets v0.52.0
Compiling memchr v2.7.1
Compiling serde v1.0.194
Compiling crc32fast v1.3.2
Compiling zstd-safe v5.0.2+zstd.1.5.2
Compiling windows-sys v0.52.0
Compiling itoa v1.0.10
Compiling futures-core v0.3.30
Compiling jobserver v0.1.27
Compiling getrandom v0.2.11
Compiling socket2 v0.5.5
Compiling cc v1.0.83
Compiling num_cpus v1.16.0
Compiling mio v0.8.10
Compiling once_cell v1.19.0
Compiling untrusted v0.9.0
Compiling spin v0.9.8
Compiling crypto-common v0.1.6
Compiling subtle v2.5.0
Compiling block-buffer v0.10.4
Compiling tokio v1.35.1
Compiling tracing-core v0.1.32
Compiling fnv v1.0.7
Compiling http v0.2.11
Compiling digest v0.10.7
Compiling tracing v0.1.40
Compiling rand_core v0.6.4
Compiling futures-task v0.3.30
Compiling hashbrown v0.14.3
Compiling equivalent v1.0.1
Compiling pin-utils v0.1.0
Compiling tinyvec_macros v0.1.1
Compiling futures-sink v0.3.30
Compiling cpufeatures v0.2.11
Compiling futures-io v0.3.30
Compiling ring v0.17.7
Compiling zstd-sys v2.0.9+zstd.1.5.5
Compiling bzip2-sys v0.1.11+1.0.8
Compiling futures-util v0.3.30
Compiling tinyvec v1.6.0
Compiling indexmap v2.1.0
Compiling proc-macro2 v1.0.74
Compiling windows_x86_64_msvc v0.42.2
Compiling percent-encoding v2.3.1
Compiling try-lock v0.2.5
Compiling log v0.4.20
Compiling rustix v0.38.28
Compiling form_urlencoded v1.2.1
Compiling unicode-normalization v0.1.22
Compiling want v0.3.1
Compiling http-body v0.4.6
Compiling inout v0.1.3
Compiling futures-channel v0.3.30
Compiling base64ct v1.6.0
Compiling bitflags v2.4.1
Compiling powerfmt v0.2.0
Compiling httpdate v1.0.3
Compiling unicode-ident v1.0.12
Compiling adler v1.0.2
Compiling tokio-util v0.7.10
Compiling tower-service v0.3.2
Compiling unicode-bidi v0.3.14
Compiling linux-raw-sys v0.4.12
Compiling h2 v0.3.22
Compiling idna v0.5.0
Compiling miniz_oxide v0.7.1
Compiling deranged v0.3.11
Compiling password-hash v0.4.2
Compiling hyper v0.14.28
Compiling cipher v0.4.4
Compiling sha2 v0.10.8
Compiling hmac v0.12.1
Compiling aho-corasick v1.1.2
Compiling ppv-lite86 v0.2.17
Compiling regex-syntax v0.8.2
Compiling time-core v0.1.2
Compiling utf8parse v0.2.1
Compiling ryu v1.0.16
Compiling base64 v0.21.5
Compiling anstyle v1.0.4
Compiling anstyle-wincon v3.0.2
Compiling rustls-pemfile v1.0.4
Compiling anstyle-parse v0.2.3
Compiling time v0.3.31
Compiling rand_chacha v0.3.1
Compiling pbkdf2 v0.11.0
Compiling regex-automata v0.4.3
Compiling serde_urlencoded v0.7.1
Compiling aes v0.8.3
Compiling windows-targets v0.42.2
Compiling flate2 v1.0.28
Compiling xattr v1.2.0
Compiling quote v1.0.35
Compiling url v2.5.0
Compiling sha1 v0.10.6
Compiling anstyle-query v1.0.2
Compiling filetime v0.2.23
Compiling encoding_rs v0.8.33
Compiling mime v0.3.17
Compiling ipnet v2.9.0
Compiling constant_time_eq v0.1.5
Compiling colorchoice v1.0.0
Compiling byteorder v1.5.0
Compiling zstd-safe v7.0.0
Compiling webpki-roots v0.25.3
Compiling portable-atomic v1.6.0
Compiling regex v1.10.2
Compiling anstream v0.6.5
Compiling tar v0.4.40
Compiling syn v2.0.46
Compiling windows-sys v0.45.0
Compiling rand v0.8.5
Compiling encode_unicode v0.3.6
Compiling unicode-width v0.1.11
Compiling anyhow v1.0.79
Compiling strsim v0.10.0
Compiling lazy_static v1.4.0
Compiling highway v1.1.0
Compiling option-ext v0.2.0
Compiling clap_lex v0.6.0
Compiling heck v0.4.1
Compiling clap_builder v4.4.12
Compiling dirs-sys v0.4.1
Compiling console v0.15.7
Compiling winreg v0.50.0
Compiling number_prefix v0.4.0
Compiling unicode-segmentation v1.10.1
Compiling fastrand v2.0.1
Compiling clap_derive v4.4.7
Compiling tempfile v3.9.0
Compiling indicatif v0.17.7
Compiling directories v5.0.1
Compiling os_pipe v1.1.5
Compiling clap v4.4.12
Compiling bzip2 v0.4.4
The following warnings were emitted during compilation:

warning: bzip2-sys@0.1.11+1.0.8: GNU compiler is not supported for this target
warning: bzip2-sys@0.1.11+1.0.8: GNU compiler is not supported for this target
warning: bzip2-sys@0.1.11+1.0.8: In file included from bzip2-1.0.8/bzlib_private.h:33,
warning: bzip2-sys@0.1.11+1.0.8: from bzip2-1.0.8/blocksort.c:22:
warning: bzip2-sys@0.1.11+1.0.8: bzip2-1.0.8/bzlib.h:70: warning: "BZ_EXPORT" redefined
warning: bzip2-sys@0.1.11+1.0.8: 70 | #define BZ_EXPORT
warning: bzip2-sys@0.1.11+1.0.8: |
warning: bzip2-sys@0.1.11+1.0.8: : note: this is the location of the previous definition
warning: bzip2-sys@0.1.11+1.0.8: In file included from bzip2-1.0.8/bzlib_private.h:33,
warning: bzip2-sys@0.1.11+1.0.8: from bzip2-1.0.8/blocksort.c:22:
warning: bzip2-sys@0.1.11+1.0.8: bzip2-1.0.8/bzlib.h:79:13: fatal error: windows.h: No such file or directory
warning: bzip2-sys@0.1.11+1.0.8: 79 | # include <windows.h>
warning: bzip2-sys@0.1.11+1.0.8: | ^~~~~~~~~~~
warning: bzip2-sys@0.1.11+1.0.8: compilation terminated.
warning: bzip2-sys@0.1.11+1.0.8: ToolExecError: Command "cc" "-O3" "-ffunction-sections" "-fdata-sections" "-m64" "-I" "bzip2-1.0.8" "-D_WIN32" "-DBZ_EXPORT" "-D_FILE_OFFSET_BITS=64" "-DBZ_NO_STDIO" "-o" "/tmp/cargo-installQyOKtR/x86_64-pc-windows-msvc/release/build/bzip2-sys-9926a6fdaf77750e/out/lib/bzip2-1.0.8/blocksort.o" "-c" "bzip2-1.0.8/blocksort.c" with args "cc" did not execute successfully (status code exit status: 1).running: "cc" "-O3" "-ffunction-sections" "-fdata-sections" "-m64" "-I" "bzip2-1.0.8" "-D_WIN32" "-DBZ_EXPORT" "-D_FILE_OFFSET_BITS=64" "-DBZ_NO_STDIO" "-o" "/tmp/cargo-installQyOKtR/x86_64-pc-windows-msvc/release/build/bzip2-sys-9926a6fdaf77750e/out/lib/bzip2-1.0.8/huffman.o" "-c" "bzip2-1.0.8/huffman.c"
warning: bzip2-sys@0.1.11+1.0.8: GNU compiler is not supported for this target
warning: bzip2-sys@0.1.11+1.0.8: In file included from bzip2-1.0.8/bzlib_private.h:33,
warning: bzip2-sys@0.1.11+1.0.8: from bzip2-1.0.8/huffman.c:22:
warning: bzip2-sys@0.1.11+1.0.8: bzip2-1.0.8/bzlib.h:70: warning: "BZ_EXPORT" redefined
warning: bzip2-sys@0.1.11+1.0.8: 70 | #define BZ_EXPORT
warning: bzip2-sys@0.1.11+1.0.8: |
warning: bzip2-sys@0.1.11+1.0.8: : note: this is the location of the previous definition
warning: bzip2-sys@0.1.11+1.0.8: In file included from bzip2-1.0.8/bzlib_private.h:33,
warning: bzip2-sys@0.1.11+1.0.8: from bzip2-1.0.8/huffman.c:22:
warning: bzip2-sys@0.1.11+1.0.8: bzip2-1.0.8/bzlib.h:79:13: fatal error: windows.h: No such file or directory
warning: bzip2-sys@0.1.11+1.0.8: 79 | # include <windows.h>
warning: bzip2-sys@0.1.11+1.0.8: | ^~~~~~~~~~~
warning: bzip2-sys@0.1.11+1.0.8: compilation terminated.
warning: bzip2-sys@0.1.11+1.0.8: ToolExecError: Command "cc" "-O3" "-ffunction-sections" "-fdata-sections" "-m64" "-I" "bzip2-1.0.8" "-D_WIN32" "-DBZ_EXPORT" "-D_FILE_OFFSET_BITS=64" "-DBZ_NO_STDIO" "-o" "/tmp/cargo-installQyOKtR/x86_64-pc-windows-msvc/release/build/bzip2-sys-9926a6fdaf77750e/out/lib/bzip2-1.0.8/huffman.o" "-c" "bzip2-1.0.8/huffman.c" with args "cc" did not execute successfully (status code exit status: 1).running: "cc" "-O3" "-ffunction-sections" "-fdata-sections" "-m64" "-I" "bzip2-1.0.8" "-D_WIN32" "-DBZ_EXPORT" "-D_FILE_OFFSET_BITS=64" "-DBZ_NO_STDIO" "-o" "/tmp/cargo-installQyOKtR/x86_64-pc-windows-msvc/release/build/bzip2-sys-9926a6fdaf77750e/out/lib/bzip2-1.0.8/crctable.o" "-c" "bzip2-1.0.8/crctable.c"
warning: bzip2-sys@0.1.11+1.0.8: GNU compiler is not supported for this target
warning: bzip2-sys@0.1.11+1.0.8: In file included from bzip2-1.0.8/bzlib_private.h:33,
warning: bzip2-sys@0.1.11+1.0.8: from bzip2-1.0.8/crctable.c:22:
warning: bzip2-sys@0.1.11+1.0.8: bzip2-1.0.8/bzlib.h:70: warning: "BZ_EXPORT" redefined
warning: bzip2-sys@0.1.11+1.0.8: 70 | #define BZ_EXPORT
warning: bzip2-sys@0.1.11+1.0.8: |
warning: bzip2-sys@0.1.11+1.0.8: : note: this is the location of the previous definition
warning: bzip2-sys@0.1.11+1.0.8: In file included from bzip2-1.0.8/bzlib_private.h:33,
warning: bzip2-sys@0.1.11+1.0.8: from bzip2-1.0.8/crctable.c:22:
warning: bzip2-sys@0.1.11+1.0.8: bzip2-1.0.8/bzlib.h:79:13: fatal error: windows.h: No such file or directory
warning: bzip2-sys@0.1.11+1.0.8: 79 | # include <windows.h>
warning: bzip2-sys@0.1.11+1.0.8: | ^~~~~~~~~~~
warning: bzip2-sys@0.1.11+1.0.8: compilation terminated.
warning: bzip2-sys@0.1.11+1.0.8: ToolExecError: Command "cc" "-O3" "-ffunction-sections" "-fdata-sections" "-m64" "-I" "bzip2-1.0.8" "-D_WIN32" "-DBZ_EXPORT" "-D_FILE_OFFSET_BITS=64" "-DBZ_NO_STDIO" "-o" "/tmp/cargo-installQyOKtR/x86_64-pc-windows-msvc/release/build/bzip2-sys-9926a6fdaf77750e/out/lib/bzip2-1.0.8/crctable.o" "-c" "bzip2-1.0.8/crctable.c" with args "cc" did not execute successfully (status code exit status: 1).running: "cc" "-O3" "-ffunction-sections" "-fdata-sections" "-m64" "-I" "bzip2-1.0.8" "-D_WIN32" "-DBZ_EXPORT" "-D_FILE_OFFSET_BITS=64" "-DBZ_NO_STDIO" "-o" "/tmp/cargo-installQyOKtR/x86_64-pc-windows-msvc/release/build/bzip2-sys-9926a6fdaf77750e/out/lib/bzip2-1.0.8/randtable.o" "-c" "bzip2-1.0.8/randtable.c"
warning: bzip2-sys@0.1.11+1.0.8: GNU compiler is not supported for this target
warning: bzip2-sys@0.1.11+1.0.8: In file included from bzip2-1.0.8/bzlib_private.h:33,
warning: bzip2-sys@0.1.11+1.0.8: from bzip2-1.0.8/randtable.c:22:
warning: bzip2-sys@0.1.11+1.0.8: bzip2-1.0.8/bzlib.h:70: warning: "BZ_EXPORT" redefined
warning: bzip2-sys@0.1.11+1.0.8: 70 | #define BZ_EXPORT
warning: bzip2-sys@0.1.11+1.0.8: |
warning: bzip2-sys@0.1.11+1.0.8: : note: this is the location of the previous definition
warning: bzip2-sys@0.1.11+1.0.8: In file included from bzip2-1.0.8/bzlib_private.h:33,
warning: bzip2-sys@0.1.11+1.0.8: from bzip2-1.0.8/randtable.c:22:
warning: bzip2-sys@0.1.11+1.0.8: bzip2-1.0.8/bzlib.h:79:13: fatal error: windows.h: No such file or directory
warning: bzip2-sys@0.1.11+1.0.8: 79 | # include <windows.h>
warning: bzip2-sys@0.1.11+1.0.8: | ^~~~~~~~~~~
warning: bzip2-sys@0.1.11+1.0.8: compilation terminated.
warning: bzip2-sys@0.1.11+1.0.8: ToolExecError: Command "cc" "-O3" "-ffunction-sections" "-fdata-sections" "-m64" "-I" "bzip2-1.0.8" "-D_WIN32" "-DBZ_EXPORT" "-D_FILE_OFFSET_BITS=64" "-DBZ_NO_STDIO" "-o" "/tmp/cargo-installQyOKtR/x86_64-pc-windows-msvc/release/build/bzip2-sys-9926a6fdaf77750e/out/lib/bzip2-1.0.8/randtable.o" "-c" "bzip2-1.0.8/randtable.c" with args "cc" did not execute successfully (status code exit status: 1).running: "cc" "-O3" "-ffunction-sections" "-fdata-sections" "-m64" "-I" "bzip2-1.0.8" "-D_WIN32" "-DBZ_EXPORT" "-D_FILE_OFFSET_BITS=64" "-DBZ_NO_STDIO" "-o" "/tmp/cargo-installQyOKtR/x86_64-pc-windows-msvc/release/build/bzip2-sys-9926a6fdaf77750e/out/lib/bzip2-1.0.8/compress.o" "-c" "bzip2-1.0.8/compress.c"
warning: bzip2-sys@0.1.11+1.0.8: GNU compiler is not supported for this target
warning: bzip2-sys@0.1.11+1.0.8: In file included from bzip2-1.0.8/bzlib_private.h:33,
warning: bzip2-sys@0.1.11+1.0.8: from bzip2-1.0.8/compress.c:29:
warning: bzip2-sys@0.1.11+1.0.8: bzip2-1.0.8/bzlib.h:70: warning: "BZ_EXPORT" redefined
warning: bzip2-sys@0.1.11+1.0.8: 70 | #define BZ_EXPORT
warning: bzip2-sys@0.1.11+1.0.8: |
warning: bzip2-sys@0.1.11+1.0.8: : note: this is the location of the previous definition
warning: bzip2-sys@0.1.11+1.0.8: In file included from bzip2-1.0.8/bzlib_private.h:33,
warning: bzip2-sys@0.1.11+1.0.8: from bzip2-1.0.8/compress.c:29:
warning: bzip2-sys@0.1.11+1.0.8: bzip2-1.0.8/bzlib.h:79:13: fatal error: windows.h: No such file or directory
warning: bzip2-sys@0.1.11+1.0.8: 79 | # include <windows.h>
warning: bzip2-sys@0.1.11+1.0.8: | ^~~~~~~~~~~
warning: bzip2-sys@0.1.11+1.0.8: compilation terminated.
warning: bzip2-sys@0.1.11+1.0.8: ToolExecError: Command "cc" "-O3" "-ffunction-sections" "-fdata-sections" "-m64" "-I" "bzip2-1.0.8" "-D_WIN32" "-DBZ_EXPORT" "-D_FILE_OFFSET_BITS=64" "-DBZ_NO_STDIO" "-o" "/tmp/cargo-installQyOKtR/x86_64-pc-windows-msvc/release/build/bzip2-sys-9926a6fdaf77750e/out/lib/bzip2-1.0.8/compress.o" "-c" "bzip2-1.0.8/compress.c" with args "cc" did not execute successfully (status code exit status: 1).running: "cc" "-O3" "-ffunction-sections" "-fdata-sections" "-m64" "-I" "bzip2-1.0.8" "-D_WIN32" "-DBZ_EXPORT" "-D_FILE_OFFSET_BITS=64" "-DBZ_NO_STDIO" "-o" "/tmp/cargo-installQyOKtR/x86_64-pc-windows-msvc/release/build/bzip2-sys-9926a6fdaf77750e/out/lib/bzip2-1.0.8/decompress.o" "-c" "bzip2-1.0.8/decompress.c"
warning: bzip2-sys@0.1.11+1.0.8: GNU compiler is not supported for this target
warning: bzip2-sys@0.1.11+1.0.8: In file included from bzip2-1.0.8/bzlib_private.h:33,
warning: bzip2-sys@0.1.11+1.0.8: from bzip2-1.0.8/decompress.c:22:
warning: bzip2-sys@0.1.11+1.0.8: bzip2-1.0.8/bzlib.h:70: warning: "BZ_EXPORT" redefined
warning: bzip2-sys@0.1.11+1.0.8: 70 | #define BZ_EXPORT
warning: bzip2-sys@0.1.11+1.0.8: |
warning: bzip2-sys@0.1.11+1.0.8: : note: this is the location of the previous definition
warning: bzip2-sys@0.1.11+1.0.8: In file included from bzip2-1.0.8/bzlib_private.h:33,
warning: bzip2-sys@0.1.11+1.0.8: from bzip2-1.0.8/decompress.c:22:
warning: bzip2-sys@0.1.11+1.0.8: bzip2-1.0.8/bzlib.h:79:13: fatal error: windows.h: No such file or directory
warning: bzip2-sys@0.1.11+1.0.8: 79 | # include <windows.h>
warning: bzip2-sys@0.1.11+1.0.8: | ^~~~~~~~~~~
warning: bzip2-sys@0.1.11+1.0.8: compilation terminated.
warning: bzip2-sys@0.1.11+1.0.8: ToolExecError: Command "cc" "-O3" "-ffunction-sections" "-fdata-sections" "-m64" "-I" "bzip2-1.0.8" "-D_WIN32" "-DBZ_EXPORT" "-D_FILE_OFFSET_BITS=64" "-DBZ_NO_STDIO" "-o" "/tmp/cargo-installQyOKtR/x86_64-pc-windows-msvc/release/build/bzip2-sys-9926a6fdaf77750e/out/lib/bzip2-1.0.8/decompress.o" "-c" "bzip2-1.0.8/decompress.c" with args "cc" did not execute successfully (status code exit status: 1).running: "cc" "-O3" "-ffunction-sections" "-fdata-sections" "-m64" "-I" "bzip2-1.0.8" "-D_WIN32" "-DBZ_EXPORT" "-D_FILE_OFFSET_BITS=64" "-DBZ_NO_STDIO" "-o" "/tmp/cargo-installQyOKtR/x86_64-pc-windows-msvc/release/build/bzip2-sys-9926a6fdaf77750e/out/lib/bzip2-1.0.8/bzlib.o" "-c" "bzip2-1.0.8/bzlib.c"
warning: bzip2-sys@0.1.11+1.0.8: In file included from bzip2-1.0.8/bzlib_private.h:33,
warning: bzip2-sys@0.1.11+1.0.8: from bzip2-1.0.8/bzlib.c:31:
warning: bzip2-sys@0.1.11+1.0.8: bzip2-1.0.8/bzlib.h:70: warning: "BZ_EXPORT" redefined
warning: bzip2-sys@0.1.11+1.0.8: 70 | #define BZ_EXPORT
warning: bzip2-sys@0.1.11+1.0.8: |
warning: bzip2-sys@0.1.11+1.0.8: : note: this is the location of the previous definition
warning: bzip2-sys@0.1.11+1.0.8: In file included from bzip2-1.0.8/bzlib_private.h:33,
warning: bzip2-sys@0.1.11+1.0.8: from bzip2-1.0.8/bzlib.c:31:
warning: bzip2-sys@0.1.11+1.0.8: bzip2-1.0.8/bzlib.h:79:13: fatal error: windows.h: No such file or directory
warning: bzip2-sys@0.1.11+1.0.8: 79 | # include <windows.h>
warning: bzip2-sys@0.1.11+1.0.8: | ^~~~~~~~~~~
warning: bzip2-sys@0.1.11+1.0.8: compilation terminated.
warning: bzip2-sys@0.1.11+1.0.8: ToolExecError: Command "cc" "-O3" "-ffunction-sections" "-fdata-sections" "-m64" "-I" "bzip2-1.0.8" "-D_WIN32" "-DBZ_EXPORT" "-D_FILE_OFFSET_BITS=64" "-DBZ_NO_STDIO" "-o" "/tmp/cargo-installQyOKtR/x86_64-pc-windows-msvc/release/build/bzip2-sys-9926a6fdaf77750e/out/lib/bzip2-1.0.8/bzlib.o" "-c" "bzip2-1.0.8/bzlib.c" with args "cc" did not execute successfully (status code exit status: 1).

error: failed to run custom build command for bzip2-sys v0.1.11+1.0.8
`

@Jake-Shadle
Copy link
Author

You are using cross, not xwin nor this dockerfile, please open an issue on cross.

@oberluz
Copy link

oberluz commented Jan 3, 2024

I thought I was but in fact I'm not. I had a Cross.toml with the x86_64-pc-windows-msvc target mapped to the docker image as described by @P3GLEG in the previous comment, but in fact I deleted the image and it runs exactly the same. Thanks for clarifying that at least...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment