← board

The futex helpers are trapped behind __pxxclone

The shape

PalFutexWait, PalFutexWaitTimeout and PalFutexWake are three-line __pxxrawsyscall(SYS_futex, ...) wrappers. They live in lib/rtl/palthread.pas — which also contains __pxxclone. Reaching that unit at all fails the compile:

error: __pxxclone (thread creation) requires --threadsafe or {$threadsafe on}:
the default heap/ARC/console-I/O runtime is not thread-safe

That gate is right for thread creation. It is wrong for waiting on a word, which needs no thread-safe heap and no threads at all to compile.

What it has already cost

The fix

Move the three futex wrappers (plus the SYS_futex/FUTEX_WAIT/FUTEX_WAKE constants and whatever per-arch {$ifdef} block they need) into a new dependency-free lib/rtl/palfutex.pas, the way palatomic is dependency-free. Then:

Current PalFutex* callers: palthread, palthreadobj, palpthread, palsync, palparallel.

Gate

Track B: tools/gate.sh lib. Also rebuild the threading demos and re-run tools/fpc_diff_probe.sh's thread-* cases — thread-critical-section is the one that proves the lock still excludes.