Ann: SWI-Prolog 10.1.1 (devel)

Dear SWI-Prolog user,

SWI-Prolog 10.1.1 is ready for download. Highlights:

  • Tighten code sanity, mostly by @mgondan1. See UBSAN topics below.
    Also other minor code cleanup.

  • Fixed broken WASM build

  • Enhancements and fixes to JSON RPC libraries.

  • Several fixes and enhancements to XPCE. Fixed the thread monitor,
    avoid crashes on partial object initialization and further fixes and
    enhancements to the LSP support.

    Enjoy and may 2026 be a good Prolog year!

    – Jan

SWI-Prolog Changelog since version 10.1.0

  • ENHANCED: edit/1: if multiple hits are in the same file, take most
    specific. Thus, if both the file and some object inside the file
    match, use the object. Also xpce classes are more specific that the
    module they are contained in.

  • FIXED: edit/1 for normal predicates. Broken after integrating
    foreign predicates.

  • FIXED: UBSAN: Calling event handler with too many arguments.

  • UBSAN: Avoid offset to NULL pointer

  • UBSAN: Possible increment of NULL pointer This is benign, but
    officially undefined.

  • FIXED: Type handling for PL_thread_at_exit(). Resulted in reported
    undefined behaviour due to non-matching function prototype.

  • CLEANUP: Unconditionally use fpclassify() This is available on any
    system providing C99 and we already demand C11.

  • PORT: Make compile using Emscripten

Package json

  • FIXED: Server side handling for methods without parameters.
    Now accepts omitted params field as well as "params": {} as
    valid input for such a method.

  • FIXED: Correctly call methods that take no parameters

  • ADDED: json_call/4: option async(:Goal) Extends async(true) to get
    an asynchronous reply.

  • FIXED: json_method/1: Avoid discontiguous messages

  • ADDED: Print a warning if the server receives a non-implemented
    notification.

  • ADDED: json_rpc_call/4, etc: option thread_alias(+Atom)

  • ADDED: JSON RPC server: set json_rpc_stream global variable while
    dispatching. This variable provides access to the underlying stream.
    This may be used to identify the connection.

Package libedit

  • FIXED: Build on Windows for enhanced background write handling.

  • ENHANCED: Refreshing the terminal on background writes.

Package utf8proc

  • FIXED: #1 UBSAN: adding to NULL pointer.

Package xpce

  • ENHANCED: editor->align: minimize the change This reduces
    change/undo info and keeps the buffer marked clean if no change
    happens.

  • FIXED: Collecting LSP change message could corrupt edit modifications.

  • ADDED: Broadcast pce_emacs(saved(Buffer)) when a buffer was saved.
    Can be used to trigger an LSP didSave() event, automatically recompile,
    etc.

  • FIXED: Avoid undefined @nil->update in bookmark handling.

  • ENHANCED: Only display output from help/1 in GUI when invoked from
    the gui.

  • ADDED: error->feedback type backtrace to force errors to dump
    a backtrace.

  • FIXED: Avoid memory corruption when ->initialise fails. The partial
    object may have references. If so, leave its final destruction to
    the reference count dropping to zero.

  • CLEANUP: Replace all calls to sprintf() with snprintf()

  • FIXED: Thread monitor. Broken due to changes to class image.
    New code is simplified by using image->fill and num rather than
    int|real type.

  • FIXED: image->fill to accept a colour. Filling with images is
    currently not supported.

6 Likes

Hi Jan . I am going to install this 10.1.1 , thanks . I wonder about the wasm update: what need I to do to update my wasm setup?
I’ll keep you informed.
Thanks for your help, and Happy New Year !
Jo.

Nothing special. 10.1.1 is not much different from 9.3.36. Devel series typically does not make big jumps except for occasional big rewrites. These happened in the 9.3 series, but they had few consequences for the Prolog user.

Many thanks Jan. So, it would be maybe wiser to wait that I take time to update my MX Linux to update all my SWI-Prolog setup, don’t you think so?

It all depends on what you care about, what you depend upon, which version you are upgrading from and which platform.

joseph@mx:~$ swipl --version
SWI-Prolog version 9.3.34 for x86_64-linux

It is the previous devel. version, and I plan to upgrade MX Linux 23 to 25, which needs backup, etc.

In that case I’d first update Linux. It will also give you a faster Prolog as more recent gcc versions typically produce faster code.

1 Like

