Skip to content

localvector: dlopen / dlsym for Delphi non-Windows (was: dcc64 Linux E2010/E2003) - #224

Merged
FMXExpress merged 1 commit into
mainfrom
claude/localvector-delphi-linux-fix
Jun 11, 2026
Merged

FMXExpress merged 1 commit into
mainfrom
claude/localvector-delphi-linux-fix

Conversation

@FMXExpress

Copy link
Copy Markdown
Owner

Summary

You reported:

[DCC Error] LocalVector.Sqlite3.pas(126): E2010 Incompatible types: 'PWideChar' and 'string'
[DCC Error] LocalVector.Sqlite3.pas(135): E2003 Undeclared identifier: 'GetProcedureAddress'

Both come from the {$ELSE} (non-Windows) branches in ldLib / ldProc assuming FPC's dynlibs unit is available. FPC's LoadLibrary takes a string and GetProcedureAddress accepts string + handle — but dcc64 on Linux has neither symbol. The {$ELSE} branch was unguarded for the Delphi-non-Windows case, so dcc64 hit the FPC-flavoured calls and errored.

Fix

Split the {$ELSE} branches into the existing FPC path and a new Delphi-Linux path that routes through Posix.Dlfcn:

  • LocalVector.Sqlite3.pas — , Posix.Dlfcn added to the uses clause for Delphi non-Windows. ldLib uses dlopen(PAnsiChar, RTLD_NOW) and casts the Pointer back to TOrdHandle (already NativeUInt on that target). ldProc uses dlsym.

  • onnxruntime_pas_api.pas — same pattern of bug (LoadLibrary(PChar) + GetProcAddress) which compiles on Delphi Windows but not Linux — the LoadLibrary PChar overload only ships in Winapi.Windows. Same split applied. The TOrtLibHandle alias also gets a NativeUInt branch for Delphi non-Windows since HMODULE is Winapi.Windows-only.

RTLD_NOW (not RTLD_LAZY) so a missing entrypoint surfaces here, not on the first call — matches what FPC's LoadLibrary does internally on POSIX, and what OrtRuntimeLoaded / Sqlite3Loaded ("is the dynamic library actually usable") are asking.

Test plan

  • FPC make smoke — all subcommands OK
  • FPC make test — full suite green
  • Delphi Linux: build via dcc64 on your box — should no longer fail with E2010 / E2003 at those line numbers

https://claude.ai/code/session_01TBcLtmpj7dqA5tyFbGnQon


Generated by Claude Code

…E2010/E2003)

The reported error chain:

  [DCC Error] LocalVector.Sqlite3.pas(126): E2010 Incompatible types:
              'PWideChar' and 'string'
  [DCC Error] LocalVector.Sqlite3.pas(135): E2003 Undeclared identifier:
              'GetProcedureAddress'

Both come from the `{$ELSE}` (non-Windows) branches in ldLib / ldProc
assuming FPC's dynlibs unit is available. FPC's LoadLibrary takes a
string and FPC's GetProcedureAddress accepts a string + handle -- but
dcc64 on Linux has neither symbol. The {$ELSE} branch is unguarded for
the Delphi-non-Windows case, so dcc64 errored out on the FPC-flavoured
calls.

