1
0
mirror of https://github.com/skeeto/w64devkit.git synced 2025-04-18 06:44:01 +03:00

Initial commit of working code

This commit is contained in:
Christopher Wellons 2020-05-09 16:04:41 -04:00
commit 675638827a
4 changed files with 335 additions and 0 deletions

241
Dockerfile Normal file
View File

@ -0,0 +1,241 @@
FROM debian:buster-slim
ARG VERSION=1.0.0
ARG PREFIX=/w64devkit-$VERSION
ARG BINUTILS_VERSION=2.34
ARG BUSYBOX_VERSION=FRP-3445-g10e14d5eb
ARG GCC_VERSION=10.1.0
ARG GMP_VERSION=6.2.0
ARG MAKE_VERSION=4.2
ARG MINGW_VERSION=6.0.0
ARG MPC_VERSION=1.1.0
ARG MPFR_VERSION=4.0.2
RUN apt-get update && apt-get install --yes --no-install-recommends \
build-essential curl file libgmp-dev libmpc-dev libmpfr-dev m4 texinfo zip
# Download, verify, and unpack
RUN curl --insecure --location --remote-name-all \
https://ftp.gnu.org/gnu/binutils/binutils-$BINUTILS_VERSION.tar.xz \
https://ftp.gnu.org/gnu/gcc/gcc-10.1.0/gcc-$GCC_VERSION.tar.xz \
https://ftp.gnu.org/gnu/gmp/gmp-$GMP_VERSION.tar.xz \
https://ftp.gnu.org/gnu/mpc/mpc-$MPC_VERSION.tar.gz \
https://ftp.gnu.org/gnu/mpfr/mpfr-$MPFR_VERSION.tar.xz \
https://ftp.gnu.org/gnu/make/make-$MAKE_VERSION.tar.gz \
https://frippery.org/files/busybox/busybox-w32-$BUSYBOX_VERSION.tgz \
https://downloads.sourceforge.net/project/mingw-w64/mingw-w64/mingw-w64-release/mingw-w64-v$MINGW_VERSION.tar.bz2
COPY SHA256SUMS .
RUN sha256sum -c SHA256SUMS \
&& tar xJf binutils-$BINUTILS_VERSION.tar.xz \
&& tar xzf busybox-w32-$BUSYBOX_VERSION.tgz \
&& tar xJf gcc-$GCC_VERSION.tar.xz \
&& tar xJf gmp-$GMP_VERSION.tar.xz \
&& tar xzf mpc-$MPC_VERSION.tar.gz \
&& tar xJf mpfr-$MPFR_VERSION.tar.xz \
&& tar xzf make-$MAKE_VERSION.tar.gz \
&& tar xjf mingw-w64-v$MINGW_VERSION.tar.bz2
# Build cross-compiler
WORKDIR /x-binutils
RUN /binutils-$BINUTILS_VERSION/configure \
--prefix=/bootstrap \
--with-sysroot=/bootstrap \
--target=x86_64-w64-mingw32 \
--disable-nls \
--enable-static \
--disable-shared \
--disable-multilib
RUN make -j$(nproc)
RUN make install
WORKDIR /x-mingw-headers
RUN /mingw-w64-v$MINGW_VERSION/mingw-w64-headers/configure \
--prefix=/bootstrap/x86_64-w64-mingw32 \
--host=x86_64-w64-mingw32
RUN make -j$(nproc)
RUN make install
WORKDIR /bootstrap
RUN ln -s x86_64-w64-mingw32 mingw
WORKDIR /x-gcc
RUN /gcc-$GCC_VERSION/configure \
--prefix=/bootstrap \
--with-sysroot=/bootstrap \
--target=x86_64-w64-mingw32 \
--enable-static \
--disable-shared \
--enable-languages=c,c++ \
--enable-libgomp \
--enable-threads=win32 \
--enable-version-specific-runtime-libs \
--disable-nls \
--disable-multilib
RUN make -j$(nproc) all-gcc
RUN make install-gcc
ENV PATH="/bootstrap/bin:${PATH}"
WORKDIR /x-mingw-crt
RUN /mingw-w64-v$MINGW_VERSION/mingw-w64-crt/configure \
--prefix=/bootstrap/x86_64-w64-mingw32 \
--with-sysroot=/bootstrap/x86_64-w64-mingw32 \
--host=x86_64-w64-mingw32
RUN make -j$(nproc)
RUN make install
WORKDIR /x-winpthreads
RUN /mingw-w64-v$MINGW_VERSION/mingw-w64-libraries/winpthreads/configure \
--prefix=/bootstrap/x86_64-w64-mingw32 \
--with-sysroot=/bootstrap/x86_64-w64-mingw32 \
--host=x86_64-w64-mingw32 \
--enable-static \
--disable-shared
RUN make -j$(nproc)
RUN make install
WORKDIR /x-gcc
RUN make -j$(nproc)
RUN make install
# Cross-compile GCC
WORKDIR /
WORKDIR /binutils
RUN /binutils-$BINUTILS_VERSION/configure \
--prefix=$PREFIX \
--with-sysroot=$PREFIX \
--host=x86_64-w64-mingw32 \
--target=x86_64-w64-mingw32 \
--disable-nls \
--enable-static \
--disable-shared \
CFLAGS="-Os" \
LDFLAGS="-s"
RUN make -j$(nproc)
RUN make install
WORKDIR /
WORKDIR /gmp
RUN /gmp-$GMP_VERSION/configure \
--prefix=/deps \
--host=x86_64-w64-mingw32 \
--disable-assembly \
--enable-static \
--disable-shared \
CFLAGS="-Os" \
LDFLAGS="-s"
RUN make -j$(nproc)
RUN make install
WORKDIR /
WORKDIR /mpfr
RUN /mpfr-$MPFR_VERSION/configure \
--prefix=/deps \
--host=x86_64-w64-mingw32 \
--with-gmp-include=/deps/include \
--with-gmp-lib=/deps/lib \
--enable-static \
--disable-shared \
CFLAGS="-Os" \
LDFLAGS="-s"
RUN make -j$(nproc)
RUN make install
WORKDIR /
WORKDIR /mpc
RUN /mpc-$MPC_VERSION/configure \
--prefix=/deps \
--host=x86_64-w64-mingw32 \
--with-gmp-include=/deps/include \
--with-gmp-lib=/deps/lib \
--with-mpfr-include=/deps/include \
--with-mpfr-lib=/deps/lib \
--enable-static \
--disable-shared \
CFLAGS="-Os" \
LDFLAGS="-s"
RUN make -j$(nproc)
RUN make install
WORKDIR /
WORKDIR /mingw-headers
RUN /mingw-w64-v$MINGW_VERSION/mingw-w64-headers/configure \
--prefix=$PREFIX/x86_64-w64-mingw32 \
--host=x86_64-w64-mingw32
RUN make -j$(nproc)
RUN make install
WORKDIR /mingw-crt
RUN /mingw-w64-v$MINGW_VERSION/mingw-w64-crt/configure \
--prefix=$PREFIX/x86_64-w64-mingw32 \
--with-sysroot=$PREFIX/x86_64-w64-mingw32 \
--host=x86_64-w64-mingw32 \
CFLAGS="-Os" \
LDFLAGS="-s"
RUN make -j$(nproc)
RUN make install
WORKDIR /
RUN sed -i 's#=/mingw/include#=/include#' gcc-$GCC_VERSION/gcc/config.gcc
WORKDIR /gcc
RUN /gcc-$GCC_VERSION/configure \
--prefix=$PREFIX \
--with-sysroot=$PREFIX \
--target=x86_64-w64-mingw32 \
--host=x86_64-w64-mingw32 \
--enable-static \
--disable-shared \
--with-gmp-include=/deps/include \
--with-gmp-lib=/deps/lib \
--with-mpc-include=/deps/include \
--with-mpc-lib=/deps/lib \
--with-mpfr-include=/deps/include \
--with-mpfr-lib=/deps/lib \
--enable-languages=c,c++ \
--enable-libgomp \
--enable-threads=win32 \
--enable-version-specific-runtime-libs \
--disable-multilib \
--disable-nls \
CFLAGS="-Os" \
LDFLAGS="-s"
RUN make -j$(nproc)
RUN make install
WORKDIR /winpthreads
RUN /mingw-w64-v$MINGW_VERSION/mingw-w64-libraries/winpthreads/configure \
--prefix=$PREFIX/x86_64-w64-mingw32 \
--with-sysroot=$PREFIX/x86_64-w64-mingw32 \
--host=x86_64-w64-mingw32 \
--enable-static \
--disable-shared
RUN make -j$(nproc)
RUN make install
RUN echo '@%~dp0/gcc.exe %*' >$PREFIX/bin/cc.bat
# Build some extra development tools
WORKDIR /make
RUN /make-$MAKE_VERSION/configure \
--host=x86_64-w64-mingw32 \
--disable-nls \
CFLAGS="-I/make-$MAKE_VERSION/glob -Os" \
LDFLAGS="-s"
RUN make -j$(nproc)
RUN cp make.exe $PREFIX/bin/
WORKDIR /busybox-w32
RUN make mingw64_defconfig
RUN make -j$(nproc)
RUN cp busybox.exe $PREFIX/bin/
# Pack up a release
WORKDIR /
ENV PREFIX=${PREFIX}
CMD zip -q9Xr - $PREFIX

