Are Linux static builds no longer supported by 9.3.25?

If I try to build with -DSWIPL_STATIC_LIB=ON -DSTATIC_EXTENSIONS=ON the first problem is that -DCMAKE_BUILD_TYPE=PGO doesn’t work, but even if I switch to -DCMAKE_BUILD_TYPE=Release the build blows up:

[382/2559] Building C object src/CMakeFiles/swiplobjs.dir/os/pl-cstack.c.o
FAILED: src/CMakeFiles/swiplobjs.dir/os/pl-cstack.c.o 
/opt/rh/devtoolset-12/root/usr/bin/cc  -Isrc -I../src -O2  -fvisibility=hidden   -Wall -fno-strict-aliasing -std=gnu11 -MD -MT src/CMakeFiles/swiplobjs.dir/os/pl-cstack.c.o -MF src/CMakeFiles/swiplobjs.dir/os/pl-cstack.c.o.d -o src/CMakeFiles/swiplobjs.dir/os/pl-cstack.c.o   -c ../src/os/pl-cstack.c
../src/os/pl-cstack.c: In function ‘print_trace’:
../src/os/pl-cstack.c:425:15: warning: unused variable ‘info’ [-Wunused-variable]
  425 |     { Dl_info info;
      |               ^~~~
../src/os/pl-cstack.c: At top level:
../src/os/pl-cstack.c:456:5: error: expected identifier or ‘(’ before ‘else’
  456 |   } else
      |     ^~~~
../src/os/pl-cstack.c:459:1: error: expected identifier or ‘(’ before ‘}’ token
  459 | }
      | ^
../src/os/pl-cstack.c:356:1: warning: ‘addr2line’ defined but not used [-Wunused-function]
  356 | addr2line(const char *fname, uintptr_t offset, char *buf, size_t size)
      | ^~~~~~~~~
[404/2559] Building C object src/CMakeFiles/swiplobjs.dir/pl-index.c.o
In file included from ../src/pl-incl.h:2968,
                 from ../src/pl-index.h:37,
                 from ../src/pl-index.c:37:
../src/pl-data.h: In function ‘update_primary_index___LD’:
../src/pl-data.h:213:30: warning: ‘key’ may be used uninitialized [-Wmaybe-uninitialized]
  213 | #define tagex(w)        ((w) & (TAG_MASK|STG_MASK))
      |                              ^
../src/pl-index.c:3629:10: note: ‘key’ was declared here
 3629 |     word key;
      |          ^~~
[415/2559] Building C object src/CMakeFiles/swiplobjs.dir/pl-wam.c.o
ninja: build stopped: subcommand failed.

It depends on the platform, I guess. It surely works in general as the WASM version is built this way (and this is the primary motivation). On Linux, this works for me:

cmake -DSTATIC_EXTENSIONS=ON \
      -DINSTALL_DOCUMENTATION=OFF \
      -DSWIPL_PACKAGE_LIST="clib;plunit" -G Ninja ..

It has some trouble compiling the library as .qlf. That probably needs some tweaking with the set of included packages and/or some additional conditional compilation to avoid including stuff that does not exist.

This does not use -DSWIPL_STATIC_LIB=ON, but that seems implied. swipl does not link to libswipl.so and instead, there is a libswipl.a as part of the build.

I don’t know your platform. I guess you need to find the right conditions to disable that route for printing crash information (that is what pl-cstack.c does). That code is a bit confusing at it is highly platform dependent and (thus) it is more “cpp” code than C :frowning:

Thanks, the platform is a RedHat derivative, but an old one as I want binary compatibility with it - I’ve already had to build a couple of dependencies (eg PCRE) from source. If I build swipl as shared I have to include a lot of shared libraries in the bundle if I want to run it on newer OS versions, so I was investigating if static linking would be a better option.

I think the trick will be finding the right set of things to put in -DSWIPL_PACKAGE_LIST, as you say. Or just don’t support such an ancient Linux version :laughing: