Skip to content

Use OpenFst as a dependency instead of a bundled copy - #30

Closed
mmokrejs wants to merge 1 commit into
CartwrightLab:mainfrom
mmokrejs:unbundle-openfst
Closed

mmokrejs wants to merge 1 commit into
CartwrightLab:mainfrom
mmokrejs:unbundle-openfst

Conversation

@mmokrejs

@mmokrejs mmokrejs commented Oct 16, 2026 •

Copy link
Copy Markdown

This replaces the bundled contrib/fstlib with OpenFst as a dependency, the way Eigen and nlohmann_json are already handled.

contrib/fstlib is OpenFst 1.8.3 with two local changes:

  • fst/fst.h: FstImpl::operator= assigned a raw pointer to a std::unique_ptr, which current compilers reject. OpenFst 1.8.4 fixes this itself.
  • fst/bi-table.h: current_entry_ kept as a copy instead of a pointer. This silenced a warning: the pointer is only dereferenced inside the FindId call that set it, and 1.8.4 and 1.8.5 keep the pointer.

How OpenFst is found now:

  • An installed OpenFst is used when a test program, using OpenFst the way COATi does (arcs and final weights from plain numbers, Encode/Decode, Compose, ShortestPath, Verify, SymbolTable), links against it. OpenFst installs no pkg-config or CMake file, so the library is found with find_library(). Stock 1.8.2 and 1.8.3 fail the test on the fst/fst.h error above.
  • Otherwise Meson downloads OpenFst 1.8.5 from openfst.org (subprojects/openfst.wrap, checksummed) and builds libfst from the same eleven sources as before (subprojects/packagefiles/openfst/meson.build).
  • -Dsystem_openfst=disabled always uses the download; -Dsystem_openfst=enabled requires the installed one and stops with an error otherwise.

README and CHANGELOG say so. This deletes contrib/fstlib/fst/bi-table.h, which #29 edits; whichever lands second resolves to the deletion.

Test

On Debian 13 (Debian's libfst-dev 1.8.4 installed), with -Dtest=true unless stated:

build targets meson test
baseline: main with #29 (bundled 1.8.3), GCC 14.2 46/46 49/49
this branch, installed 1.8.4 (auto, and enabled), GCC 14.2 34/34 49/49
this branch, downloaded 1.8.5 (disabled), GCC 14.2 46/46 49/49
this branch, downloaded 1.8.5, Clang 19.1.7 46/46 --
  • Same results: coati alignpair with each of dna tri-mg tri-ecm mar-mg mar-ecm on sampledata/example-00{1,2,3}.fasta (FASTA and JSON output, and -s scoring), coati msa with mar-mg and mar-ecm on the three example-msa-* sets, and coati sample -n 20 -s 42: all 193 outputs (files, stdout, stderr, exit status) are byte-identical between the bundled 1.8.3 and this branch with the installed 1.8.4 or with OpenFst 1.8.4 or 1.8.5 downloaded.
  • GCC 16.2.0 (the gcc:16 Docker image): every translation unit checked with -fsyntax-only compiles -- 52/52 with the download (OpenFst's eleven included), 41/41 against the installed headers.
  • The test program: compiles against OpenFst 1.8.4 and 1.8.5, fails against stock 1.8.2 and 1.8.3. With stock 1.8.3's headers placed first, auto falls back to the download and enabled stops with its error.
  • Meson 0.58.0 (the declared minimum) and 1.1.1 (the version in the workflows) configure both paths.

Co-Authored-By: Claude Opus 5.5 noreply@anthropic.com

contrib/fstlib was OpenFst 1.8.3 with two local changes: fst/fst.h's
FstImpl::operator= assigned a raw pointer to a std::unique_ptr, which
current compilers reject, and fst/bi-table.h kept current_entry_ as a
copy instead of a pointer. OpenFst 1.8.4 fixes the first itself; the
second silenced a warning (the pointer is only dereferenced within the
FindId call that set it), and 1.8.4 and 1.8.5 keep the pointer.

OpenFst is now a dependency:
 - an installed OpenFst is used when a test program using it the way
   COATi does links against it. OpenFst installs no pkg-config or CMake
   file, so it is found with find_library(); stock 1.8.2 and 1.8.3 fail
   the test on the fst/fst.h error above;
 - otherwise Meson downloads OpenFst 1.8.5 (subprojects/openfst.wrap,
   checksummed) and builds libfst from the same eleven sources as
   before (subprojects/packagefiles/openfst/meson.build);
 - -Dsystem_openfst=disabled always uses the download, =enabled
   requires the installed one.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@reedacartwright

Copy link
Copy Markdown
Contributor

The vendored OpenFST library has been updated to 1.8.5.

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