Regression: --foreign=save

There is a problem bundling dynamic libraries with stand alone binaries since 8.1.24 (8.1.25 also fails). I’ve reduced it to this sample:

$ cat /tmp/s.pl

#!/usr/sbin/swipl

:- use_module(library(main)).
:- use_module(library(inotify)).

:- initialization(main, main).

main(_) :-
   format('test',[]).

Running it from source is fine:

$ /tmp/s.pl                                                                                                                                                        
test

The stand-alone version fails:

$ /usr/sbin/swipl --stand_alone=true --foreign=save -o /tmp/s -c /tmp/s.pl                                                                                        
$ /tmp/s                                                                                                                                                          
ERROR: /home/u/.local/share/swi-prolog/pack/inotify/prolog/inotify.pl:44: Initialization goal raised exception:
ERROR: inotify4pl: cannot open shared object file: No such file or directory
ERROR: In:
ERROR:   [18] throw(error(shared_object(open,'inotify4pl: cannot open shared object file: No such file or directory'),context(...,_2872)))
ERROR:   [16] <meta call>
ERROR:   [15] with_mutex('$foreign',load_foreign_library(foreign(inotify4pl),inotify,default(install))) <foreign>
ERROR:   [12] '$run_init_goal'(shlib:load_foreign_library(...)) at /usr/lib/swipl/boot/init.pl:714
ERROR:   [11] catch(system:'$run_init_goal'(...),_3010,system:'$initialization_error'(_3032,...,...)) at /usr/lib/swipl/boot/init.pl:482
ERROR:   [10] catch_with_backtrace(system:'$run_init_goal'(...),_3068,system:'$initialization_error'(_3090,...,...)) at /usr/lib/swipl/boot/init.pl:532
ERROR: 
ERROR: Note: some frames are missing due to last-call optimization.
ERROR: Re-run your program in debug mode (:- debug.) to get more detail.
test%                                                                                                                                                                                     

Looks like --foreign=save is not saving the inotify4pl.so.

It saves fine as you can see using unzip -l /tmp/s, but restarting the state cannot find it. This bug seems to be there for quite a while. Fixed.

For those that can’t or do not want to rebuild from source, you can pick shlib.pl from the GIT repo and put it in the system library.

I wanted to thank you for the ‘philosophy’ with which you run the development of SWI-Prolog, namely: a Prolog that is practical, usable in real world research and applications, and not just in academic settings. I think this, accompanied with your best-in-class response time to any issues is what has made SWI-Prolog the best prolog in the Open Source world --and I would venture to say-- in the commercial world also.

Thanks again.

2 Likes