From 624e0cbff6f2756310e5364be524a6adb2ec6d48 Mon Sep 17 00:00:00 2001 From: nmlgc Date: Mon, 2 Aug 2021 22:13:10 +0200 Subject: [PATCH] [Readme] Add a workaround for `Error: Unable to execute command 'tlink.exe'` Caused by TCC needlessly copying the PATH variable into a 128-byte buffer. --- README.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/README.md b/README.md index f3c5ca2f..a2aca81a 100644 --- a/README.md +++ b/README.md @@ -145,6 +145,13 @@ The final executables will be put into `bin\th0?`, using the same names as the o ### Troubleshooting +* TCC compiles, but fails to link, with `Error: Unable to execute command 'tlink.exe'` + + **Cause:** To locate TLINK, TCC needlessly copies the `PATH` environment variable into a statically allocated 128-byte buffer. It then constructs absolute `tlink.exe` filenames for each of the semicolon- or `\0`-terminated paths, writing these into a buffer that immediately follows the 128-byte `PATH` buffer in memory. The search is finished as soon as TCC found an existing file, which gives precedence to earlier paths in the `PATH`. If the search didn't complete until a potential "final" path that runs past the 128 bytes, the final attempted filename will consist of the part that still fit into the buffer, followed by the previously attempted path. + + **Workaround:** Make sure that the `BIN\` path to Turbo C++ 4.0J is fully contained within the first 127 bytes of the `PATH` inside your DOS system. + (The 128th byte must either be a separating `;` or the terminating `\0` of the `PATH` string.) + * TLINK fails with `Loader error (0000): Unrecognized Error` on 32-bit Windows ≥Vista This can be fixed by configuring the NTVDM DPMI driver to be loaded into conventional memory rather than upper memory, by editing `%WINDIR%\System32\autoexec.nt`: