Skip to content

Delphi: link sqlite3 statically via FireDAC.Phys.SQLiteWrapper.Stat - #135

Merged
FMXExpress merged 2 commits into
mainfrom
claude/delphi-sqlite-static
Jun 6, 2026
Merged

FMXExpress merged 2 commits into
mainfrom
claude/delphi-sqlite-static

Conversation

@FMXExpress

Copy link
Copy Markdown
Owner

Summary

Pulls FireDAC.Phys.SQLiteWrapper.Stat into the dpr so the SQLite amalgamation is linked statically into pasclaw.exe — no sqlite3.dll needs to ship alongside the binary. PasClaw.Memory.Index (FTS5 for memory_search) is the only consumer today; the existing FireDAC connection just stops resolving the DLL at startup.

Guarded with {$IFNDEF FPC} since the unit is part of FireDAC and only exists on the Delphi side. FPC keeps its dynamic libsqlite3 link path unchanged.

Test plan

  • FPC make clean && make — clean (the guard skips the unit).
  • Delphi build — confirm pasclaw.exe runs memory_search without a sqlite3.dll next to it.

https://claude.ai/code/session_01TBcLtmpj7dqA5tyFbGnQon


Generated by Claude Code

PasClaw.Memory.Index opens an SQLite FTS5 database for memory_search.
On the Delphi side that goes through FireDAC + an external
sqlite3.dll alongside pasclaw.exe — one more file the user has to
ship next to the binary.

Pulling FireDAC.Phys.SQLiteWrapper.Stat into the dpr's uses clause
links the SQLite amalgamation directly into the executable, so the
DLL is no longer required. Guarded with {$IFNDEF FPC} because the
unit is part of FireDAC (Delphi-only); FPC keeps its dynamic
libsqlite3 link path unchanged.

https://claude.ai/code/session_01TBcLtmpj7dqA5tyFbGnQon

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: a02fb4166b

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/pasclaw/PasClaw.dpr
Comment on lines +25 to +26
{$IFNDEF FPC}
FireDAC.Phys.SQLiteWrapper.Stat, { Link sqlite3 statically into the exe so

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Keep static SQLite unit out of Delphi Linux builds

This guard includes FireDAC.Phys.SQLiteWrapper.Stat for every non-FPC build, including the Delphi Linux64 target declared in PasClaw.dproj. RAD Studio's SQLite/FireDAC docs list static SQLite libraries for Windows/macOS/mobile but state that FireDAC on Linux supports only dynamic linking, so the Delphi Linux build will now try to compile/link the static wrapper even though that platform must continue using libsqlite3.so. Please narrow this to the Windows Delphi platforms (or otherwise exclude Linux64) so the existing Delphi Linux target is not broken.

Useful? React with 👍 / 👎.

Codex P1 on PR #135: the existing {$IFNDEF FPC} guard pulled
FireDAC.Phys.SQLiteWrapper.Stat into every non-FPC compile,
including Delphi's Linux64 target declared in PasClaw.dproj. RAD
Studio's FireDAC for Linux only supports dynamic linking against
libsqlite3.so — the static SQLite wrapper unit ships for Windows /
macOS / mobile only, so attempting to use it on Delphi Linux64
breaks the build (unit-not-found).

Nest a second guard `{$IFNDEF LINUX}` inside the existing
`{$IFNDEF FPC}` so:

  Delphi Windows / macOS / iOS / Android   include static unit
                                            (sqlite3 in the .exe,
                                             no DLL to ship)
  Delphi Linux64                            skip static unit; the
                                            existing dynamic
                                            libsqlite3.so path
                                            keeps working
  FPC any-OS                                skip (unchanged)

No FPC behaviour change; FPC's link path was already untouched by
the outer guard. `make` clean on Linux/FPC.
@FMXExpress
FMXExpress merged commit 2f02cbd into main Jun 6, 2026
FMXExpress pushed a commit that referenced this pull request Jun 7, 2026
Codex noted that registering LocalVector.VectorStore.FireDAC in
PasClaw.dproj would break the Delphi Linux64 build: that unit pulls
FireDAC.Phys.SQLiteWrapper.Stat into its uses clause, and RAD Studio
only ships the static SQLite wrapper for Windows / macOS / mobile —
exactly the same constraint PasClaw.dpr's {$IFNDEF LINUX} guard
addresses (PR #135). The Linux64 hybrid backend needs to use the
dynamic libsqlite3.so path; we have it already in the portable
backend (LocalVector.VectorStore.Sqlite), the factory just wasn't
routing through it on Linux64.

Two-file fix (both modifications scoped to PasClaw — clearly marked
in the file header so a future upstream resync sees them):

  LocalVector.VectorStore.pas — force-define LV_PORTABLE_SQLITE on
    Delphi Linux64 right after the {$mode} directive. The factory's
    existing  {$IFDEF LV_PORTABLE_SQLITE}  branch already routes
    through TSqliteVectorStore (dynamic libsqlite3 + dynamically-
    loaded vec0), which works on Linux64. FPC paths untouched.

  LocalVector.VectorStore.FireDAC.pas — stub the entire unit body on
    Delphi Linux64. The pattern is

      {$IF DEFINED(LINUX) AND NOT DEFINED(FPC)}
      interface
      implementation
      end.
      {$IFEND}

    inserted before the original `interface`. dcc64 hits `end.` on
    Linux64 and stops, never reaching the FireDAC.Phys.SQLiteWrapper.Stat
    import. Every other Delphi target (and every FPC target) hits the
    false branch of the {$IF} and compiles the original implementation
    unchanged.

Backend matrix after this fix:

  Delphi Windows / macOS / mobile  → FireDAC backend
                                     (static SQLiteWrapper.Stat,
                                      unchanged from upstream)
  Delphi Linux64                   → portable Sqlite backend
                                     (dynamic libsqlite3.so,
                                      same path the Linux64 PasClaw.dpr
                                      build uses since PR #135)
  FPC any-OS                       → portable Sqlite backend
                                     (unchanged)

Per-file modification headers preserved per the in-tree localvector
attribution convention; both new guards are marked as PasClaw
modifications so a future upstream resync can see exactly what we
changed.

Verified: FPC build still clean (the {$IF} on FPC evaluates to false
since NOT DEFINED(FPC) is false, so both files behave as before).
Full test suite green: smoke + hashline + toolview +
anthropic-server-tools + openai-server-tools + println-helper +
utf8-codepage-tag + gemini-schema-strip + markdown-render +
json-utf8-roundtrip.

Delphi-side verification (dcc64 on the actual Linux64 target) needs a
real Delphi compiler — not available in CI. The shape mirrors PR #135's
{$IFNDEF LINUX} pattern, which dcc64 accepts.
khongten001 pushed a commit to khongten001/PasClaw that referenced this pull request Jul 13, 2026
Two dcc64 errors against the just-merged PR FMXExpress#167:

  PasClaw.Memory.Index.pas(622): H2443
    Inline function 'TFDParam.SetAsInteger' has not been expanded
    because unit 'FireDAC.Stan.Param' is not specified in USES list

  LocalVector.VectorStore.FireDAC.pas(31): E2029
    'INTERFACE' expected but identifier 'guard' found
  LocalVector.VectorStore.FireDAC.pas(32): E2052
    Unterminated string
  LocalVector.VectorStore.FireDAC.pas(39): E2038
    Illegal character in input file: '}' (#$7D)
  LocalVector.VectorStore.pas(103): F2063
    Could not compile used unit 'LocalVector.VectorStore.FireDAC.pas'

The H2443 hint was always present but never surfaced as an error
before; the four E20xx errors are a regression my PR FMXExpress#167 stub
introduced. Both addressed here.

PasClaw.Memory.Index.pas:
  Added FireDAC.Stan.Param to the {$ELSE} branch of the FireDAC uses
  list (alongside the existing FireDAC.Comp.Client / Stan.Def /
  Stan.Async / DApt entries). The TFDParam.SetAsInteger call at
  line 622 ends up inlined now instead of dispatched through the
  vtable, and dcc64's H2443 hint goes away. No FPC behaviour change.

LocalVector.VectorStore.FireDAC.pas:
  My PR FMXExpress#167 stub-block comment used curly-brace delimiters and
  literally spelled out a {$IFNDEF LINUX} directive inside the
  comment text:

    { PasClaw modification: stub on Delphi Linux64.
      ... PasClaw.dpr already routes around this constraint
      (PR FMXExpress#135 added the {$IFNDEF LINUX}
      guard there); we extend ...
    }

  Curly-brace comments DO NOT NEST in Pascal, so dcc64 parses the
  inner {$IFNDEF LINUX} as a real compiler directive, then chokes
  on the closing `}` that was meant for the outer comment. PR FMXExpress#158
  hit the exact same trap in PasClaw.Providers.Gemini and switched
  to (* ... *) delimiters; same fix here. The comment text also no
  longer spells the directive verbatim — it references the
  source-level platform guard by its bare name — so a future
  reader doesn't accidentally re-introduce the trap by reformatting
  the comment back to curly braces.

  The actual stub directive

    {$IF DEFINED(LINUX) AND NOT DEFINED(FPC)}
    interface
    implementation
    end.
    {$IFEND}

  is unchanged. Behaviour matrix from PR FMXExpress#167 still holds:
    Delphi Windows / macOS / mobile  → FireDAC backend (unchanged)
    Delphi Linux64                   → portable Sqlite backend
                                       (LV_PORTABLE_SQLITE forced on
                                        by LocalVector.VectorStore)
    FPC any-OS                       → portable Sqlite backend

Verified: FPC build still clean. Full test suite green: smoke +
hashline + toolview + anthropic-server-tools + openai-server-tools +
println-helper + utf8-codepage-tag + gemini-schema-strip +
markdown-render + json-utf8-roundtrip.

Delphi-side verification needs a real dcc64 compiler — not available
here, but the comment-trap fix mirrors PR FMXExpress#158's exactly and the
FireDAC.Stan.Param edit is mechanical.
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