The threading surface is not where FPC code looks for it
- Type: compat (RTL parity) — Track B (
lib/rtl) - Status: backlog
- Opened: 2026-08-05
- Found by: writing the
tools/fpc_diff_probe.shthread cases. Every one needed a{$IFDEF FPC}split in itsusesline before it would build on both sides — which is the finding.
pxx has a real, working native TThread (lib/rtl/palthreadobj.pas, futex/PAL
based, no libc). The gap is entirely in where the names live and what they
look like, i.e. the mission's "compile real-world code as-is" line.
The four differences
TThreadis inpalthreadobj, notClasses. Every threaded FPC/Delphi program saysuses Classes. MakingClassesre-exportTThreadis the obvious fix and has a real cost to weigh:classescurrently does not depend on the thread machinery, and pullingpalthreadobjin makes every Classes-using program carry it. Worth a Track U call if the size/dependency trade-off is not obvious — do not just do it.- No
cthreadsunit. On Unix, FPC code must havecthreadsfirst in the program'suses, so portable sources start with{$IFDEF UNIX}cthreads,{$ENDIF}. pxx has no thread manager to install, so an empty compat shim unit would cost nothing and let those sources through unedited. WaitForis aprocedure. FPC's isfunction WaitFor: LongWord, returning the thread'sReturnValue, andr := t.WaitForis the common idiom. Today pxx compiles that expression and yields garbage — but that is a separate and much worse bug, filed as [[bug-p-procedure-method-in-an-expression-yields-garbage]]. Fixing that one turns this into an honest compile error; fixing this one makes the idiom work.BeginThread/EndThread/TThreadID/WaitForThreadTerminatedo not exist. The low-level FPC thread API.palthreadhas the machinery under its own names.
Already done, separately
InterLockedIncrement and family were missing entirely and now exist in
lib/rtl/palatomic.pas, verified identical to FPC across all eleven
return-value cases. They still need an explicit uses palatomic where FPC has
them in system — [[bug-a-interlocked-family-needs-a-uses-clause-unlike-fpc]].
Coverage
Six thread cases in tools/fpc_diff_probe.sh (thread-*). The ones this
ticket blocks are tagged [known]; thread-tthread-waitfor already passes, so
the core Create/Start/WaitFor/Finished path is verified against FPC today.
Gate
Track B: make lib-test / tools/gate.sh lib. If Classes gains the
re-export, re-check binary size on a Classes-only demo before and after.