Skip to content

Commit 21e5a29

Browse files
committed
Use MinGW GCC with POSIX thread support when linking.
This changes from using WIN32 threads to POSIX threads when linking. MinGW (when using `libstdc++`) doesn't support C11 and C++11 threading support with WIN32 threads. This PR also makes WINE builds more resilient. Note that this will not affect any multi-threaded Rust code, which uses the Win32 API, calling `CreateThread` and `WaitForSingleObject` directly.
1 parent 247c440 commit 21e5a29

File tree

4 files changed

+13
-3
lines changed

4 files changed

+13
-3
lines changed

.changes/1123.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"description": "support external C/C++ dependencies using C11/C++11 threads for MinGW targets by switching linkers from `*-gcc` to `*gcc-posix`.",
3+
"type": "added",
4+
"issues": [1122],
5+
"breaking": true
6+
}

.changes/591-1095.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
},
1818
{
1919
"type": "changed",
20-
"description": "updated powerpc64, riscv64, and sparc64 *-linux-gnu images to use a 6.x kernel instead of a 4.x kernel.",
20+
"description": "updated powerpc64, riscv64, and sparc64 `*-linux-gnu` images to use a 6.x kernel instead of a 4.x kernel.",
2121
"breaking": true,
2222
"issues": [1094]
2323
}

docker/Dockerfile.i686-pc-windows-gnu

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,11 @@ RUN mkdir -p /usr/lib/binfmt-support/ && \
3434
COPY windows-entry.sh /
3535
ENTRYPOINT ["/windows-entry.sh"]
3636

37+
# for why we always link with pthread support, see:
38+
# https://github.com/cross-rs/cross/pull/1123#issuecomment-1312287148
3739
ENV CROSS_TOOLCHAIN_PREFIX=i686-w64-mingw32-
3840
ENV CROSS_SYSROOT=/usr/i686-w64-mingw32
39-
ENV CARGO_TARGET_I686_PC_WINDOWS_GNU_LINKER="$CROSS_TOOLCHAIN_PREFIX"gcc \
41+
ENV CARGO_TARGET_I686_PC_WINDOWS_GNU_LINKER="$CROSS_TOOLCHAIN_PREFIX"gcc-posix \
4042
CARGO_TARGET_I686_PC_WINDOWS_GNU_RUNNER=wine \
4143
CC_i686_pc_windows_gnu="$CROSS_TOOLCHAIN_PREFIX"gcc-posix \
4244
CXX_i686_pc_windows_gnu="$CROSS_TOOLCHAIN_PREFIX"g++-posix \

docker/Dockerfile.x86_64-pc-windows-gnu

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,11 @@ RUN mkdir -p /usr/lib/binfmt-support/ && \
3232
COPY windows-entry.sh /
3333
ENTRYPOINT ["/windows-entry.sh"]
3434

35+
# for why we always link with pthread support, see:
36+
# https://github.com/cross-rs/cross/pull/1123#issuecomment-1312287148
3537
ENV CROSS_TOOLCHAIN_PREFIX=x86_64-w64-mingw32-
3638
ENV CROSS_SYSROOT=/usr/x86_64-w64-mingw32
37-
ENV CARGO_TARGET_X86_64_PC_WINDOWS_GNU_LINKER="$CROSS_TOOLCHAIN_PREFIX"gcc \
39+
ENV CARGO_TARGET_X86_64_PC_WINDOWS_GNU_LINKER="$CROSS_TOOLCHAIN_PREFIX"gcc-posix \
3840
CARGO_TARGET_X86_64_PC_WINDOWS_GNU_RUNNER=wine \
3941
CC_x86_64_pc_windows_gnu="$CROSS_TOOLCHAIN_PREFIX"gcc-posix \
4042
CXX_x86_64_pc_windows_gnu="$CROSS_TOOLCHAIN_PREFIX"g++-posix \

0 commit comments

Comments
 (0)