Thanks Jan! By the way, CRAN is complaining again, so expect additional PRs to make a few more grumpy sanitizers happy. Oh my…

Hi Jan,

On MX Linux 25, fresh install of SWI-Prolog :

-- Build files have been written to: /usr/local/swipl-devel/build
root@mx:/usr/local/swipl-devel/build# ninja
ninja: error: 'man/ssl', needed by 'man/lib/prologpack.tex', missing and no known rule to make it
root@mx:/usr/local/swipl-devel/build# 

I do not know what I can do... 
Thanks for your help. 
Jo.

Seems you did not install the OpenSSL (or LibreSSL) dependency. Good advice is to run in the build directory

 cmake .

That should tell you about missing dependencies that have consequences.

Hi Jan,

I have finally succeeded to install the latest version of SWI-Prolog . But I do not succeed to install WASM in my laptop with Linux MX 25. I meet errors and errors and it is really complicated, more complicated than with the previous version.

configure: cmake -DCMAKE_INSTALL_PREFIX=/root/wasm -DPCRE2GREP_SUPPORT_JIT=OFF -G Ninja .. -DCMAKE_TOOLCHAIN_FILE=/usr/share/emscripten/cmake/Modules/Platform/Emscripten.cmake -DCMAKE_CROSSCOMPILING_EMULATOR=/usr/bin/node
CMake Deprecation Warning at CMakeLists.txt:106 (CMAKE_MINIMUM_REQUIRED):
  Compatibility with CMake < 3.10 will be removed from a future version of
  CMake.

  Update the VERSION argument <min> value.  Or, use the <min>...<max> syntax
  to tell CMake that the project requires at least <min> but has been updated
  to work with policies introduced by <max> or earlier.


-- Could NOT find BZip2 (missing: BZIP2_LIBRARIES BZIP2_INCLUDE_DIR) 
CMake Warning at CMakeLists.txt:129 (FIND_PACKAGE):
  By not providing "FindReadline.cmake" in CMAKE_MODULE_PATH this project has
  asked CMake to find a package configuration file provided by "Readline",
  but CMake did not find one.

  Could not find a package configuration file provided by "Readline" with any
  of the following names:

    ReadlineConfig.cmake
    readline-config.cmake

  Add the installation prefix of "Readline" to CMAKE_PREFIX_PATH or set
  "Readline_DIR" to a directory containing one of the above files.  If
  "Readline" provides a separate development package or SDK, be sure it has
  been installed.


CMake Warning at CMakeLists.txt:130 (FIND_PACKAGE):
  By not providing "FindEditline.cmake" in CMAKE_MODULE_PATH this project has
  asked CMake to find a package configuration file provided by "Editline",
  but CMake did not find one.

  Could not find a package configuration file provided by "Editline" with any
  of the following names:

    EditlineConfig.cmake
    editline-config.cmake

  Add the installation prefix of "Editline" to CMAKE_PREFIX_PATH or set
  "Editline_DIR" to a directory containing one of the above files.  If
  "Editline" provides a separate development package or SDK, be sure it has
  been installed.


CMake Error at CMakeLists.txt:498 (file):
  file STRINGS file "/usr/local/configure.ac" cannot be read.


CMake Error at CMakeLists.txt:518 (string):
  string sub-command REPLACE requires at least four arguments.
Call Stack (most recent call first):
  CMakeLists.txt:530 (PARSE_LIB_VERSION)


CMake Error at CMakeLists.txt:518 (string):
  string sub-command REPLACE requires at least four arguments.
Call Stack (most recent call first):
  CMakeLists.txt:531 (PARSE_LIB_VERSION)


CMake Error at CMakeLists.txt:518 (string):
  string sub-command REPLACE requires at least four arguments.
Call Stack (most recent call first):
  CMakeLists.txt:532 (PARSE_LIB_VERSION)


CMake Error at CMakeLists.txt:518 (string):
  string sub-command REPLACE requires at least four arguments.
Call Stack (most recent call first):
  CMakeLists.txt:533 (PARSE_LIB_VERSION)


CMake Error: File /usr/local/src/pcre2.h.in does not exist.
CMake Error at CMakeLists.txt:535 (CONFIGURE_FILE):
  CONFIGURE_FILE Problem configuring file


CMake Error: File /usr/local/libpcre2-posix.pc.in does not exist.
CMake Error at CMakeLists.txt:556 (CONFIGURE_FILE):
  CONFIGURE_FILE Problem configuring file


