Ann: SWI-Prolog 9.1.15

Dear SWI-Prolog user,

SWI-Prolog 9.1.15 is ready for download. The changelog is long.
Highlights:

  • Various changes to the CMake files that allow adding the
    entire SWI-Prolog source tree using CMake’s add_subdirectory().
    This largely simplifies integrating SWI-Prolog from source
    in larger projects.

  • Support Microsoft Visual C++ compiler suite. This is
    responsible for most of the commits. As different compilers
    warn about different things quite a bit of (type) cleanup
    as needed. This fixed a few minor issues, one possible
    memory corruption on the Windows version of the xpce graphics
    system and a serious bug in udp_receive/4. These changes
    also cleaned up running the system in the build directory.
    Not well tested. Runs about 20% slower than MinGW version.

    See Building SWI-Prolog on MS-Windows for details.

  • Ongoing work on the Janus Python interface. Several bug fixes,
    Unicode support for function and method names, more compatibility
    with the XSB version. Discussions on improving and fixing
    details on the API are ongoing.

  • Avoid dependency of the core on the clib package and its foreign
    code for dealing with ULRs and timing. This code was used by
    library(ansi_term), dealing with color output to terminals.
    This simplifies saved states that only depend on Prolog code.
    After comments from @peter.ludemann.

  • Added checking options passed to predicates as part of check/0.
    Updated these checks after discussion with @peter.ludemann.

  • Over 2 times faster nth1/3 after comments from @brebs

    Enjoy — Jan

SWI-Prolog Changelog since version 9.1.14

  • BUILD: Avoid dependency on Threads::Threads when building single
    threaded. This applies to the packages and blocks e.g., the WASM
    build.

  • DOC: check/0 Document new checks and using check/0 for batch mode
    static analysis (linter).

  • ADDED: check/0: run check_predicate_options/0.

  • FIXED: check_predicate_options/0: avoid several false warnings.

  • ADDED: must_be/2: type list_or_partial_list(Type)

  • DOC: open/4 reposition option.

  • MODIFIED: Disable toplevel variables if the flag toplevel_var_size
    is 0

  • ENHANCED: Performance of nth1/3 and nth0/3 for mode (-,+,?)

  • PORT: Remove emacs module declarations from SWI-Prolog.h The symbols
    must be exported, but we should not declare them as part of the API
    as that prevents building the sweep module. In MSVC the linkage
    options for exported and imported data is different.

  • FIXED: Recompilation logic may use an erased clause If the newly
    compiled clause is equal to the “current” clause, the new clause is
    destroyed and the old is kept. We must however check that the “old”
    is not yet erased.

  • FIXED: Message translation for trace(Head, Ports) getting location
    of predicate wrong and ansi_hyperlink/3 printed the URL rather than
    the label if the terminal does not support hyperlinks.

  • ENHANCED: Avoid dependency of library(ansi_term) on package clib

  • ENHANCED: ansi_get_color/2 to use stream timeouts Old version used
    call_with_time_limit/2, but this is in a library, pulls in a shared
    object dependency and requires threads.

  • BUILD: Allow building the manuals in non-Unix environments.

  • PORT: Find local home more flexible. Normally swipl is in src, but
    using some backends there can be a configuration directory in between.

  • PORT: Property configure threads for packages.

  • FIXED: bf_set_ui(): uint32_t >> 32 is undefined.

  • CLEANUP: signed/unsigned and other warnings for bf_gmp.c

  • CLEANUP: Resolve signed/unsigned comparison and negation of unsigned
    ints.

  • PORT: Make multi-threading work with MSVC version - Allow using
    vcpkg package pthreads for threading. - Port atomic operations
    to use the MSVC _Interlocked* intrinsics - Sync thread config for
    swipl-win.exe with libswipl.dll.

  • PORT: Make LibBF compile using MSVC Now compiles with many warnings.
    Basics seem to work.

  • PORT: Empty struct support for pl-wam.c

  • FIXED: set_prolog_gc_thread/1: no-op in the single-threaded version.

  • PORT: Introduce free() for LibBF memory management. LibBF uses
    realloc(ptr,0) rather than free, but this is not-portable and
    flagged by the latests versions of valgrind.

  • BUILD: Work around problem generating Unix Makefiles

  • CLEANUP: Remove swipl.home and swipl.rc from the source root dir.

  • PORT: Fix various warnings generated by MSVC2022

  • BUILD: Simplify build_home.pl

  • BUILD: More patches to allow building as a CMake subdir. These patches
    notably deal with the package locations and documentation.

  • BUILD: Allow building as a sub project from a larger CMake project This
    patch replaces use of CMAKE_SOURCE_DIR with CMAKE_CURRENT_SOURCE_DIR,
    so we can do

    add_subdirectory(swipl)
    

    in a larger project.

  • FIXED: Typo in check_installation/0 (syntax error)

  • PORT: WASM: Do not try to get ioctl support.

Package clib

  • TEST: Use PlUnit for the socket tests.

  • FIXED: udp_receive/4: did not pass address parameters correctly.

  • PORT: MSVC Avoid issues with different address length and buffer
    size types.

  • PORT: Support MSVC. Mostly silence warnings, improved types,
    fixed headers.

Package cpp

  • PORT: MSVC work-arounds for compiling the tests. MSVS requires
    C++20 for the blob type initialization.

  • FIXED: likes.cpp sample code

Package http

  • FIXED: Several predicate options declarations.

  • PORT: Support MSVC Cleanup types.

Package inclpr

  • PORT: MSVC Cleanup old code.

Package ltx2htm

  • PORT: Support MSVC Silence warnings, cleanup types.

Package mqi

  • BUILD: Avoid dependency on CMAKE_SOURCE_DIR

Package nlp

  • PORT: Suppress MSVC warnings

Package odbc

  • PORT: MSVC Cleanup types (introduce more size_t)

Package pcre

  • PORT: MSVC Avoid type warnings.

Package pengines

  • FIXED: Predicate option declarations.

Package protobufs

  • PORT: MSVC Cleanup float32 and int32 handling.

Package semweb

  • FIXED: Predicate options declarations.

  • PORT: MSVC Type cleanup, added atomic versions.

Package sgml

  • PORT: MSVC More portable types and avoid possible overflows by
    using size_t

  • PORT: Support MSVC Suppress warnings, support MSVC atomic intrinsics.

Package ssl

  • PORT: MSVC Make configure work by removing z.lib dependency when not
    using MinGW and avoid several type errors.

  • PORT: MSVC doesn’t allow for array declaration from const int.
    Also use MSVC intrinsics for atomic operations.

  • FIXED: Return type for Prolog term.

Package sweep

  • PORT: MSVC Need to get DLL linkage correct. This also requires a
    change in SWI-Prolog.h

  • PORT: Include local copy of emacs-module.h in case this is not
    provided.

Package swipy

  • ADDED: Allow evaluation of arguments. If the construct Obj:Method
    or Module:Func is encountered in a data structure it is evaluated.

  • FIXED: Support Unicode attribute and function names.

  • ADDED: built_in pseudo module Allows for
    py_call(built_in:print(“Hello”)) in addition to
    py_call(print(“Hello”)). This patch also allows evaluating a plain
    atom to its module for consistency. Finally, this patch avoids a
    crash on py_call(sys, R).

  • FIXED: Avoid string stack overflow calling Prolog from Python

  • FIXED: px_comp() when using DELAY_LISTS

  • ENHANCED: Avoid conflict with Python module “swipl” As janus.py
    first tries to load swipl it may load the FFI based interface to
    SWI-Prolog. We renamed the internal module to _swipl to avoid
    that possible conflict.

  • FIXED: Calling methods with only keyword arguments

  • PORT: MSVC Pragma cleanup and cleaner way to deal with Python3.dll
    compatibility library

Package table

  • PORT: MSVC

Package tipc

  • FIXED: library(tipc/tipc_linda): Did not load
    library(tipc/tipc_broadcast).

Package xpce

  • FIXED: Windows possible memory corruption due to long/intptr_t mismatch

  • PORT: MSVC - Avoid dependency on globbing in CMake command by
    using CMake file(GLOB) - Suppress compiler warnings on data loss and
    signed/unsigned types - Small typing cleanup. - Avoid RedrawWindow()
    (renamed to pceRedrawWindow()) - Fix SendFunc casting - Avoid conflict
    over “small”!?

  • PORT: Include Win32 port of Xpm dependency This simplifies the
    build process. The code has been included and updated to avoid many
    compiler warnings.

  • PORT: C11 compatibility

  • BUILD: Copy swipl-rc to home/xpce/prolog This is the only file
    that required running the binary without installation that was in
    the source. By copying it to the binary pre-stage home dir we can
    greatly simplify build_home.pl

Package yaml

  • PORT: MSVC

Package zlib

  • FIXED: Predicate options declarations.
3 Likes

The tgetent problem has reappeared (Apple M1, clang15). Not on my Windows computer, but on a CRAN testing machine, see here: https://www.stats.ox.ac.uk/pub/bdr/M1mac/rswipl.log

Some thoughts on this: man tgetent says that both curses.h and term.h need to be included, e.g. tgetent(3) - Linux man page . I can see something similar in pl-term.c, but it does not match 100%:

#if !defined(HAVE_TERM_H) && !defined(HAVE_NCURSES_TERM_H) && !defined(HAVE_CURSES_H)
/* Some systems seem not to have the headers ... */
#undef HAVE_TGETENT
#endif

I don’t know if ncurses.h is relevant in that context, so let’s simplify it for a moment:

#if !defined(HAVE_TERM_H) && !defined(HAVE_CURSES_H)

I think it should rather be an “or”,

#if !defined(HAVE_TERM_H) || !defined(HAVE_CURSES_H)

Assuming that ncurses.h may act as a replacement for curses.h, the original requirement would be term and (curses or ncurses), its negation -term or -(curses or ncurses), that is, -term or (-curses and -ncurses).

#if !defined(HAVE_TERM_H) || (!defined(HAVE_NCURSES_TERM_H) && !defined(HAVE_CURSES_H))
/* Some systems seem not to have the headers ... */
#undef HAVE_TGETENT
#endif

I hope this makes any sense. I cannot test it, unfortunately.

I think it does. Most likely the thing broken is this Mac. Works fine on my M1 with latest MacOS and Xcode. That Mac has the function as well as <ncurses.h>, so not having <term.h> is weird.

tgetent() is a good old portability nightmare for which I now added this code and comment

#if !defined(HAVE_TERM_H) || !defined(HAVE_CURSES_H)
/* system does not seem to have the headers.  In the old days there
   was a lot of variation in the required headers, so we looked for
   all headers that could have the tgetent() and checked for the
   function and then just included all relevant headers available.

   It seems that modern systems settled on <term.h> and <curses.h>,
   so we'll simply demand these.

   Note that for most modern compiler a lacking prototype is a real
   error, so not having the prototype is as bad as not having the
   function.
*/
#undef HAVE_TGETENT
#endif

Now just hope this won’t break anything else … Over the decades, there were about 5 headers involved, so quite some possibilities :frowning: