Ann: SWI-Prolog 9.1.16

Dear SWI-Prolog user,

SWI-Prolog 9.1.16 is ready for download. Most of the work is on
(language) interfaces and portability. Highlights:

  • Several changes and enhancements to the Janus Python interface.

    • MODIFIED: In replies from Prolog, the logical truth is now represented
      using a key truth rather than status
    • More mature support for Well Founded Semantics undefined results.
    • Support round trip of Prolog rational numbers to Fraction
    • Support Python Enum.
    • Allow for eval(Term) in py_call/2 to evaluate arguments in
      Python expresions.
    • Updated the XSB inspired interface.
  • More work on the C++ interface by @peter.ludemann

  • Updated JPL .class files to Java 8 as the latest OpenJDK no longer
    handles version 7.

  • Several performance enhancements to arithmetic.

  • Fixed a memory leak in PL_put_term_from_chars() for numbers.

    Enjoy — Jan

SWI-Prolog Changelog since version 9.1.15

  • PORT: Partial work to allow MSVC build under Conda. This patch works
    around issues for CMake FindThreads.cmake. It also explicitly enables
    MSVC /MD to compile the packages if threading is enabled.

  • BUILD: Runtime configuration during boot for Windows As, on Windows,
    we install all DLLs in the same directory we do not need to add
    the package bin dirs to the foreign search path. But, we must use
    prolog_to_os_filename/2 to ensure proper handling of the search based
    on the executable.

  • FIXED: #1197 function cmpr failing for negative values.

  • FIXED: #1097 ctrl-C in read causes exit from REPL Fix consists of
    two parts. (1) if something (libedit) already set the stream error
    condition, make S__fillbuf() return with an error immediately and
    (2) do not abort the main query loop if we get an abort request.

  • DOC: additions and cleanup wrap_predicate/4, pack_install/1, handling
    blobs and streams from foreign code, returning from foreign predicates.

  • ENHANCED: Allow interrupts during evalExpression()

  • PORT: Make new stuff work again using MSVC

  • ENHANCED: dark theme arithmetic used blue on black. [no ci]

  • PERFORMANCE: Add shortcut to PL_unify_number() Add a shortcut for
    the typical case where the number is a small integer, the target is
    a variable and we are not short on stack space.

  • PERFORMANCE: Simplify clearNumber() Notably improves performance for
    float arithmetic.

  • FIXED: Memory leak in PL_put_term_from_chars() fast route. This
    function implements a fast route for integers and rationals and leaked
    the GMP/LibBF object for rationals and large integers.

  • ENHANCED: PL_get_float() to raise a float overflow on too large
    rational.

  • BUILD: Added scripts/configure This script is used for a long time
    to maintain multiple versions under the same source tree. See script
    for details. [no ci]

  • PORT: Work around broken MacOS versions lacking <term.h> Reported
    by Matthias Gondan after failing build for CRAN

  • FIXED: PL_get_nchars() and friends CVT_INTEGER handling Broken
    in 2ac1553770ac1a9d6753b8b6e72ac2028815a028

  • ADDED: PL_get_nchars(): CVT_XINTEGER Allow converting numbers to
    hexadecimal strings.

  • DOC: library(occurs) [no ci]

Package cpp

  • ENHANCEMENT: added PlAcquireStream

  • ENHANCED: AtomMap utility

  • DOC: blobs and exceptions

  • ENHANCED: std::string instead of char* in some calls (no code change
    needed) - Can add char* interface if needed for performance (unlikely)
    PlTerm(term_t) constructor is public, for consistency with PlAtom

Package jpl

  • UPDATED: Java standards from 7 to 8. Support for 7 is dropped from
    latest OpenJDK releases and 7 is officially EOL for a while.

Package swipy

  • DOC: Handling Undefined

  • ADDED: Class Undefined to deal with WFS undefined results.

  • MODIFIED: Renamed status and truth_vals to truth As decided in
    Janus meeting, September 20.

  • TEST: Install XSB test data if installation includes the tests

  • BUILD: Starting a pyproject.toml

  • DOC: Document handling virtual environments.

  • ADDED: Support Python virtual environments

  • ADDED: Pass instances of class Enum as name (atom).

  • FIXED: Avoid recursive errors crashing while janus.py is being loaded.
    It seems we cannot call certain APIs while processing an error.

  • ADDED: Map Prolog rational numbers to Python fractions.Fraction().

  • ENHANCED: Use hexadecimal conversion for bigints.

  • DOC: Included references

  • COMPAT: Sync py_func/3,4 and py_dot/4,5. Updated docs.

  • MODIFIED: Sync XSB view with current agreement. - pyfunc/3-5,
    pydot/4,5 renamed to py_func/3-5 and py_dot/4,5. - Deleted
    free_python_object/1 (=py_free/1)

  • MODIFIED: Rules when py_object(true) is effective

  • MODIFIED: Use eval(Term) to evaluate Python expressions inline.

  • MODIFIED: Prolog representation of Python sets to use py_set(List)
    Was pySet(List).

2 Likes