CMake Error: File /usr/local/libpcre2-8.pc.in does not exist.
CMake Error at CMakeLists.txt:560 (CONFIGURE_FILE):
  CONFIGURE_FILE Problem configuring file


CMake Error: File /usr/local/pcre2-config.in does not exist.
CMake Error at CMakeLists.txt:583 (CONFIGURE_FILE):
  CONFIGURE_FILE Problem configuring file


CMake Error: File /usr/local/src/pcre2_chartables.c.dist does not exist.
CMake Error at CMakeLists.txt:598 (CONFIGURE_FILE):
  CONFIGURE_FILE Problem configuring file


CMake Error: File /usr/local/cmake/pcre2-config.cmake.in does not exist.
CMake Error at CMakeLists.txt:1092 (configure_file):
  configure_file Problem configuring file


CMake Error: File /usr/local/cmake/pcre2-config-version.cmake.in does not exist.
CMake Error at CMakeLists.txt:1095 (configure_file):
  configure_file Problem configuring file


-- 
-- 
-- PCRE2-. configuration summary:
-- 
--   Install prefix .................. : /root/wasm
--   C compiler ...................... : /usr/local/wasm/emsdk/upstream/emscripten/emcc
--   C compiler flags ................ : -O3 -DNDEBUG
-- 
--   Build 8 bit PCRE2 library ....... : ON
--   Build 16 bit PCRE2 library ...... : OFF
--   Build 32 bit PCRE2 library ...... : OFF
--   Enable JIT compiling support .... : OFF
--   Use SELinux allocator in JIT .... : IGNORE
--   Enable Unicode support .......... : ON
--   Newline char/sequence ........... : LF
--   \R matches only ANYCRLF ......... : OFF
--   \C is disabled .................. : OFF
--   EBCDIC coding ................... : OFF
--   EBCDIC coding with NL=0x25 ...... : OFF
--   Rebuild char tables ............. : OFF
--   Internal link size .............. : 2
--   Parentheses nest limit .......... : 250
--   Heap limit ...................... : 20000000
--   Match limit ..................... : 10000000
--   Match depth limit ............... : MATCH_LIMIT
--   Build shared libs ............... : OFF
--   Build static libs ............... : ON
--      with PIC enabled ............. : OFF
--   Build pcre2grep ................. : ON
--   Enable JIT in pcre2grep ......... : OFF
--   Enable callouts in pcre2grep .... : ON
--   Enable callout fork in pcre2grep. : ON
--   Buffer size for pcre2grep ....... : 20480
--   Build tests (implies pcre2test .. : ON
--                and pcre2grep)
--   Link pcre2grep with libz ........ : ON
--   Link pcre2grep with libbz2 ...... : Library not found
--   Link pcre2test with libeditline . : Library not found
--   Link pcre2test with libreadline . : Library not found
--   Support Valgrind .................: OFF
--   Use %zu and %td ..................: AUTO
-- 
-- Configuring incomplete, errors occurred!
emcmake: error: 'cmake -DCMAKE_INSTALL_PREFIX=/root/wasm -DPCRE2GREP_SUPPORT_JIT=OFF -G Ninja .. -DCMAKE_TOOLCHAIN_FILE=/usr/share/emscripten/cmake/Modules/Platform/Emscripten.cmake -DCMAKE_CROSSCOMPILING_EMULATOR=/usr/bin/node' failed (returned 1)

I do not understand these errors with pcre2 that is said to be “optional”…

All the best,
Jo.

pcre2 is optional for building SWI-Prolog, but this seems an error building the dependency. If you don’t need regular expressions in Prolog, just ignore it and SWI-Prolog for WASM should still build. You may have to disable the pcre package, but probably it will drop it itself if libpcre cannot be found.

Thanks for your help Jan. I will insist to install wasm in my laptop with Linux MX 25. I’ll keep you informed.
All the best,
Jo.

Setting up EMSDK environment (suppress these messages with EMSDK_QUIET=1)
Adding directories to PATH:
PATH += /usr/local/wasm/emsdk
PATH += /usr/local/wasm/emsdk/upstream/emscripten

Setting environment variables:
PATH = /usr/local/wasm/emsdk:/usr/local/wasm/emsdk/upstream/emscripten:/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games:/sbin:/usr/sbin
EMSDK = /usr/local/wasm/emsdk
EMSDK_NODE = /usr/local/wasm/emsdk/node/22.16.0_64bit/bin/node
-- Configuring SWI-Prolog-10.1.1
-- Added packages  sgml: Required by package clib
-- Added packages  json: Required by package http
-- Added packages  RDF nlp zlib: Required by package semweb
Please use -DGMP_ROOT=dir to enable GMP on Emscripen
Please use -DGMP_ROOT=dir to enable GMP on Emscripen
-- Could NOT find LibUUID (missing: LIBUUID_INCLUDE_DIR UUID_LIBRARY) 
-- Could NOT find PCRE (missing: PCRE_LIBRARY PCRE_INCLUDE_DIR) 
-- Configuring done (0.9s)
-- Generating done (0.1s)
-- Build files have been written to: /usr/local/wasm/swipl-devel/build.wasm
root@mx:/usr/local/wasm/swipl-devel/build.wasm# ninja
ninja: error: '/lib/libgmp.a', needed by 'src/swipl.js', missing and no known rule to make it
root@mx:/usr/local/wasm/swipl-devel/build.wasm# ```

That's really hard...

Well … :slight_smile:

You either need to build and install GMP for Emscripten or pass -DUSE_GMP=OFF to cmake. That is the default as the libBF support for big nums is much smaller and avoids LGPL license issues (but GMP is faster, notably for rational numbers).

The normal procedure:

  • Choose a directory for your WASM dependencies and tools. Default is $HOME/wasm. If you using anything else, set the environment variable WASM_HOME.
  • Make sure emsdk is installed in that dir
  • Build the dependencies in subdirectories of this dir and make sure they install in {bin,lib,include} below thuis dir.
  • Go to the Prolog source tree
  • run mkdir build.wasm
  • cd into build.wasm and run ../scripts/configure. Check the messages.
  • If ok, run ninja.

See scripts/configure for details.

Many many thanks Jan, that is very helpful.

(By the way, this WASM Tinker has been improved, the job is almost done now).

Have a nice week-end and thank you again !

Dear Jan,

I successfully built SWI-Prolog for WebAssembly on Debian-based Linux (MX 25), but encountered two critical issues that need upstream attention:

1. CRITICAL: LibBF Build Failure on Emscripten

File: src/libbf/cutils.h
Issue: Uses GCC-specific __attribute__((assume(expr))) not supported by Emscripten

Error: Compilation fails without manual patching

Required fix:

c

// Line 32 and similar occurrences
#ifdef EMSCRIPTEN
#define ASSUME(expr) do {} while(0)
#else
#define ASSUME(expr) __attribute__((assume(expr)))
#endif

Without this patch, WASM compilation is impossible. This should be fixed upstream immediately, as it affects all users attempting WASM builds.

2. Missing SWI-Tinker

The interactive tinker shell was removed from the main repository on March 1, 2025 (commit 3db1890).

Issue: The old tinker code no longer works - wasm_query_loop/0 doesn’t exist in current WASM builds.

Questions:

  • Where is the new tinker? Separate npm package?
  • What’s the new API for interactive WASM shells?
  • Is there a migration path for existing users?

The tinker was essential for pedagogical use of WASM SWI-Prolog. Its disappearance without documentation creates a significant gap.

Test Results

After patching cutils.h:

  • :white_check_mark: All 51 tests passed (100%)
  • :white_check_mark: node src/swipl.js works perfectly
  • :cross_mark: Tinker unusable (API incompatibility)

Best regards,
Jo (with great help of claude.ai)

Works fine here as well as in the NPM package build. Using EMSDK 4.0.22 at the moment.

For migration you’ll have to compare the code. I think the changes are marginal. The old version was merely a PoC. Since, the WASM interface has been extended to support asynchronous Prolog goals and yield-based debugging. These allow for building proper interactive web applications, including a Prolog debugger. With this, Tinker got a bit too large to be just a demo for the WASM version, so it was turned into a distinct project.

Many thanks Jan, your reply is very helpful. As usual. I did not think to search on Github; I apologize. It seems to me that SWI-Prolog version 10.1.1 for x86_64-linux that I installed yesterday is quicker than 9.3, but it would not be really surprising. I will install the New SWI-Tinker soon. Thanks again, and have a nice Sunday.
All the best,
Jo.

This appears wrong. SWI-Prolog compiles fine with EMSDK 4.0.15. A clean build using EMSDK 4.0.22 crashes while building the .qlf files. I do not know the exact version of EMSDK that introduced this, neither whether it is an Emscripten or Prolog bug.

If anyone wishes to figure that out, please do and report!

1 Like