Pack RocksDB, build fails on Ubuntu 22.04 LTS on WSL on Windows (reproducible)

Build of RocksDB for pack RocksDB fails and is reproducible.

OS: Ubuntu 22.04 LTS on WSL 2 on Windows 10
SWI-Prolog: 8.5.13

After first fail of building RocksDB pack, downloaded RocksDB into ~\rocksdb and successfully ran make all from rocksdb directory, all test were run during build.

Retired installing RocksDB pack again.

?- pack_remove(rocksdb).
true.

Verified that ~/.local/share/swi-prolog/pack was empty.

?- pack_install(rocksdb).
% Contacting server at https://www.swi-prolog.org/pack/query ... ok
Install rocksdb@0.8.0 from GIT at https://github.com/JanWielemaker/rocksdb.git Y/n?
% Cloning into '/home/groot/.local/share/swi-prolog/pack/rocksdb'...
% Contacting server at https://www.swi-prolog.org/pack/query ... ok
% "rocksdb.git" was downloaded 5 times
Package:                rocksdb
Title:                  SWI-Prolog interface to RocksDB
Installed version:      0.8.0
Author:                 Jan Wielemaker <J.Wielemaker@vu.nl>
Maintainer:             Jan Wielemaker <J.Wielemaker@cwi.nl>
Packager:               Jan Wielemaker <J.Wielemaker@cwi.nl>
Home page:              https://github.com/JanWielemaker/rocksdb
Download URL:           https://github.com/JanWielemaker/rocksdb.git
Run post installation scripts for pack "rocksdb" Y/n?Y
% git submodule update --init rocksdb
% Submodule 'rocksdb' (https://github.com/facebook/rocksdb) registered for path 'rocksdb'
% Cloning into '/home/groot/.local/share/swi-prolog/pack/rocksdb/rocksdb'...
% Submodule path 'rocksdb': checked out 'bd68bfb41b58dba4332045392cdbda4664b01e81'
% ROCKSDB_DISABLE_JEMALLOC=1 ROCKSDB_DISABLE_TCMALLOC=1 /usr/bin/gmake -j4 -C rocksdb static_lib EXTRA_CXXFLAGS=-fPIC EXTRA_CFLAGS=-fPIC USE_RTTI=1 DEBUG_LEVEL=0
% gmake[1]: Entering directory '/home/groot/.local/share/swi-prolog/pack/rocksdb/rocksdb'
% $DEBUG_LEVEL is 0
% Makefile:235: Warning: /usr/lib/swi-prolog/include" does not exist
%   GEN      util/build_version.cc
% $DEBUG_LEVEL is 0
% Makefile:235: Warning: /usr/lib/swi-prolog/include" does not exist
%   GEN      util/build_version.cc
%   CC       cache/clock_cache.o

...

%   CC       options/options_helper.o
ERROR: options/options_helper.cc: In function ‘rocksdb::Status rocksdb::GetStringFromStruct(const rocksdb::ConfigOptions&, const void*, const std::unordered_map<std::__cxx11::basic_string<char>, rocksdb::OptionTypeInfo>&, std::string*)’:
ERROR: options/options_helper.cc:767:19: error: loop variable ‘iter’ creates a copy from type ‘const std::pair<const std::__cxx11::basic_string<char>, rocksdb::OptionTypeInfo>’ [-Werror=range-loop-construct]
ERROR:   767 |   for (const auto iter : type_info) {
ERROR:       |                   ^~~~
% options/options_helper.cc:767:19: note: use reference type to prevent copying
%   767 |   for (const auto iter : type_info) {
%       |                   ^~~~
%       |                   &
%   CC       options/options_parser.o

...

%   CC       table/block_based/block_based_filter_block.o
% cc1plus: all warnings being treated as errors
% gmake[1]: *** [Makefile:2258: options/options_helper.o] Error 1
% gmake[1]: *** Waiting for unfinished jobs....
% gmake[1]: Leaving directory '/home/groot/.local/share/swi-prolog/pack/rocksdb/rocksdb'
% gmake: *** [Makefile:20: rocksdb/librocksdb.a] Error 2
ERROR: Process "process(/usr/bin/gmake,[])": exit status: 2
ERROR: In:
ERROR:   [25] throw(error(process_error(...,...),_17810))
ERROR:   [21] build_tools:build_step(build,_17854{env:[...|...],git:true,inquiry:true,pack:rocksdb,pack_version:1,src_dir:'/home/groot/.local/share/swi-prolog/pack/rocksdb',url:'https://github.com/JanWielemaker/rocksdb.git'},_17854{bin_dir:'/home/groot/.local/share/swi-prolog/pack/rocksdb',env:[...|...],git:true,inquiry:true,pack:rocksdb,pack_version:1,src_dir:'/home/groot/.local/share/swi-prolog/pack/rocksdb',url:'https://github.com/JanWielemaker/rocksdb.git'}) at /usr/lib/swi-prolog/library/build/tools.pl:110
ERROR:   [20] apply:foldl_([build,...|...],build_tools:build_step,_17854{env:[...|...],git:true,inquiry:true,pack:rocksdb,pack_version:1,src_dir:'/home/groot/.local/share/swi-prolog/pack/rocksdb',url:'https://github.com/JanWielemaker/rocksdb.git'},_17966) at /usr/lib/swi-prolog/library/apply.pl:316
ERROR:   [14] prolog_pack:pack_post_install(rocksdb,'/home/groot/.local/share/swi-prolog/pack/rocksdb',[git(true),...|...]) at /usr/lib/swi-prolog/library/prolog_pack.pl:1102
ERROR:    [9] toplevel_call('<garbage_collected>') at /usr/lib/swi-prolog/boot/toplevel.pl:1162
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.
   Exception: (21) build_tools:build_step(build, _14752{env:['PATH'='/usr/lib/swi-prolog/bin/x86_64-linux:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin', 'SWIPL'='/usr/lib/swi-prolog/bin/x86_64-linux/swipl', 'SWIPL_PACK_VERSION'=1, 'SWIPLVERSION'=80513, 'SWIHOME'='/usr/lib/swi-prolog', ... = ...|...], git:true, inquiry:true, pack:rocksdb, pack_version:1, src_dir:'/home/groot/.local/share/swi-prolog/pack/rocksdb', url:'https://github.com/JanWielemaker/rocksdb.git'}, _15194) ?
Full output
?- pack_install(rocksdb).
% Contacting server at https://www.swi-prolog.org/pack/query ... ok
Install rocksdb@0.8.0 from GIT at https://github.com/JanWielemaker/rocksdb.git Y/n?
% Cloning into '/home/groot/.local/share/swi-prolog/pack/rocksdb'...
% Contacting server at https://www.swi-prolog.org/pack/query ... ok
% "rocksdb.git" was downloaded 5 times
Package:                rocksdb
Title:                  SWI-Prolog interface to RocksDB
Installed version:      0.8.0
Author:                 Jan Wielemaker <J.Wielemaker@vu.nl>
Maintainer:             Jan Wielemaker <J.Wielemaker@cwi.nl>
Packager:               Jan Wielemaker <J.Wielemaker@cwi.nl>
Home page:              https://github.com/JanWielemaker/rocksdb
Download URL:           https://github.com/JanWielemaker/rocksdb.git
Run post installation scripts for pack "rocksdb" Y/n?Y
% git submodule update --init rocksdb
% Submodule 'rocksdb' (https://github.com/facebook/rocksdb) registered for path 'rocksdb'
% Cloning into '/home/groot/.local/share/swi-prolog/pack/rocksdb/rocksdb'...
% Submodule path 'rocksdb': checked out 'bd68bfb41b58dba4332045392cdbda4664b01e81'
% ROCKSDB_DISABLE_JEMALLOC=1 ROCKSDB_DISABLE_TCMALLOC=1 /usr/bin/gmake -j4 -C rocksdb static_lib EXTRA_CXXFLAGS=-fPIC EXTRA_CFLAGS=-fPIC USE_RTTI=1 DEBUG_LEVEL=0
% gmake[1]: Entering directory '/home/groot/.local/share/swi-prolog/pack/rocksdb/rocksdb'
% $DEBUG_LEVEL is 0
% Makefile:235: Warning: /usr/lib/swi-prolog/include" does not exist
%   GEN      util/build_version.cc
% $DEBUG_LEVEL is 0
% Makefile:235: Warning: /usr/lib/swi-prolog/include" does not exist
%   GEN      util/build_version.cc
%   CC       cache/clock_cache.o
%   CC       cache/lru_cache.o
%   CC       cache/cache.o
%   CC       cache/sharded_cache.o
%   CC       db/arena_wrapped_db_iter.o
%   CC       db/blob/blob_file_addition.o
%   CC       db/blob/blob_file_garbage.o
%   CC       db/blob/blob_file_meta.o
%   CC       db/builder.o
%   CC       db/c.o
%   CC       db/column_family.o
%   CC       db/compacted_db_impl.o
%   CC       db/compaction/compaction.o
%   CC       db/compaction/compaction_iterator.o
%   CC       db/compaction/compaction_job.o
%   CC       db/compaction/compaction_picker.o
%   CC       db/compaction/compaction_picker_fifo.o
%   CC       db/compaction/compaction_picker_level.o
%   CC       db/compaction/compaction_picker_universal.o
%   CC       db/convenience.o
%   CC       db/db_filesnapshot.o
%   CC       db/db_impl/db_impl.o
%   CC       db/db_impl/db_impl_compaction_flush.o
%   CC       db/db_impl/db_impl_debug.o
%   CC       db/db_impl/db_impl_experimental.o
%   CC       db/db_impl/db_impl_files.o
%   CC       db/db_impl/db_impl_open.o
%   CC       db/db_impl/db_impl_readonly.o
%   CC       db/db_impl/db_impl_secondary.o
%   CC       db/db_impl/db_impl_write.o
%   CC       db/db_info_dumper.o
%   CC       db/db_iter.o
%   CC       db/dbformat.o
%   CC       db/error_handler.o
%   CC       db/event_helpers.o
%   CC       db/experimental.o
%   CC       db/external_sst_file_ingestion_job.o
%   CC       db/file_indexer.o
%   CC       db/flush_job.o
%   CC       db/flush_scheduler.o
%   CC       db/forward_iterator.o
%   CC       db/import_column_family_job.o
%   CC       db/internal_stats.o
%   CC       db/logs_with_prep_tracker.o
%   CC       db/log_reader.o
%   CC       db/log_writer.o
%   CC       db/malloc_stats.o
%   CC       db/memtable.o
%   CC       db/memtable_list.o
%   CC       db/merge_helper.o
%   CC       db/merge_operator.o
%   CC       db/range_del_aggregator.o
%   CC       db/range_tombstone_fragmenter.o
%   CC       db/repair.o
%   CC       db/snapshot_impl.o
%   CC       db/table_cache.o
%   CC       db/table_properties_collector.o
%   CC       db/transaction_log_impl.o
%   CC       db/trim_history_scheduler.o
%   CC       db/version_builder.o
%   CC       db/version_edit.o
%   CC       db/version_edit_handler.o
%   CC       db/version_set.o
%   CC       db/wal_manager.o
%   CC       db/write_batch.o
%   CC       db/write_batch_base.o
%   CC       db/write_controller.o
%   CC       db/write_thread.o
%   CC       env/env.o
%   CC       env/env_chroot.o
%   CC       env/env_encryption.o
%   CC       env/env_hdfs.o
%   CC       env/env_posix.o
%   CC       env/file_system.o
%   CC       env/fs_posix.o
%   CC       env/io_posix.o
%   CC       env/mock_env.o
%   CC       file/delete_scheduler.o
%   CC       file/file_util.o
%   CC       file/filename.o
%   CC       file/random_access_file_reader.o
%   CC       file/read_write_util.o
%   CC       file/readahead_raf.o
%   CC       file/sequence_file_reader.o
%   CC       file/sst_file_manager_impl.o
%   CC       file/writable_file_writer.o
%   CC       logging/auto_roll_logger.o
%   CC       logging/event_logger.o
%   CC       logging/log_buffer.o
%   CC       memory/arena.o
%   CC       memory/concurrent_arena.o
%   CC       memory/jemalloc_nodump_allocator.o
%   CC       memory/memkind_kmem_allocator.o
%   CC       memtable/alloc_tracker.o
%   CC       memtable/hash_linklist_rep.o
%   CC       memtable/hash_skiplist_rep.o
%   CC       memtable/skiplistrep.o
%   CC       memtable/vectorrep.o
%   CC       memtable/write_buffer_manager.o
%   CC       monitoring/histogram.o
%   CC       monitoring/histogram_windowing.o
%   CC       monitoring/in_memory_stats_history.o
%   CC       monitoring/instrumented_mutex.o
%   CC       monitoring/iostats_context.o
%   CC       monitoring/perf_context.o
%   CC       monitoring/perf_level.o
%   CC       monitoring/persistent_stats_history.o
%   CC       monitoring/statistics.o
%   CC       monitoring/thread_status_impl.o
%   CC       monitoring/thread_status_updater.o
%   CC       monitoring/thread_status_updater_debug.o
%   CC       monitoring/thread_status_util.o
%   CC       monitoring/thread_status_util_debug.o
%   CC       options/cf_options.o
%   CC       options/db_options.o
%   CC       options/options.o
%   CC       options/options_helper.o
ERROR: options/options_helper.cc: In function ‘rocksdb::Status rocksdb::GetStringFromStruct(const rocksdb::ConfigOptions&, const void*, const std::unordered_map<std::__cxx11::basic_string<char>, rocksdb::OptionTypeInfo>&, std::string*)’:
ERROR: options/options_helper.cc:767:19: error: loop variable ‘iter’ creates a copy from type ‘const std::pair<const std::__cxx11::basic_string<char>, rocksdb::OptionTypeInfo>’ [-Werror=range-loop-construct]
ERROR:   767 |   for (const auto iter : type_info) {
ERROR:       |                   ^~~~
% options/options_helper.cc:767:19: note: use reference type to prevent copying
%   767 |   for (const auto iter : type_info) {
%       |                   ^~~~
%       |                   &
%   CC       options/options_parser.o
%   CC       port/port_posix.o
%   CC       port/stack_trace.o
%   CC       table/adaptive/adaptive_table_factory.o
%   CC       table/block_based/binary_search_index_reader.o
%   CC       table/block_based/block.o
%   CC       table/block_based/block_based_filter_block.o
% cc1plus: all warnings being treated as errors
% gmake[1]: *** [Makefile:2258: options/options_helper.o] Error 1
% gmake[1]: *** Waiting for unfinished jobs....
% gmake[1]: Leaving directory '/home/groot/.local/share/swi-prolog/pack/rocksdb/rocksdb'
% gmake: *** [Makefile:20: rocksdb/librocksdb.a] Error 2
ERROR: Process "process(/usr/bin/gmake,[])": exit status: 2
ERROR: In:
ERROR:   [25] throw(error(process_error(...,...),_17810))
ERROR:   [21] build_tools:build_step(build,_17854{env:[...|...],git:true,inquiry:true,pack:rocksdb,pack_version:1,src_dir:'/home/groot/.local/share/swi-prolog/pack/rocksdb',url:'https://github.com/JanWielemaker/rocksdb.git'},_17854{bin_dir:'/home/groot/.local/share/swi-prolog/pack/rocksdb',env:[...|...],git:true,inquiry:true,pack:rocksdb,pack_version:1,src_dir:'/home/groot/.local/share/swi-prolog/pack/rocksdb',url:'https://github.com/JanWielemaker/rocksdb.git'}) at /usr/lib/swi-prolog/library/build/tools.pl:110
ERROR:   [20] apply:foldl_([build,...|...],build_tools:build_step,_17854{env:[...|...],git:true,inquiry:true,pack:rocksdb,pack_version:1,src_dir:'/home/groot/.local/share/swi-prolog/pack/rocksdb',url:'https://github.com/JanWielemaker/rocksdb.git'},_17966) at /usr/lib/swi-prolog/library/apply.pl:316
ERROR:   [14] prolog_pack:pack_post_install(rocksdb,'/home/groot/.local/share/swi-prolog/pack/rocksdb',[git(true),...|...]) at /usr/lib/swi-prolog/library/prolog_pack.pl:1102
ERROR:    [9] toplevel_call('<garbage_collected>') at /usr/lib/swi-prolog/boot/toplevel.pl:1162
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.
   Exception: (21) build_tools:build_step(build, _14752{env:['PATH'='/usr/lib/swi-prolog/bin/x86_64-linux:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin', 'SWIPL'='/usr/lib/swi-prolog/bin/x86_64-linux/swipl', 'SWIPL_PACK_VERSION'=1, 'SWIPLVERSION'=80513, 'SWIHOME'='/usr/lib/swi-prolog', ... = ...|...], git:true, inquiry:true, pack:rocksdb, pack_version:1, src_dir:'/home/groot/.local/share/swi-prolog/pack/rocksdb', url:'https://github.com/JanWielemaker/rocksdb.git'}, _15194) ?

Also checked that lastest version of RocksDB pack was installed by checking against latest commit.

groot@Galaxy:~/.local/share/swi-prolog/pack/rocksdb$ sed -n '1084,1089p' cpp/rocksdb4pl.cpp
typedef enum
{ ENUM_ALL,
  ENUM_FROM,
  ENUM_PREFIX
} enum_type;

For % Makefile:235: Warning: /usr/lib/swi-prolog/include" does not exist
checked

groot@Galaxy:/usr/lib/swi-prolog/include$ ll
total 124
drwxr-xr-x  4 root root  4096 Jun 27 16:54 ./
drwxr-xr-x 12 root root  4096 Jun 27 16:54 ../
-rw-r--r--  1 root root 53564 Jun 22 04:51 SWI-Prolog.h
-rw-r--r--  1 root root 16706 Jun 22 04:51 SWI-Stream.h
-rw-r--r--  1 root root 29358 Jun 15 11:11 SWI-cpp.h
drwxr-xr-x  2 root root  4096 Jun 27 16:54 Yap/
drwxr-xr-x  2 root root  4096 Jun 27 16:54 sicstus/

EDIT

Running make in RocksDB directory for SWI-Prolog pack without clean first

groot@Galaxy:~/.local/share/swi-prolog/pack/rocksdb$ make
ROCKSDB_DISABLE_JEMALLOC=1 ROCKSDB_DISABLE_TCMALLOC=1 make -j4 -C rocksdb static_lib EXTRA_CXXFLAGS=-fPIC EXTRA_CFLAGS=-fPIC USE_RTTI=1 DEBUG_LEVEL=0
make[1]: Entering directory '/home/groot/.local/share/swi-prolog/pack/rocksdb/rocksdb'
$DEBUG_LEVEL is 0
  GEN      util/build_version.cc
  CC       options/options_helper.o
  CC       table/block_based/block_based_table_builder.o
  CC       table/block_based/block_based_table_factory.o
  CC       table/block_based/block_based_table_iterator.o
options/options_helper.cc: In function ‘rocksdb::Status rocksdb::GetStringFromStruct(const rocksdb::ConfigOptions&, const void*, const std::unordered_map<std::__cxx11::basic_string<char>, rocksdb::OptionTypeInfo>&, std::string*)’:
options/options_helper.cc:767:19: error: loop variable ‘iter’ creates a copy from type ‘const std::pair<const std::__cxx11::basic_string<char>, rocksdb::OptionTypeInfo>’ [-Werror=range-loop-construct]
  767 |   for (const auto iter : type_info) {
      |                   ^~~~
options/options_helper.cc:767:19: note: use reference type to prevent copying
  767 |   for (const auto iter : type_info) {
      |                   ^~~~
      |                   &
  CC       table/block_based/block_based_table_reader.o
  CC       table/block_based/block_builder.o
table/block_based/block_based_table_builder.cc: In member function ‘void rocksdb::BlockBasedTableBuilder::EnterUnbuffered()’:
table/block_based/block_based_table_builder.cc:1590:30: error: ‘block_rep’ may be used uninitialized [-Werror=maybe-uninitialized]
 1590 |       std::swap(*(block_rep->data), data_block);
      |                  ~~~~~~~~~~~~^~~~~
table/block_based/block_based_table_builder.cc:1587:41: note: ‘block_rep’ declared here
 1587 |       ParallelCompressionRep::BlockRep* block_rep;
      |                                         ^~~~~~~~~
  CC       table/block_based/block_prefetcher.o
cc1plus: all warnings being treated as errors
make[1]: *** [Makefile:2258: options/options_helper.o] Error 1
make[1]: *** Waiting for unfinished jobs....
cc1plus: all warnings being treated as errors
make[1]: *** [Makefile:2258: table/block_based/block_based_table_builder.o] Error 1
make[1]: Leaving directory '/home/groot/.local/share/swi-prolog/pack/rocksdb/rocksdb'
make: *** [Makefile:20: rocksdb/librocksdb.a] Error 2

EDIT

Found this RocksDB issue which might be related.


Noted on GitHub issues: #7

Any hints or solutions on how to get to a successful build?

Yes, this looks like a bug in RocksDB, and the error message makes sense if you’re familiar with C++ :wink:

It appears that the problem has been fixed in the github repository, so I suggest:

pack_remove(rocksdb).
pack_install(rocksdb).

to make sure you get the latest code – I tried pack_install(rocksdb, [upgrade(true)]), but it simply returned with “already installed @0.8.0”.

1 Like

Enough to often go nuts working with it but not enough that it rolls off the finger tips.


I actually tried swapping out the Git submodule version of RocksDB which is rocksdb @ bd68bfb for a current one and ran into a new set of errors.

The one requested by the RocksDB pack and the commits of RocksDB are compiling clean by themselves but when built via pack_install/1 or pack_rebuild/1 lead to errors. I tried running make shared_object in the pack directory but that is failing because pack_install/1 is setting up some environment variables that are not there when make is executed directly.

Saw this post that notes

For debugging purposes pack_install creates a shell script in the build location that sets the same variables, so you can run the compiler from any environment.

but I can not find the script or even in the Prolog code where it is created. Needless to say this is my typical scenario with make and C++, try, back step try again, and again and again and then one day wake up lucky and it just works. Then it seems I can never get such things to fail again.

Thanks.
No joy.
Same errors as in the first post.

My mistake – I was looking at the wrong line in the source code … the problem doesn’t seem to have been fixed.

You can try this:

  • edit line 767 of ~/.local/share/swi-prolog/pack/rocksdb/rocksdb/options/options_helper.cc to for (const auto &iter : type_info) {
  • pack_install(rocksdb, [rebuild(make)])

Except, on my system rebuild(make) does nothing. @jan - why is this?

So, instead, you can do something like this:

ROCKSDB_DISABLE_JEMALLOC=1 ROCKSDB_DISABLE_TCMALLOC=1 /usr/bin/gmake -j8 -C ~/.local/share/swi-prolog/pack/rocksdb/rocksdb static_lib EXTRA_CXXFLAGS=-fPIC EXTRA_CFLAGS=-fPIC USE_RTTI=1 DEBUG_LEVEL=0

The exact command will be different on your system, but you can see it in the output when you did the original pack_install. You’ll need to change the /usr/bin/gmake to whatever your system uses and change the path ~/.local/share/swi-prolog/pack/rocksdb/rocksdb

You may also need to run make install from the ~/.local/share/swi-prolog/pack/rocksdb directory, although on my system, nothing was required.

(It should be possible to do everything from ~/.local/share/swi-prolog/pack/rocksdb/rocksdb, but that requires knowing the values of some environment variables)

That looks like one of the commands I need but did not know how to run. Thanks.


I will give your suggestion(s) a try as soon and my current idea on making bites the dust.

It appears that @jan needs to do a submodule update at github on pack(rocksdb).

In the meantime, you should be able to do this to get the latest sources and rebuild:

cd ~/.local/share/swi-prolog/pack/rocksdb/rocksdb
git checkout main
git pull
make clean
ROCKSDB_DISABLE_JEMALLOC=1 ROCKSDB_DISABLE_TCMALLOC=1 /usr/bin/gmake -j8  static_lib EXTRA_CXXFLAGS=-fPIC EXTRA_CFLAGS=-fPIC USE_RTTI=1 DEBUG_LEVEL=0

As before, you’ll need to change the directory and the “gmake” line, also the -j8 option should be no more than the number of cores on your machine.
This should get the latest sources from github, which appear to have removed the offending line.

Thanks, yes.

Two days ago I would have had no clue what that statement meant but so glad you noted that as I was wondering if it was true but didn’t know enough at present to ask.

For others wondering what this means see Git submodule then notice the rocksdb @ bd68bfb for GitHub - JanWielemaker/rocksdb: SWI-Prolog interface for RocksDB then notice that SWI-Prolog is actually made up of as a composition of repositories (see library branch) which are pulled down when building with

git submodule update --init


ROCKSDB_DISABLE_JEMALLOC=1 ROCKSDB_DISABLE_TCMALLOC=1 /usr/bin/gmake -j8 static_lib EXTRA_CXXFLAGS=-fPIC EXTRA_CFLAGS=-fPIC USE_RTTI=1 DEBUG_LEVEL=0

That looks like it might be one of the pieces I need. Will give that at try.

I have pulled a recent specific commit and using that to refresh the RocksDB pack rocksdb directory as the RocksDB commits are a fast moving target and pulling the most recent one is just one more variable I want to avoid. While I will try main I will also try one the tags like v7.3.1.

Thanks.

Done.
No errors.

Last lines are

GEN    util/build_version.cc
CC      util/build_versoin.o
AR      librocksdb.a
/usr/bin/ar: creating librocksdb.a

Correct me if I am wrong, but that only built librocksdb.a (static library). The building of the shared_object rocksdb4pl.so still needs to be made by the Makefile from the SWI-Prolog pack.

As you noted earlier

but that requires knowing the values of some environment variables

that is the next part and for which I was expecting to find a bash script crated by pack_install/1to run make manually.

The good thing is that I understand most of what you note without getting lost and we seem be on the same path for the most part.


I was also doing some research on RocksDB and while it is not a perfect fit, it checks off more of the boxes toward being able to seamlessly extend the footprint for SWI-Prolog beyond just ram and onto diskspace while being really fast. I like that RocksDB seems to be the first safe pick for Disk based key-value stores and can be customized at many points. In particular my first major need is for large read only fact stores and bulk loading of portions of those facts on a monthly basis.

Here are some references for those that might be looking.

Disk based key-value stores
RocksDB: A High Performance Embedded Key-Value Store for Flash Storage - Data@Scale (YouTube)
DropBox Engineering Evening on RocksDB with Dhruba Borthakur @ Rockset (YouTube)
RocksDB: Evolution of Development Priorities in a Key-value Store Serving Large-scale Applications
Bloom filter
Log-structured merge-tree
What is SST (Static Sorted Table)
Optimizing Bulk Load in RocksDB
RocksDB merge operators
RocksDB Wiki
Prefix Index

As must be obvious, I know next to nothing about Windows development and have no desire to learn anything about it. All I can do is tell you what works for me on Linux and hopefully you can translate that something in Windows.

I was able to rebuild using the latest rocksdb sources on github. After librocksdb.a is built (or whatever the equivalent is in Windows-world), you need to do something like this, to build the foreign code from rocksdb4pl.cpp:

g++ -std=c++17 -fPIC -pthread -I"/home/peter/.local/lib/swipl/include"  -shared -Irocksdb/include -shared -o lib/x86_64-linux/rocksdb4pl.so cpp/rocksdb4pl.cpp rocksdb/librocksdb.a -lpthread -lrt -lsnappy -lgflags -lz -lbz2 -llz4 -lzstd 

You might be able to do this by editing the Makefile, changing the “c++11” to “c++17” and then doing make shared_object; but I suspect you’d need to set some other environment variables. The best way of figuring things out is by looking at the outputs from your original pack_install.

@jan – the -std=c++11 doesn’t work with the latest rocksdb sources: it needs to become `-std=c++17’ … I think that’s set by the CPPFLAGS variable.

1 Like

I have a few ideas for extending rocksdb (and rocks_pred) but I haven’t written them up.
The current rocks_pred can be improved a small amount (e.g., I don’t think that it needs to use hashes, because rocksdb does key prefix compression), but the biggest change is to allow more tuning, which will require modifying rocks4pl.cpp to set more options … and there are a lot of options, so it’ll be a bit of work to make these changes. Fortunately, I have a good model in library(pcre) which I recently modified, so I’ll be able to get to work on this soon.

Sorry should have made this more obvious. While, as you note, I normally do my Prolog on Windows for this I am using a recently created Ubuntu virtual machine on WSL 2 on Windows. The only purpose for the machine is to get RocksDB working with SWI-Prolog and then try out the rocks-predicates against the data from Full UMLS Release Files. Once that is done I might try a Windows variation but have no problem staying on Linux for months or more if need be to do this work.

If you want I have a private message that has my notes on this process where you can see my many false steps and what I am learning just ask. It was created as a private message so that @Rscho314 could see and if it works most of what is needed for a wiki page can just be clipped out.

1 Like

If you look at the Makefile it merely checks the existence of librocksdb.a for deciding whether or not to run make in the submodule.

Thanks. I’ve updated the submodule and set the C++ standard to c++17. Seems to work fine.

For packs in general, if the pack_install/1 fails for some reason, go to the pack directory (typically ~/.local/share/swi-prolog/pack/<Pack>), run

source buildenv.sh
make

Instead of plain make you can do all the usual stuff to get naughty foreign code built. The buildenv.sh script is created by the pack_install/1 and defines the environment variables that make it possible to find SWI-Prolog components and setup the pack for the current architecture.

The choice for a static library compiled with -fPIC is quite deliberate as it makes the result easier to share (just a single shared object) while this is not a generic build anyway.

I know. Supporting some more is probably useful, When I wrote the rocksdb interface it was mostly to compare it against BerkeleyDB for a specific project. It scales a lot better from what I recall. BerkeleyDB has other nice properties though, such as allowing multiple processes to access the same database concurrently.

1 Like

For those looking for the recent commits to the SWI-Prolog RocksDB pack

For

the submodule is now at rocksdb @ d52b520 and was expecting it to be a commit in the last month or so but in checking find Apr 7, 2021. Why that particular commit? It is tied to a specific tag or release?

Thanks.

FYI for others who might be attempting this.

Here is what I am finding.

Now that the pack has been modified am trying with a clean slate.

?- pack_remove(rocks_db).

worked as expected and removed the directory

~/.local/share/swi-prolog/pack/rocksdb

Then trying

?- pack_install(rocks_db). 

was expecting to see version 0.9.0 but only saw 0.8.0. No problem will just try

?- pack_install(`https://github.com/JanWielemaker/rocksdb`). 

which failed (returned false).

As noted in the documentation

  • GIT URL (not well supported yet)

so wasn’t getting my hopes up.

So back to figuring out the manual steps and doing them.

After removing, this works for me:

?- pack_install('https://github.com/JanWielemaker/rocksdb.git').

Note the atom quotes rather that code-list quotes and adding .git. Pushed a fix that probes whether a URL is a GIT URL by trying to use git to probe the URL.

1 Like

Thanks, will give that a try.

I think I have completed a successful build of the RocksDB static library librocksdb.a and the shared object rocksdb4pl.so mostly using pack commands. It looks like the pack_rebuild also did the check but want to see it for myself before closing out this side project and the issue.

It now works as expected!!!

groot@Somewhere:~$ swipl
Welcome to SWI-Prolog (threaded, 64 bits, version 8.5.13)

...

?- pack_list_installed.
Installed packages (1):

i rocksdb@0.9.0             - SWI-Prolog interface to RocksDB
true.

?- pack_remove(rocksdb).
% Removing '/home/groot/.local/share/swi-prolog/pack/rocksdb' and contents
true.

?- pack_install(rocksdb).
% Contacting server at https://www.swi-prolog.org/pack/query ... ok
Install rocksdb@0.9.0 from GIT at https://github.com/JanWielemaker/rocksdb.git Y/n? Y

...

Run post installation scripts for pack "rocksdb" Y/n? Y
% git submodule update --init rocksdb
...

% gmake: Nothing to be done for 'install'.
true.

?-
Click triangle to see full output
groot@Somewhere:~$ swipl
Welcome to SWI-Prolog (threaded, 64 bits, version 8.5.13)
SWI-Prolog comes with ABSOLUTELY NO WARRANTY. This is free software.
Please run ?- license. for legal details.

For online help and background, visit https://www.swi-prolog.org
For built-in help, use ?- help(Topic). or ?- apropos(Word).

?- pack_list_installed.
Installed packages (1):

i rocksdb@0.9.0             - SWI-Prolog interface to RocksDB
true.

?- pack_remove(rocksdb).
% Removing '/home/groot/.local/share/swi-prolog/pack/rocksdb' and contents
true.

?- pack_install(rocksdb).
% Contacting server at https://www.swi-prolog.org/pack/query ... ok
Install rocksdb@0.9.0 from GIT at https://github.com/JanWielemaker/rocksdb.git Y/n?
% Cloning into '/home/groot/.local/share/swi-prolog/pack/rocksdb'...
% Contacting server at https://www.swi-prolog.org/pack/query ... ok
% "rocksdb.git" was downloaded 3 times
Package:                rocksdb
Title:                  SWI-Prolog interface to RocksDB
Installed version:      0.9.0
Author:                 Jan Wielemaker <J.Wielemaker@vu.nl>
Maintainer:             Jan Wielemaker <J.Wielemaker@cwi.nl>
Packager:               Jan Wielemaker <J.Wielemaker@cwi.nl>
Home page:              https://github.com/JanWielemaker/rocksdb
Download URL:           https://github.com/JanWielemaker/rocksdb.git
Run post installation scripts for pack "rocksdb" Y/n?
% git submodule update --init rocksdb
% Submodule 'rocksdb' (https://github.com/facebook/rocksdb) registered for path 'rocksdb'
% Cloning into '/home/groot/.local/share/swi-prolog/pack/rocksdb/rocksdb'...
% Submodule path 'rocksdb': checked out 'd52b520d5168de6be5f1494b2035b61ff0958c11'
% ROCKSDB_DISABLE_JEMALLOC=1 ROCKSDB_DISABLE_TCMALLOC=1 /usr/bin/gmake -j4 -C rocksdb static_lib EXTRA_CXXFLAGS=-fPIC EXTRA_CFLAGS=-fPIC USE_RTTI=1 DEBUG_LEVEL=0
% gmake[1]: Entering directory '/home/groot/.local/share/swi-prolog/pack/rocksdb/rocksdb'
% $DEBUG_LEVEL is 0
% Makefile:295: Warning: /usr/lib/swi-prolog/include" does not exist
%   CC       cache/cache.o
%   CC       cache/lru_cache.o
%   CC       cache/clock_cache.o
%   CC       cache/sharded_cache.o
%   CC       db/arena_wrapped_db_iter.o
%   CC       db/blob/blob_file_addition.o
%   CC       db/blob/blob_file_builder.o
%   CC       db/blob/blob_file_cache.o
%   CC       db/blob/blob_file_garbage.o
%   CC       db/blob/blob_file_meta.o
%   CC       db/blob/blob_file_reader.o
%   CC       db/blob/blob_log_format.o
%   CC       db/blob/blob_log_sequential_reader.o
%   CC       db/blob/blob_log_writer.o
%   CC       db/builder.o
%   CC       db/c.o
%   CC       db/column_family.o
%   CC       db/compaction/compaction.o
%   CC       db/compaction/compaction_iterator.o
%   CC       db/compaction/compaction_job.o
%   CC       db/compaction/compaction_picker.o
%   CC       db/compaction/compaction_picker_fifo.o
%   CC       db/compaction/compaction_picker_level.o
%   CC       db/compaction/compaction_picker_universal.o
%   CC       db/compaction/sst_partitioner.o
%   CC       db/convenience.o
%   CC       db/db_filesnapshot.o
%   CC       db/db_impl/compacted_db_impl.o
%   CC       db/db_impl/db_impl.o
%   CC       db/db_impl/db_impl_compaction_flush.o
%   CC       db/db_impl/db_impl_debug.o
%   CC       db/db_impl/db_impl_experimental.o
%   CC       db/db_impl/db_impl_files.o
%   CC       db/db_impl/db_impl_open.o
%   CC       db/db_impl/db_impl_readonly.o
%   CC       db/db_impl/db_impl_secondary.o
%   CC       db/db_impl/db_impl_write.o
%   CC       db/db_info_dumper.o
%   CC       db/db_iter.o
%   CC       db/dbformat.o
%   CC       db/error_handler.o
%   CC       db/event_helpers.o
%   CC       db/experimental.o
%   CC       db/external_sst_file_ingestion_job.o
%   CC       db/file_indexer.o
%   CC       db/flush_job.o
%   CC       db/flush_scheduler.o
%   CC       db/forward_iterator.o
%   CC       db/import_column_family_job.o
%   CC       db/internal_stats.o
%   CC       db/logs_with_prep_tracker.o
%   CC       db/log_reader.o
%   CC       db/log_writer.o
%   CC       db/malloc_stats.o
%   CC       db/memtable.o
%   CC       db/memtable_list.o
%   CC       db/merge_helper.o
%   CC       db/merge_operator.o
%   CC       db/output_validator.o
%   CC       db/periodic_work_scheduler.o
%   CC       db/range_del_aggregator.o
%   CC       db/range_tombstone_fragmenter.o
%   CC       db/repair.o
%   CC       db/snapshot_impl.o
%   CC       db/table_cache.o
%   CC       db/table_properties_collector.o
%   CC       db/transaction_log_impl.o
%   CC       db/trim_history_scheduler.o
%   CC       db/version_builder.o
%   CC       db/version_edit.o
%   CC       db/version_edit_handler.o
%   CC       db/version_set.o
%   CC       db/wal_edit.o
%   CC       db/wal_manager.o
%   CC       db/write_batch.o
%   CC       db/write_batch_base.o
%   CC       db/write_controller.o
%   CC       db/write_thread.o
%   CC       env/composite_env.o
%   CC       env/env.o
%   CC       env/env_chroot.o
%   CC       env/env_encryption.o
%   CC       env/env_hdfs.o
%   CC       env/env_posix.o
%   CC       env/file_system.o
%   CC       env/fs_posix.o
%   CC       env/fs_remap.o
%   CC       env/file_system_tracer.o
%   CC       env/io_posix.o
%   CC       env/mock_env.o
%   CC       file/delete_scheduler.o
%   CC       file/file_prefetch_buffer.o
%   CC       file/file_util.o
%   CC       file/filename.o
%   CC       file/line_file_reader.o
%   CC       file/random_access_file_reader.o
%   CC       file/read_write_util.o
%   CC       file/readahead_raf.o
%   CC       file/sequence_file_reader.o
%   CC       file/sst_file_manager_impl.o
%   CC       file/writable_file_writer.o
%   CC       logging/auto_roll_logger.o
%   CC       logging/event_logger.o
%   CC       logging/log_buffer.o
%   CC       memory/arena.o
%   CC       memory/concurrent_arena.o
%   CC       memory/jemalloc_nodump_allocator.o
%   CC       memory/memkind_kmem_allocator.o
%   CC       memtable/alloc_tracker.o
%   CC       memtable/hash_linklist_rep.o
%   CC       memtable/hash_skiplist_rep.o
%   CC       memtable/skiplistrep.o
%   CC       memtable/vectorrep.o
%   CC       memtable/write_buffer_manager.o
%   CC       monitoring/histogram.o
%   CC       monitoring/histogram_windowing.o
%   CC       monitoring/in_memory_stats_history.o
%   CC       monitoring/instrumented_mutex.o
%   CC       monitoring/iostats_context.o
%   CC       monitoring/perf_context.o
%   CC       monitoring/perf_level.o
%   CC       monitoring/persistent_stats_history.o
%   CC       monitoring/statistics.o
%   CC       monitoring/thread_status_impl.o
%   CC       monitoring/thread_status_updater.o
%   CC       monitoring/thread_status_updater_debug.o
%   CC       monitoring/thread_status_util.o
%   CC       monitoring/thread_status_util_debug.o
%   CC       options/cf_options.o
%   CC       options/configurable.o
%   CC       options/customizable.o
%   CC       options/db_options.o
%   CC       options/options.o
%   CC       options/options_helper.o
%   CC       options/options_parser.o
%   CC       port/port_posix.o
%   CC       port/win/env_default.o
%   CC       port/win/env_win.o
%   CC       port/win/io_win.o
%   CC       port/win/port_win.o
%   CC       port/win/win_logger.o
%   CC       port/win/win_thread.o
%   CC       port/stack_trace.o
%   CC       table/adaptive/adaptive_table_factory.o
%   CC       table/block_based/binary_search_index_reader.o
%   CC       table/block_based/block.o
%   CC       table/block_based/block_based_filter_block.o
%   CC       table/block_based/block_based_table_builder.o
%   CC       table/block_based/block_based_table_factory.o
%   CC       table/block_based/block_based_table_iterator.o
%   CC       table/block_based/block_based_table_reader.o
%   CC       table/block_based/block_builder.o
%   CC       table/block_based/block_prefetcher.o
%   CC       table/block_based/block_prefix_index.o
%   CC       table/block_based/data_block_hash_index.o
%   CC       table/block_based/data_block_footer.o
%   CC       table/block_based/filter_block_reader_common.o
%   CC       table/block_based/filter_policy.o
%   CC       table/block_based/flush_block_policy.o
%   CC       table/block_based/full_filter_block.o
%   CC       table/block_based/hash_index_reader.o
%   CC       table/block_based/index_builder.o
%   CC       table/block_based/index_reader_common.o
%   CC       table/block_based/parsed_full_filter_block.o
%   CC       table/block_based/partitioned_filter_block.o
%   CC       table/block_based/partitioned_index_iterator.o
%   CC       table/block_based/partitioned_index_reader.o
%   CC       table/block_based/reader_common.o
%   CC       table/block_based/uncompression_dict_reader.o
%   CC       table/block_fetcher.o
%   CC       table/cuckoo/cuckoo_table_builder.o
%   CC       table/cuckoo/cuckoo_table_factory.o
%   CC       table/cuckoo/cuckoo_table_reader.o
%   CC       table/format.o
%   CC       table/get_context.o
%   CC       table/iterator.o
%   CC       table/merging_iterator.o
%   CC       table/meta_blocks.o
%   CC       table/persistent_cache_helper.o
%   CC       table/plain/plain_table_bloom.o
%   CC       table/plain/plain_table_builder.o
%   CC       table/plain/plain_table_factory.o
%   CC       table/plain/plain_table_index.o
%   CC       table/plain/plain_table_key_coding.o
%   CC       table/plain/plain_table_reader.o
%   CC       table/sst_file_dumper.o
%   CC       table/sst_file_reader.o
%   CC       table/sst_file_writer.o
%   CC       table/table_factory.o
%   CC       table/table_properties.o
%   CC       table/two_level_iterator.o
%   CC       test_util/sync_point.o
%   CC       test_util/sync_point_impl.o
%   CC       test_util/transaction_test_util.o
%   CC       tools/dump/db_dump_tool.o
%   CC       trace_replay/trace_replay.o
%   CC       trace_replay/block_cache_tracer.o
%   CC       trace_replay/io_tracer.o
%   CC       util/coding.o
%   CC       util/compaction_job_stats_impl.o
%   CC       util/comparator.o
%   CC       util/compression_context_cache.o
%   CC       util/concurrent_task_limiter_impl.o
%   CC       util/crc32c.o
%   CC       util/dynamic_bloom.o
%   CC       util/hash.o
%   CC       util/murmurhash.o
%   CC       util/random.o
%   CC       util/rate_limiter.o
%   CC       util/ribbon_config.o
%   CC       util/slice.o
%   CC       util/file_checksum_helper.o
%   CC       util/status.o
%   CC       util/string_util.o
%   CC       util/thread_local.o
%   CC       util/threadpool_imp.o
%   CC       util/xxhash.o
%   CC       utilities/backupable/backupable_db.o
%   CC       utilities/blob_db/blob_compaction_filter.o
%   CC       utilities/blob_db/blob_db.o
%   CC       utilities/blob_db/blob_db_impl.o
%   CC       utilities/blob_db/blob_db_impl_filesnapshot.o
%   CC       utilities/blob_db/blob_file.o
%   CC       utilities/cassandra/cassandra_compaction_filter.o
%   CC       utilities/cassandra/format.o
%   CC       utilities/cassandra/merge_operator.o
%   CC       utilities/checkpoint/checkpoint_impl.o
%   CC       utilities/compaction_filters/remove_emptyvalue_compactionfilter.o
%   CC       utilities/convenience/info_log_finder.o
%   CC       utilities/debug.o
%   CC       utilities/env_mirror.o
%   CC       utilities/env_timed.o
%   CC       utilities/fault_injection_env.o
%   CC       utilities/fault_injection_fs.o
%   CC       utilities/leveldb_options/leveldb_options.o
%   CC       utilities/memory/memory_util.o
%   CC       utilities/merge_operators/max.o
%   CC       utilities/merge_operators/put.o
%   CC       utilities/merge_operators/sortlist.o
%   CC       utilities/merge_operators/string_append/stringappend.o
%   CC       utilities/merge_operators/string_append/stringappend2.o
%   CC       utilities/merge_operators/uint64add.o
%   CC       utilities/merge_operators/bytesxor.o
%   CC       utilities/object_registry.o
%   CC       utilities/option_change_migration/option_change_migration.o
%   CC       utilities/options/options_util.o
%   CC       utilities/persistent_cache/block_cache_tier.o
%   CC       utilities/persistent_cache/block_cache_tier_file.o
%   CC       utilities/persistent_cache/block_cache_tier_metadata.o
%   CC       utilities/persistent_cache/persistent_cache_tier.o
%   CC       utilities/persistent_cache/volatile_tier_impl.o
%   CC       utilities/simulator_cache/cache_simulator.o
%   CC       utilities/simulator_cache/sim_cache.o
%   CC       utilities/table_properties_collectors/compact_on_deletion_collector.o
%   CC       utilities/trace/file_trace_reader_writer.o
%   CC       utilities/transactions/lock/lock_manager.o
%   CC       utilities/transactions/lock/point/point_lock_tracker.o
%   CC       utilities/transactions/lock/point/point_lock_manager.o
%   CC       utilities/transactions/optimistic_transaction.o
%   CC       utilities/transactions/optimistic_transaction_db_impl.o
%   CC       utilities/transactions/pessimistic_transaction.o
%   CC       utilities/transactions/pessimistic_transaction_db.o
%   CC       utilities/transactions/snapshot_checker.o
%   CC       utilities/transactions/transaction_base.o
%   CC       utilities/transactions/transaction_db_mutex_impl.o
%   CC       utilities/transactions/transaction_util.o
%   CC       utilities/transactions/write_prepared_txn.o
%   CC       utilities/transactions/write_prepared_txn_db.o
%   CC       utilities/transactions/write_unprepared_txn.o
%   CC       utilities/transactions/write_unprepared_txn_db.o
%   CC       utilities/ttl/db_ttl_impl.o
%   CC       utilities/write_batch_with_index/write_batch_with_index.o
%   CC       utilities/write_batch_with_index/write_batch_with_index_internal.o
%   CC       third-party/folly/folly/detail/Futex.o
%   CC       third-party/folly/folly/synchronization/AtomicNotification.o
%   CC       third-party/folly/folly/synchronization/DistributedMutex.o
%   CC       third-party/folly/folly/synchronization/ParkingLot.o
%   CC       third-party/folly/folly/synchronization/WaitOptions.o
%   CC       utilities/transactions/lock/range/range_tree/lib/locktree/concurrent_tree.o
%   CC       utilities/transactions/lock/range/range_tree/lib/locktree/keyrange.o
%   CC       utilities/transactions/lock/range/range_tree/lib/locktree/lock_request.o
%   CC       utilities/transactions/lock/range/range_tree/lib/locktree/locktree.o
%   CC       utilities/transactions/lock/range/range_tree/lib/locktree/manager.o
%   CC       utilities/transactions/lock/range/range_tree/lib/locktree/range_buffer.o
%   CC       utilities/transactions/lock/range/range_tree/lib/locktree/treenode.o
%   CC       utilities/transactions/lock/range/range_tree/lib/locktree/txnid_set.o
%   CC       utilities/transactions/lock/range/range_tree/lib/locktree/wfg.o
%   CC       utilities/transactions/lock/range/range_tree/lib/standalone_port.o
%   CC       utilities/transactions/lock/range/range_tree/lib/util/dbt.o
%   CC       utilities/transactions/lock/range/range_tree/lib/util/memarena.o
%   CC       utilities/transactions/lock/range/range_tree/range_tree_lock_manager.o
%   CC       utilities/transactions/lock/range/range_tree/range_tree_lock_tracker.o
%   GEN      util/build_version.cc
%   CC       util/build_version.o
%   AR       librocksdb.a
% /usr/bin/ar: creating librocksdb.a
% gmake[1]: Leaving directory '/home/groot/.local/share/swi-prolog/pack/rocksdb/rocksdb'
% /usr/bin/gmake shared_object
% gmake[1]: Entering directory '/home/groot/.local/share/swi-prolog/pack/rocksdb'
% mkdir -p lib/x86_64-linux
% g++ -std=c++17 -fPIC -pthread -I"/usr/lib/swi-prolog/include"   -shared -Irocksdb/include -shared -o lib/x86_64-linux/rocksdb4pl.so cpp/rocksdb4pl.cpp rocksdb/librocksdb.a -lpthread -lrt -ldl -lsnappy -lgflags -lz -lbz2 -llz4 -lzstd
% gmake[1]: Leaving directory '/home/groot/.local/share/swi-prolog/pack/rocksdb'
% swipl -p library=prolog -p foreign="lib/x86_64-linux" -g test_rocksdb -t halt test/test_rocksdb.pl
% % PL-Unit: rocks
% .
% .
% .
% . done
% % PL-Unit: terms
% . done
% % PL-Unit: types
% .
% .
% .
% . done
% % PL-Unit: merge
% .
% .
%  done
% % PL-Unit: builtin_merge
% .
% .
% .
%  done
% % PL-Unit: properties
% . done
% % PL-Unit: enum
% . done
% % All 16 tests passed
% gmake: Nothing to be done for 'install'.
true.

?-

To verify shared object created

groot@Somewhere:~$ ls -l ~/.local/share/swi-prolog/pack/rocksdb/lib/x86_64-linux
total 146160
-rwxrwxr-x 1 groot groot 149666320 Jul  1 06:56 rocksdb4pl.so

To run the demo provided with the pack

?- working_directory(_,'/home/groot/.local/share/swi-prolog/pack/rocksdb/demo').
true.

?- [merge].
true.

?- demo(10).
% Merge full [1] [[1],[2],[3],[4],[5],[6],[7],[8],[9],[10]]
true.

Thanks go to @jan @peter.ludemann and @Rscho314.

update(true) didn’t work either: EDIT: of course it didn’t: should have been upgrade(true) (but there was also a bug in pack_install/2).

?- pack_install(rocksdb, [update(true)]).
% Contacting server at https://www.swi-prolog.org/pack/query ... ok
% Pack `rocksdb' is already installed @0.8.0
true.

I also tried deleting the .so and .a files and rocksdb/INSTALL.md, but that didn’t help either. It appears that the “make” isn’t being invoked.