Tiny C Compiler for DOS & HXRT
==============================

* Introduction
* How to build TCC
* Environment size
* HXRT config
* How to list DLLs used

Introduction
============

This is a DOS port of the Tiny C Compiler 0.9.27.  It's actually
a win32 binary, but is modified to run better in HXDOS.

This build requires an FPU (math coprocessor) to use floating point
types.

It requires 16 MB RAM to bootstrap and rebuild itself.

It uses Watcom libc rather than MSVCRT.DLL.

It does not require LFN (long file name) support.

How to build TC
===============

To build TCC, run: mkall.bat

This is done in 3 stages:

1) Bootstrap TCC using Watcom (mkwatcom.bat)
2) Self-host TCC using the bootstrapped compiler (mktcc.bat)
3) Build TCC using self-hosted compiler for sanity check (mktcc.bat)

These .bat files depend on cmp, deltree, HXRT, and watcom 1.9
On SvarDOS, use EDRDOS COMMAND.COM after commit 579ab14 (2026-03-09).

Environment size
================

I recommend allocating 2k for environment variables by adding
something like the following line to CONFIG.SYS

    SHELL=C:\COMMAND.COM C:\ /E:2048 /P

HXRT config
===========

<https://github.com/Baron-von-Riedesel/HX>

Make sure to set the HX environment before running HXLDR32:

    SET DPMILDR=136
    SET HDPMI=32

Otherwise you may have trouble spawning sub-processes.

msvcrt.dll
==========

By default, TCC is linked against the Watcom libc.  To link against
the Windows libc, edit mkall.bat and change LIBC to msvcrt.  The
MSVCRT.DLL from ReactOS 0.4.15 is good enough to run hello world,
but not good enough for TCC to build itself on DOS.  For that i used
MSVCRT.DLL 7.0.2600.2180 from Windows PE 1.5.

    (md5) b0fefa816d61ec66aa765ddf534eab5e MSVCRT.DLL

See also:

MSVCRT.DLL is not an official part of Windows
<https://web.archive.org/20160309200927/
https://blogs.msdn.microsoft.com/oldnewthing/20140411-00/?p=1273>

msvcrt-xref.pdf
<https://sourceforge.net/projects/mingw/files/MinGW/Base/mingwrt/

the _MSVCRT_ macro is really not all that important here; it's just
telling <stdio.h> to use the latest MSVCRT.dl as opposed to "old"
versions of it.  Newer MSVCRT.dll only comes with _iob, because
_imp___iob has been deprecated.

<https://lists.gnu.org/archive/html/tinycc-devel/2024-11/
msg00063.html>

How to list DLLs used
=====================

The source code includes ldd.bat which uses Watcom's wdump.exe to
report which DLLs an EXE is linked to.
