-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This commit adds a script that builds MinGW-w64 toolchains with `win32` and `posix` thread models and updates the Dockerfile to invoke it. The MinGW-w64 toolchains are installed in the Docker image as follows: * /opt/mingw-w64-win32: x86_64-w64-mingw32 toolchain, win32 thread model * /opt/mingw-w64-posix: x86_64-w64-mingw32 toolchain, posix thread model The toolchain build scripts cleans up after itself so that no intermediate build artifacts end up in the final Docker image. Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
- Loading branch information
1 parent
2dfe290
commit 43792f1
Showing
2 changed files
with
111 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
#!/bin/bash | ||
|
||
BINUTILS_VERSION=2.42 | ||
GCC_VERSION=13.2.0 | ||
MINGW_VERSION=12.0.0 | ||
|
||
mkdir mingw | ||
pushd mingw | ||
|
||
# Download source code | ||
echo "@@@ Downloading source code" | ||
mkdir src | ||
pushd src | ||
## Binutils | ||
wget https://ftp.gnu.org/gnu/binutils/binutils-${BINUTILS_VERSION}.tar.xz | ||
tar Jxf binutils-${BINUTILS_VERSION}.tar.xz | ||
## GCC | ||
wget https://ftp.gnu.org/gnu/gcc/gcc-${GCC_VERSION}/gcc-${GCC_VERSION}.tar.xz | ||
tar Jxf gcc-${GCC_VERSION}.tar.xz | ||
pushd gcc-${GCC_VERSION} | ||
contrib/download_prerequisites | ||
popd | ||
## MinGW-w64 | ||
wget https://sourceforge.net/projects/mingw-w64/files/mingw-w64/mingw-w64-release/mingw-w64-v${MINGW_VERSION}.tar.bz2 | ||
tar jxf mingw-w64-v${MINGW_VERSION}.tar.bz2 | ||
popd | ||
|
||
build_mingw_toolchain() { | ||
local old_path=$PATH | ||
local thread_model=$1 | ||
local prefix=/opt/mingw-w64-${thread_model} | ||
|
||
echo "@@@ Building MinGW-w64 toolchain with '${thread_model}' thread model" | ||
|
||
# Add prefix bin directory to PATH to aid toolchain discovery | ||
export PATH="${prefix}/bin:${PATH}" | ||
|
||
# Create build directory | ||
mkdir build-${thread_model} | ||
pushd build-${thread_model} | ||
|
||
# Build Binutils | ||
mkdir binutils | ||
pushd binutils | ||
../../src/binutils-${BINUTILS_VERSION}/configure \ | ||
--prefix=${prefix} \ | ||
--target=x86_64-w64-mingw32 \ | ||
--disable-multilib | ||
make -j$(nproc) | ||
make install | ||
popd | ||
|
||
# Install MinGW headers | ||
mkdir mingw-headers | ||
pushd mingw-headers | ||
../../src/mingw-w64-v${MINGW_VERSION}/mingw-w64-headers/configure \ | ||
--prefix=${prefix}/x86_64-w64-mingw32 \ | ||
--host=x86_64-w64-mingw32 \ | ||
--with-default-msvcrt=ucrt | ||
make install | ||
popd | ||
|
||
# Build core GCC | ||
mkdir gcc | ||
pushd gcc | ||
../../src/gcc-${GCC_VERSION}/configure \ | ||
--prefix=${prefix} \ | ||
--target=x86_64-w64-mingw32 \ | ||
--disable-multilib \ | ||
--enable-languages=c,c++ \ | ||
--enable-threads=win32 \ | ||
--with-headers | ||
make -j$(nproc) all-gcc | ||
make install-gcc | ||
popd | ||
|
||
# Build MinGW | ||
mkdir mingw | ||
pushd mingw | ||
../../src/mingw-w64-v${MINGW_VERSION}/configure \ | ||
--prefix=${prefix}/x86_64-w64-mingw32 \ | ||
--host=x86_64-w64-mingw32 \ | ||
--with-default-msvcrt=ucrt | ||
make -j$(nproc) | ||
make install -j$(nproc) | ||
popd | ||
|
||
# Build final GCC | ||
pushd gcc | ||
make -j$(nproc) | ||
make install | ||
popd | ||
|
||
# Restore environment | ||
popd | ||
export PATH=${old_path} | ||
} | ||
|
||
# Build MinGW toolchain with 'win32' thread model | ||
build_mingw_toolchain win32 | ||
|
||
# Build MinGW toolchain with 'posix' thread model | ||
build_mingw_toolchain posix | ||
|
||
# Clean up build directories | ||
popd | ||
rm -rf mingw |