| Name | Modified | Size | Downloads / Week |
|---|---|---|---|
| Parent folder | |||
| README | < 18 hours ago | 10.8 kB | |
| djgpp205-i686_gcc-16.2.0-pthread_MSYS2.tar.xz | < 18 hours ago | 92.0 MB | |
| djgpp205-i586_gcc-16.2.0-pthread_MSYS2.tar.xz | < 18 hours ago | 92.0 MB | |
| djgpp-builder-v3.0.tar.gz | < 18 hours ago | 513.4 kB | |
| Totals: 4 Items | 184.5 MB | 0 | |
#
# This distribution is a modified version of DJGPP v2.05
# The official/original DJGPP can be found at https://delorie.com/djgpp/
#
Build script for a DJGPP cross-compiler with POSIX threads (and std::thread)
Copyright (C) 2026 by Alexander Bruines <alexander.bruines@gmail.com>
This entire distribution, including any scripts and patches used to build it,
are distributed under the terms described in the file COPYING.DJ.
COPYING.DJ should be in the same directory as this file but can also be found
at: https://www.delorie.com/djgpp/dl/ofc/simtel/v2/copying.dj
Introduction:
-------------
These scripts and patches attempt to build a GNU/Linux to DJGPP/DOS
cross-compiler with POSIX threads and working std::thread.
This is the README file for the modifications made to DJGPP v2.05 and
GNU BINUTILS, GCC and Portable Thread Library.
NOTICE: All applications produced with this unofficial DJGPP release must
-if distributed- comply with the GNU General Public License version 2.
The reason for this is that applications are statically linked to a
modified DJGPP runtime (and other GPL'ed libraries).
New in this version:
--------------------
- Updated GNU BINUTILS to 2.47 and GCC to 16.2.0.
- Added support for building/using DJGPP on Windows using MSYS2.
- Added true cross-compilation support, ie. build DJGPP on linux for use on
another host architecture (eg. for Raspberry Pi, or even for Windows).
- Added a 'download' cmake target that allows to pre-download all sources.
- The website https://git.savannah.gnu.org (used to update the config.guess
script in the Pth207 source tarball) is unavailable very often.
Its so bad that I've included the updated script in the patches directory
instead of downloading it. (There is still a way to download it via that URL
by using cmake -DSAVANNAH=ON when configuring.)
- Using of https://ftpmirror.gnu.org can be hit or miss,
changed it to use https://ftp.gnu.org/gnu instead.
- Added some contributed patches. Thank you Beebix!
Build requirements (Linux):
---------------------------
On Debian based distros the following packages are required:
cmake ninja-build bison patch sed flex gcc g++ tar texinfo
zlib1g-dev unzip zip zstd xz libgmp-dev libmpfr-dev libmpc-dev
autoconf2.69 automake
If building with -DHAVE_WATT32=ON then the following are also needed:
nasm libslang2-dev
Note that enabling Watt32 may significantly reduce thread switching performance.
(See /pth-2.0.7/djgpp/README.dos in the pth207s.zip archive.)
To cross-compile DJGPP for use on Raspberry Pi the following extra packages
are needed:
For 32bit Raspbian: crossbuild-essential-armhf
For 64bit Raspbian: crossbuild-essential-arm64
To cross-compile for Windows/MingW install the gcc-mingw-w64 package.
Build requirements (Windows/MSYS2):
-----------------------------------
When building DJGPP using MSYS2 the following packges from the MSYS repo
must be installed:
pacman -S --needed \
autoconf autoconf2.69 automake automake1.15 bison cmake flex gcc \
gmp-devel groff make mpc-devel mpfr-devel ninja patch sed tar texinfo \
unzip xz zip zlib zstd
(Use the MSYS shell to install them, ie. not a MINGW, CLANG or UCRT64 shell)
POSIX threads support:
----------------------
The pthread library used by this build of DJGPP is GNU Pth 2.0.7.
GCC is modified to use the pthread library and the -pthread command-line
option to GCC is enabled for use with DJGPP. This option defines the _REENTRANT
macro and enables automatic linking with the GNU Portable Thread (and external
sockets) library.
Watt32 Sockets library:
-----------------------
Compiling the pthread library requires a sockets implementation.
I have only made sure that this code builds cleanly and can be integrated
into this build of DJGPP.
This means that I have not tested any of the functionality this library
provides. If you want a DJGPP that includes this library then use
-DHAVE_WATT32=ON when configuring the build.
PthSock library (dummy sockets library):
----------------------------------------
This is a sockets library that I've written just to provide the minimum
required for building the GNU Portable Thread library without needing Watt32.
It does not provide any actual functionality.
I prefer this since I have no need for a sockets library (yet).
The source code is included in the 'patches' directory.
Building the DJGPP cross-compiler:
----------------------------------
The DJGPP cross-compiler is built in three stages.
- Stage 1: The regular DJGPP (ie. using the DJCRX205.ZIP package) for C only.
- Stage 2: Intermediate DJGPP that uses the patched DJLSR205.ZIP/PTH207S.ZIP
but can still only compile C code but supports pthreads.
- Stage 3: The final build of DJGPP is build with a libc/libpthread/libsocket
compiled by a compiler that uses that same set of libraries and
headers (ie. stage 2) and supports pthreads.
This time all the compilers are build (c,c++,objc,obj-c++,fortran).
(Note that only this stage is cross compiled when the build was
configured to run on another host.)
Linux:
Running the included 'build-djgpp-i586.sh' script is the same as:
cmake -G Ninja -S . -B ./build-i586 -DDJGPP_MARCH=i586 -DDJGPP_TUNE=i586 \
-DCMAKE_INSTALL_PREFIX=/usr/local && cmake --build ./build-i586
After building DJGPP it can be installed to CMAKE_INSTALL_PREFIX with:
[sudo] cmake --install ./build-i586
To cross-compile for Raspberry Pi see the included shell scripts with example
configurations (build-djgpp-*.sh).
Windows:
There are two methods to build this DJGPP compiler for use on Windows.
1. Cross-compile it on Linux.
See the build-djgpp-for-win32.sh and build-djgpp-for-win64.sh scripts.
2. Build it on Windows using MSYS2 (recommended).
Use the build-on-msys2.sh script.
The top of the CMakeLists.txt file describes all available configuration
options.
Multiple flavors:
-----------------
The default build produces .EXE files that require and are optimized for
Pentium processors. You can also install a Pentium Pro and/or Pentium II
optimized build on top (or instead) of the i586 version.
To configure for another CPU use the -DDJGPP_MARCH=i?86 when configuring.
Building Multi Threaded DJGPP applications:
-------------------------------------------
To enable POSIX threads simply specify -pthread as one of the command-line
arguments passed to GCC. This applies to both compiling and linking.
Passing the -pthread option to GCC causes it to define the _REENTRANT macro
which is used by the DJGPP header files to detect if POSIX threads are enabled.
Specifying the -pthread option during linking will cause the pthread and sockets
libraries to be automatically included.
The Autoconf 'AX_PTHREAD' macro should work with DJGPP based projects that use
pthreads and is available at:
http://www.gnu.org/software/autoconf-archive/ax_pthread.html
An example toolchain file for using the DJGPP cross-compiler with (your) CMake
based projects is akso available, see 'djgpp_toolchain.cmake' in this directory.
Caveat
------
There are a couple of caveats that apply to the GNU Portable Threads library.
The most important one is that it implements Cooperative Multi Threading
meaning that all thread switching is explicit and done in software using long
jumps at specific points in your code (ie. where you call a pthread or MT-aware
function).
Also the state of the FPU is not saved/restored when switching threads.
One more thing to note is that the pthread.h header file uses macros to redirect
some libc/libsocket calls to pthread aware versions of those functions.
These macros prepend the text '__pthread_' to function calls like fork(),
sleep(), connect(), select() and others.
The above also means that if you use any of those names in your pthread enabled
code they will also be prepended with '__pthread_'. This is not a real problem
but may cause some confusion when debugging, or an actual issue when mixing code
compiled with and without specifying the -pthread option to GCC or when a source
file somehow doesn't include pthread.h and can't find a function that had its
name modified in this manner.
Modifications and patches:
--------------------------
This is just a short description of the most important modifications made to
each package. To see all modification please examine the build scripts and
individual patch files.
Note that although these patches may produce a functional cross-compiler
there are certainly a lot of missing/broken features. If you find any and
know how to fix it, then please contribute your patch.
- binutils : Modified the section alignment for the coff-go32 and coff-go32-exe
file formats from 16 to 64 bytes.
- gcc : Apply patches made by comparing the official DJGPP released GCC
(14.2.0) sources with the original GCC sources.
: Change the maximum alignas() value from 16 to 64 bytes.
: Fix-ups to get POSIX threads to compile/work.
: Add the -pthread option for DJGPP.
- DJ???205 : Modify crt0/crt1 for using std::thread and friends.
: Fix-ups for building GCC with POSIX threads enabled.
- Watt32 : Patch the header files for inclusion in DJGPP include directory.
: Fix-ups for compilation issues.
- PTh207s : Fix-ups for compilation issues.
Version History:
----------------
v1.0 - Initial public release
v1.1 - Updated BINUTILS to version 2.45.1
- Updated GCC to version 15.2.0
- Added the ability to configure the build for either the
i586-pc-msdosdjgpp, i686-pc-msdosdjgpp or i786-pc-msdosdjgpp target,
where each is optimized for respectivly; pentium, pentium pro or
any other CPU supported by GCC, see djgpp-builder.cfg
(All three can be installed on top of each other on your system.)
- Added a means to cross-build the compiler for Raspberry Pi OS.
- Fixed an issue where the script would fail by explicitly synchronizing
the filesystem before unmounting the buildroot image file.
v2.0 - New build script using CMake.
- Updated BINUTILS to version 2.46.0
- Updated the libsocket dummy to version 1.1
v3.0 - Updated BINUTILS to version 2.47
- Updated GCC to version 16.2.0
- Restored/Added true cross-compilation support.
- Added Windows/MSYS2 support.
- Made downloading from https://git.savannah.gnu.org optional
- Use https://ftp.gnu.org instead of https://ftpmirror.gnu.org
- Patches contributed by Beebix:
- dtoutod.patch, dxe3gen-fix-unquoted-macros.patch
- Test if file exists before downloading in DownloadFile.cmake
- Forcibly apply patches no questions asked, or fail.