Skip to content

Windows 2000 and XP

A sysroot built with WINNT=0x0500 (or 0x0501) makes C and C++ programs for Windows 2000 and XP with an NT 5 version in the triple.

Windows Triple Subsystem version
2000 i586-pc-windows5.0-gnu 5.00
XP i586-pc-windows5.1-gnu 5.01
Server 2003 i586-pc-windows5.2-gnu 5.02
LLVM_SRC=~/llvm MINGW_SRC=~/mingw-w64 BIN=~/llvm/build/bin \
  SYSROOT=~/xp-sysroot WINNT=0x0501 CPU=i586 sh scripts/build-win9x.sh
LLVM_SRC=~/llvm BIN=~/llvm/build/bin SYSROOT=~/xp-sysroot CPU=i586 \
  sh scripts/build-cxx.sh
clang --target=i586-pc-windows5.1-gnu --sysroot=$SYSROOT -fuse-ld=lld \
  hello.c -o hello.exe
clang++ --target=i586-pc-windows5.1-gnu --sysroot=$SYSROOT -fuse-ld=lld \
  -stdlib=libc++ hello.cpp -o hello.exe
  • Programs import the system msvcrt.dll, which both versions ship. It is older than Vista's: it has no _l functions (_strtod_l, _snprintf_l, ...), no _create_locale and no _s functions such as wcrtomb_s, and the 2000 one lacks a few XP additions. check-imports.py --nt 5.0 (or 5.1) checks each msvcrt.dll import against the version that first shipped it (msvcrt-versions.txt, made from mingw-w64's annotated list with gen-msvcrt-versions.py), and each kernel32 import against a list of functions added in XP, Server 2003, Vista and 7 (SRW locks, condition variables, InitOnce, Fls*, GetThreadId, GetTickCount64, GetActiveProcessorCount, ...).
  • Use i586 (Pentium) triples: 2000 and XP run on a Pentium, and i686 code has CMOV, which a Pentium MMX or K6 lacks. As for 9x, there is no SSE unless -march asks for it.
  • __thread and thread_local use emulated TLS, as with GCC: the clang in clang-dos/llvm uses it by default for MinGW triples below 6.0, since before Vista Windows sets up native TLS only for the program and the DLLs loaded with it, not for one loaded with LoadLibrary. -fno-emulated-tls turns it off.
  • build-cxx.sh adds a static libc++, libc++abi and libunwind (DWARF unwinding). With the sysroot's _WIN32_WINNT below 0x0600, the libc++ in clang-dos/llvm uses no Vista functions:
  • threads: std::mutex is a CRITICAL_SECTION and std::condition_variable a queue of waiting threads with an event each; call_once is an interlocked flag; thread-specific data uses TlsAlloc with destructors run from the mingw-w64 runtime's thread exit callback; std::thread::get_id uses NtQueryInformationThread when there is no GetThreadId; atomic::wait polls.
  • locales: a locale is its name, set with setlocale for each call that takes one. The "C" locale costs a setlocale(LC_ALL, NULL) per call. A named locale changes the process locale for the call, so formatting with a non-"C" locale in two threads at once can race.
  • <filesystem>: file information comes from NtQueryInformationFile. Windows before Vista has no symbolic links to files, so create_symlink fails with an error and canonical does not resolve junctions.
  • Windows 2000 needs Service Pack 4 for msvcrt.dll's _get_heap_handle, which XP has only from SP2; nothing in the sysroot imports it.
  • Wine runs the tests reporting Windows 2000 or XP, but Wine does not limit programs to that API, and no real 2000 or XP machine has run them yet. --dlls with DLLs copied from a real system checks every import.