62
README.md Normal file
View File

@ -0,0 +1,62 @@
# Portable C and C++ Development Kit for x64 Windows
This is a Dockerfile that builds a small, portable development suite for
writing C and C++ applications on and for x64 Windows. Docker is not
needed to use the tools themselves. It's merely used as reliable, clean
environment for compilation and linking. Included tools:
* [Mingw-w64 GCC][w64] : compilers, linker, assembler
* GNU Make : standard build tool
* [busybox-w32][bb] : standard unix utilities, including sh
## Build
First build the image, then run it to produce a release .zip file:
docker build -t w64devkit .
docker run --rm w64devkit >w64devkit.zip
## Usage
The final .zip file contains tools in a typical unix-like configuration.
Unzip the contents anywhere and add its `bin/` directory to your path.
For example, while inside a console or batch script:
set PATH=c:\path\to\w64devkit\bin;%PATH%
Then to access a small unix environment:
busybox sh -l
This will expose the rest of busybox's commands without further action.
## Notes
Due to [an old GCC bug][bug], we must build a cross-compiler to
cross-compile GCC itself because, due to host contamination, GCC can
only be correctly and safely cross-compiled by a matching version.
Since the development kit is intended to be flexible, light, and
portable — i.e. run from anywhere, in place, and no installation is
necessary — the binaries are all optimized for size, not speed.
I'd love to include Git, but unfortunately Git's build system is a
disaster and doesn't support cross-compilation. It's also got weird
dependencies like Perl. Git may be a fantastic and wonderful tool, but
it's also kind of a mess.
It would be nice to have a better shell like Bash. BusyBox Ash is
limited, and the Windows port is pretty quirky. Unfortunately Bash's
build system is a total mess and does not support cross-compilation.
Since the build environment is so stable and predicable, it would be
great for the .zip to be reproducible, i.e. builds by different people
are bit-for-bit identical. There are multiple reasons why this is not
currently the case, the least of which are [timestamps in the .zip
file][zip].
[bb]: https://frippery.org/busybox/
[bug]: https://gcc.gnu.org/legacy-ml/gcc/2017-05/msg00219.html
[w64]: http://mingw-w64.org/
[zip]: https://tanzu.vmware.com/content/blog/barriers-to-deterministic-reproducible-zip-files

8
SHA256SUMS Normal file
View File

@ -0,0 +1,8 @@
f00b0e8803dc9bab1e2165bd568528135be734df3fabf8d0161828cd56028952 binutils-2.34.tar.xz
e8e7ac9ff79fe85cb6d2ccaffc650fbd2b0ea9a24ffb87a50b3b17e8e23a60e7 busybox-w32-FRP-3445-g10e14d5eb.tgz
b6898a23844b656f1b68691c5c012036c2e694ac4b53a8918d4712ad876e7ea2 gcc-10.1.0.tar.xz
258e6cd51b3fbdfc185c716d55f82c08aff57df0c6fbd143cf6ed561267a1526 gmp-6.2.0.tar.xz
e968ce3c57ad39a593a92339e23eb148af6296b9f40aa453a9a9202c99d34436 make-4.2.tar.gz
6985c538143c1208dcb1ac42cedad6ff52e267b47e5f970183a3e75125b43c2e mpc-1.1.0.tar.gz
1d3be708604eae0e42d578ba93b390c2a145f17743a744d8f3f8c2ad5855a38a mpfr-4.0.2.tar.xz
805e11101e26d7897fce7d49cbb140d7bac15f3e085a91e0001e80b2adaf48f0 mingw-w64-v6.0.0.tar.bz2

24
UNLICENSE Normal file
View File

@ -0,0 +1,24 @@
This is free and unencumbered software released into the public domain.
Anyone is free to copy, modify, publish, use, compile, sell, or
distribute this software, either in source code form or as a compiled
binary, for any purpose, commercial or non-commercial, and by any
means.
In jurisdictions that recognize copyright laws, the author or authors
of this software dedicate any and all copyright interest in the
software to the public domain. We make this dedication for the benefit
of the public at large and to the detriment of our heirs and
successors. We intend this dedication to be an overt act of
relinquishment in perpetuity of all present and future rights to this
software under copyright law.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
For more information, please refer to <http://unlicense.org/>