Fix: split the `{$ELSE}` branches into the existing FPC path and a
new Delphi-Linux path that routes through Posix.Dlfcn:

  - Sqlite3.pas adds `, Posix.Dlfcn` to the uses clause for Delphi
    non-Windows. ldLib uses dlopen(PAnsiChar, RTLD_NOW) and casts
    the Pointer back to TOrdHandle (already NativeUInt on that
    target). ldProc uses dlsym.

  - onnxruntime_pas_api.pas had the same pattern (LoadLibrary(PChar)
    + GetProcAddress) which compiles on Delphi Windows but not on
    Linux -- LoadLibrary's PChar overload only ships in
    Winapi.Windows. Same split: dlopen / dlsym for the
    Delphi-non-Windows branch. The TOrtLibHandle alias also gets a
    NativeUInt branch for Delphi-non-Windows (HMODULE is
    Winapi.Windows-only and isn't visible on dcc64 Linux).

  - RTLD_NOW (vs RTLD_LAZY) so a missing entrypoint surfaces here,
    not on the first call. Matches what FPC's LoadLibrary does
    internally on POSIX, and what the OrtRuntimeLoaded /
    Sqlite3Loaded "is the dynamic library actually usable" check
    is asking when it returns True.

FPC smoke + full test suite still green; the Delphi-Linux build needs
to be verified by the user since this sandbox has no dcc64.

https://claude.ai/code/session_01TBcLtmpj7dqA5tyFbGnQon
@FMXExpress
FMXExpress merged commit 970bdd4 into main Jun 11, 2026
FMXExpress pushed a commit that referenced this pull request Jun 13, 2026
Both changelog files were stuck at the 2026-06-10 TUI / background-
subagent / session_search / tool-RPC entries. ~7 weeks of merged
PRs (#214 through #244) had landed without a corresponding entry in
either file -- the git log was the only record of features like the
knowledgebase, inbound MCP server mode, checkpoints + /undo,
heartbeat daemon, shell backends (local | docker), send_message,
promptware defense, Windows shell-output encoding fixes, fs_grep
ripgrep optimisations, OpenTelemetry traces, and `pasclaw agent
--quiet`.

Added (newest first):

  2026-06-13
    #244  agent --quiet log-level clamp

  2026-06-12
    #243  dcc64 search path + agent --quiet / -q
    #242  OpenTelemetry traces (OTLP/HTTP+JSON)
    #241  fs_grep tier 5+6 (byte walker + Boyer-Moore-Horspool)
    #240  fs_grep tier 1-4 (deferred hash + skip-dirs + binary
          sniff + size cap)

  2026-06-11
    #239  Windows shell output: auto-detect UTF-8 vs OEM
    #238  Hashline fs_read header mojibake fix (¶ vs ¶)
    #237  Windows shell output: OEM codepage decode

  2026-06-10
    #233  Shell backends (local | docker via IShellBackend)
    #232  Heartbeat daemon + reversible condensation (CCR)
    #230  send_message tool + condenser families + promptware
          defense + task-aware MEMORY.md slicing

  2026-06-09
    #223  /goal Ralph loop + judge model + JSON-aware condenser
    #222  /undo wired into agent + sample dprojs
    #221  Checkpoints (auto-snapshot + TUI /undo)
    #220  mcp catalog: lenient hub projector
    #219  mcp: SSE / Streamable HTTP / stdio hub transports
    #218  Inbound MCP server mode
    #217  onboard: offer to index docs into the knowledgebase
    #214  Knowledgebase (RAG over operator-curated docs)

Skipped from this changelog (build-system / Delphi-fix / FPC-fix
PRs visible in the git log but not user-facing features):
#215, #216, #224, #225, #226, #227, #228, #229, #231, #234, #236.

Both files (README.md and docs/changelog.md) updated with the same
entries -- intentional mirror so a reader on either surface sees
the same history. Same prose in both; same footnote refs at the
bottom.

Validated: every [#N] reference in both files has a matching [#N]:
URL footnote (no broken links).
khongten001 pushed a commit to khongten001/PasClaw that referenced this pull request Jul 13, 2026
…er, LongInt ref-counts)

Follow-up to FMXExpress#224. Three further errors surfaced under dcc64 on Linux:

LocalVector.Sqlite3.pas
  - The {...}-style comment I added in the uses-clause for the Delphi
    non-Windows branch quoted the literal token "{$ELSE}". Delphi parses
    {$...} directives even inside {...} comments, so the lexer saw a
    bare {$ELSE} with no matching {$IFDEF} and tripped over the line
    that followed (E2029, E2052). Switched the comment to paren-star
    delimiters which are not directive-active.
  - dlsym(Pointer(h), ...) where h: TOrdHandle = NativeUInt fails on
    dcc64 (UInt64 -> Pointer rejected as direct cast). Two-step cast
    via NativeUInt: Pointer(NativeUInt(h)).

onnxruntime_pas_api.pas
  - Same Pointer(UInt64) cast in ortDoGetProc -- two-step via
    NativeUInt(AHandle).

onnxruntime.pas
  - Smart-pointer ref counts were typed PLongint / TArray<LongInt>.
    On Delphi POSIX 64-bit LongInt is 64 bits (LP64), so
    TInterlocked.Increment(var Integer) / (var Int64) had no overload
    matching var LongInt and dcc64 rejected nine call sites (E2250).
    Narrowed to PInteger / TArray<Integer>: Integer is 32-bit on every
    supported target (FPC delphi-mode, Delphi Windows, Delphi Linux64),
    matching the intended ref-count width. Storage-only change -- all
    call sites already increment/decrement through Interlocked wrappers
    that accept Integer.

FPC build of the three files is clean (verified locally; pre-existing
PasClaw.Cmd.Agent.pas nested-procedure errors on main are unrelated).

https://claude.ai/code/session_01TBcLtmpj7dqA5tyFbGnQon
khongten001 pushed a commit to khongten001/PasClaw that referenced this pull request Jul 13, 2026
…ints

Two fixes:

LocalVector.Sqlite3.pas / onnxruntime_pas_api.pas -- the persistent
dcc64 Linux E2010 at the dlsym call (third round: Pointer(h) in FMXExpress#224,
Pointer(NativeUInt(h)) in FMXExpress#225, PPointer(@h)^ in FMXExpress#226 all drew the
same "Incompatible types: 'UInt64' and 'Pointer'"). Root cause was
on the other side of the call the whole time: Delphi's Posix.Dlfcn
declares dlopen returning NativeUInt and dlsym taking
(Handle: NativeUInt; ...) -- the RTL wraps the POSIX void* handle
as an ordinal, same as HMODULE on Windows. The error was the
PARAMETER rejecting our Pointer, not a failing cast. Fix: pass the
TOrdHandle / TOrtLibHandle (both = NativeUInt in this branch)
straight through with no cast, and drop the now-pointless cast on
the dlopen result too. Comments updated to stop claiming dlopen
returns a Pointer.

PasClaw.TUI.pas -- Codex P2 on PR FMXExpress#226 (legit): the FPC line-based
REPL's new /undo handler calls UndoTurns, but nothing on the FPC
startup path ever called InitCheckpoints (RewireCheckpoints is
Delphi-positioned-TUI-only), so the checkpoints module stayed
disabled and /undo always reported "checkpoints not enabled" even
with CheckpointsEnabled forwarded from config. TTUI.Run (FPC block)
now initializes checkpoints once before the REPL loop, keyed on the
same fixed 'fpc-tui-session' id HandleUserInput already uses for
the background-subagent coordinator (the FPC REPL is single-session
with no FSession).

FPC make smoke + full make test green.

https://claude.ai/code/session_01TBcLtmpj7dqA5tyFbGnQon
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants