The problem is caused by ssl test. Disabling it makes build successful. Unfortunately, I was not able to find Debian CI logs (typical URLs and search for swi-prolog at [CI] give 404) for swi-prolog to figure out which change led to the bug.
[CI] https://ci.debian.net/