Under MSYS2-ucrt64, I get:

$ cmake ..
$ ninja
ninja: error: 'C:/msys64/ucrt64/lib/libpython3.dll.a', needed by 'src/janus.dll', missing and no known rule to make it

There is a /ucrt64/bin/libpython3.10.dll, as well as a /ucrt64/lib/libpython3.10.dll.a, which is correctly reported by message("${Python_LIBRARIES}") in the CMakeFile.

Workaround is cmake .. -DSWIPL_PACKAGES_PYTHON=OFF.

Under rtools31-ucrt64, I get:

$ PATH=/x86_64-w64-mingw32.static.posix/bin:$PATH cmake .. -DSWIPL_PACKAGES_PYTHON=OFF -DSWIPL_PACKAGES_X=OFF -DINSTALL_DOCUMENTATION=OFF
$ PATH=/x86_64-w64-mingw32.static.posix/bin:$PATH make
...
[ 81%] Building C object packages/ssl/CMakeFiles/plugin_crypto4pl.dir/crypto4pl.c.obj
In file included from C:/Users/matthias/Documents/swipl-devel/packages/ssl/crypto4pl.c:55:
C:/Users/matthias/Documents/swipl-devel/packages/ssl/cryptolib.c:54:1: error: static declaration of 'EVP_MD_CTX_free' follows non-static declaration
   54 | EVP_MD_CTX_free(EVP_MD_CTX *ctx)

Ahh, very vaguely, I remember this from months or even years ago. What was it…? I’ll search for a fix.

Solution: MINGW_ROOT must be defined,

PATH=/x86_64-w64-mingw32.static.posix/bin:$PATH cmake .. -DSWIPL_PACKAGES_PYTHON=OFF -DSWIPL_PACKAGES_X=OFF -DINSTALL_DOCUMENTATION=OFF -DMINGW_ROOT=/x86_64-w64-mingw32.static.posix/bin

This change in swipy/CMakeLists.txt made the compiler happy.

swipl_plugin(
    janus
    MODULE janus
    C_SOURCES janus/janus.c
    C_LIBS ${Python_LIBRARIES}            ****
    C_INCLUDE_DIR ${Python_INCLUDE_DIRS}  ****
    PL_LIBS janus/janus.pl
    PL_LIB_SUBDIR python
    PL_LIBS ${PYTHON_FILES})

I hope it is of any help. System is MSYS2, aka. MinGW.

I think the problem is that on Windows we use the generic python3.dll, but we do so without testing it exists. It is part of the Python binary installation, but apparently not of the MSYS2 version. Added a check.

1 Like

That sounds weird. Looks like it is picking up a wrong version of the headers? MINGW_ROOT points at a directory that has all the MinGW depedencies installed. That is supposed not to be a bin dir, but the dir above bin, lib and include.

I am not entirely sure what a line such as

AC_CHECK_FUNCS(EVP_MD_CTX_free OPENSSL_zalloc)

actually does, but if it does the same as check_symbol_exists(...), then it compiles and links a little program with a pointer to, e.g., EVP_MD_CTX_free. And the linker needs zlib.h under MinGW, which is only given if MINGW_ROOT has been defined.

  if(WIN32)
    set(OPENSSL_OS_LIBS ws2_32.lib gdi32.lib crypt32.lib)
    if(MINGW_ROOT)
      list(APPEND OPENSSL_OS_LIBS z.lib)
    endif()

It’s working, no need to change things here.

But it works for the wrong reason :frowning: Seems the condition is part of the MSVC porting work where zlib.lib is used from vcpkg and, called zlib1.lib and apparently not required to link OpenSSL. I think we must make this unconditional again and use ${ZLIB_LIBRARIES}

Finding the right conditions for differences in the configuration is quite a challenge :frowning:

edit: Pushed 86bf1a111390f7457e77f930fd5241999c2de472 to address this. Works for me using MinGW as well as MSVC. This code is only used on Windows, so other platforms are not affected.

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

Many thanks for this wonderful job !

When one installs swi-prolog via macports python’s latest release is also one of the dependencies, right? So one installs both swipl and python311 plus a bunch of other things. I was surprised to see that you don’t have to install it manually if you run “port install swi-prolog-devel”

PS: maybe the other thread with the announcement was more appropriate. This one is for arithmetics

Macports is fairly relaxed about big dependencies. As most Macports installations already have Python installed anyway, it is not that big. This is quit different from Debian that tries to keep packages small, such that you can configure a minimal system with exactly the stuff you need and as little as possible extras.

So, yes, Macports gives you a pretty much complete SWI-Prolog, possibly with some stuff you might not have wanted …

1 Like

Thanx a lot for the explanation. Regarding stuff one doesn’t want…well, you know if you put yourself in someone else’s hands or judgements…you have to accept what’s included in the package so to say. Of course whether this is fair or not remains an open issue. At least for me. But I’m more interested in what comes next than in brooding about the past (although it is meaningful to do so). Best things

PS: maybe “reflecting” is better than “brooding” which at least to my ears seems to have a negative connotation