lixa icon indicating copy to clipboard operation
lixa copied to clipboard

Static linkage instead of dynamic linkage in Ubuntu 22.04

Open tiian opened this issue 10 months ago • 3 comments

The build procedure does not work properly with Ubuntu 22.04. Two shared library are built are statically linked instead of dynamically linked:

tiian@ubuntu2204:/opt/lixa/lib$ cd /opt/lixa/lib/
tiian@ubuntu2204:/opt/lixa/lib$ ls *.so
liblixab.so       liblixta_java.so                switch_mysql_stareg.so
liblixac.so       liblixtapp.so                   switch_oracle_dynreg.so
liblixamonkey.so  switch_lixa_dummyrm.so          switch_oracle_stareg.so
liblixamy.so      switch_lixa_monkeyrm_dynreg.so  switch_postgresql_stareg.so
liblixapq.so      switch_lixa_monkeyrm_stareg.so
liblixta.so       switch_lixa_randomrm.so
tiian@ubuntu2204:/opt/lixa/lib$ ldd switch_mysql_stareg.so
	statically linked
tiian@ubuntu2204:/opt/lixa/lib$ ldd switch_postgresql_stareg.so
	statically linked

all the other shared objects in the same directory are properly dynamically linked.

make_output_ubuntu1404.txt

make_output_ubuntu2204.txt

The two attachments contain the output of the commands:

make
sudo make install

on both Ubuntu 14.04 (file make_output_ubuntu1404.tx) and Ubuntu 22.04 (file make_output_ubuntu2204.txt): there are apparently no differences between the two in respect of the linkage, but something goes wrong.

tiian avatar Feb 23 '25 09:02 tiian

Additional build logs

build-log-22.04.txt build-log-14.04.txt

tiian avatar Feb 23 '25 10:02 tiian

The exact same issue happens even with Ubuntu 24.04.

tiian avatar Feb 23 '25 10:02 tiian

Additional information:

  • the same behavior happens even with Ubuntu 24.04 ==> it's not specific of Ubuntu 22.04
  • experiment done: re-generated the gnu build tools inside Ubuntu 22.04 with usage of libtool 2.4.6 instead of libtool 2.4.2, but nothing changed ==> it's not related to an old version of libtool

Possible next investigation: differences in build parameters used for

switch_oracle_dynreg.so
switch_oracle_stareg.so

that are linked in the proper way, and

switch_mysql_stareg.so
switch_postgresql_stareg.so

that are linked statically instead of dynamically.

tiian avatar Feb 25 '25 20:02 tiian

For information built lixa 1.9.5 on RHEL 9.5 x64 and those mysql and postgresql shared objects appear to be dynamically linked according to ldd. gcc 11.5.0 autoconf 2.69 automake 1.16.2 libtool 2.4.6

imavo avatar Mar 14 '25 14:03 imavo

For information built lixa 1.9.5 on RHEL 9.5 x64 and those mysql and postgresql shared objects appear to be dynamically linked according to ldd. gcc 11.5.0 autoconf 2.69 automake 1.16.2 libtool 2.4.6

Thank you for the feedback. On Ubuntu 22.04, and possibly 24.04, I'm still far from understanding what's going on!

tiian avatar Mar 14 '25 21:03 tiian

These are the commands to compile and link the switch_postgresql_stareg.so module:

/bin/bash ../../../../libtool  --tag=CC   --mode=compile gcc -DHAVE_CONFIG_H -I. -I../../../.. -I../../../../src/client -I../../../../src/xta  -I/usr/include/postgresql -I../../../common -DLIXA_DEBUG -D_CRASH -D_TRACE -I/usr/lib/jvm/java-11-openjdk-amd64/include -I/usr/lib/jvm/java-11-openjdk-amd64/include/linux -I/usr/include/libxml2 -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -pthread -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -Wall -g -Wno-stringop-truncation -Wno-stringop-overflow -MT postgresql_stareg.lo -MD -MP -MF .deps/postgresql_stareg.Tpo -c -o postgresql_stareg.lo postgresql_stareg.c
libtool: compile:  gcc -DHAVE_CONFIG_H -I. -I../../../.. -I../../../../src/client -I../../../../src/xta -I/usr/include/postgresql -I../../../common -DLIXA_DEBUG -D_CRASH -D_TRACE -I/usr/lib/jvm/java-11-openjdk-amd64/include -I/usr/lib/jvm/java-11-openjdk-amd64/include/linux -I/usr/include/libxml2 -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -pthread -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -Wall -g -Wno-stringop-truncation -Wno-stringop-overflow -MT postgresql_stareg.lo -MD -MP -MF .deps/postgresql_stareg.Tpo -c postgresql_stareg.c  -fPIC -DPIC -o .libs/postgresql_stareg.o
mv -f .deps/postgresql_stareg.Tpo .deps/postgresql_stareg.Plo
/bin/bash ../../../../libtool  --tag=CC   --mode=link gcc -Wall -g -Wno-stringop-truncation -Wno-stringop-overflow -L/usr/lib/x86_64-linux-gnu -lpq -lglib-2.0 -module  -o switch_postgresql_stareg.la -rpath /opt/lixa/lib postgresql_stareg.lo liblixapq.la -lm 
libtool: link: rm -fr  .libs/switch_postgresql_stareg.la .libs/switch_postgresql_stareg.lai .libs/switch_postgresql_stareg.so .libs/switch_postgresql_stareg.so.0 .libs/switch_postgresql_stareg.so.0.0.0
libtool: link: gcc -shared  -fPIC -DPIC  .libs/postgresql_stareg.o   -Wl,-rpath -Wl,/home/tiian/lixa-1.9.5/src/client/switch/postgresql/.libs -Wl,-rpath -Wl,/opt/lixa/lib -L/usr/lib/x86_64-linux-gnu -lpq -lglib-2.0 ./.libs/liblixapq.so -lm  -g   -Wl,-soname -Wl,switch_postgresql_stareg.so.0 -o .libs/switch_postgresql_stareg.so.0.0.0

unfortunately, even specifying

LT_INIT([disable-static])

in configure.ac instead of the default

LT_INIT

does not solve the issue, but static libraries are not produced.

tiian avatar Mar 14 '25 21:03 tiian

Even

LT_INIT([dlopen])

in configure,ac instead of

LT_INIT

does not solve the issue.

tiian avatar Mar 14 '25 21:03 tiian

Oracle module:

file oracle_stareg.o
oracle_stareg.o: ELF 64-bit LSB relocatable, x86-64, version 1 (SYSV), with debug_info, not stripped

gcc -shared  -fPIC -DPIC  .libs/oracle_stareg.o   -L/opt/oracle/instantclient_19_8/ -lclntsh -lnnz19 -lm  -g -Wl,--no-as-needed -Wl,-rpath -Wl,/opt/oracle/instantclient_19_8/ -Wl,--no-as-needed -Wl,-rpath -Wl,/opt/oracle/instantclient_19_8/   -Wl,-soname -Wl,switch_oracle_stareg.so.0 -o .libs/switch_oracle_stareg.so.0.0.0

produces a valid module.

PostgreSQL model:

file postgresql_stareg.o 
postgresql_stareg.o: ELF 64-bit LSB relocatable, x86-64, version 1 (SYSV), with debug_info, not stripped

gcc -shared  -fPIC -DPIC  .libs/postgresql_stareg.o   -Wl,-rpath -Wl,/home/tiian/lixa-1.9.5/src/client/switch/postgresql/.libs -Wl,-rpath -Wl,/opt/lixa/lib -L/usr/lib/x86_64-linux-gnu -lpq -lglib-2.0 ./.libs/liblixapq.so -lm  -g   -Wl,-soname -Wl,switch_postgresql_stareg.so.0 -o .libs/switch_postgresql_stareg.so.0.0.0

produces an invalid module:

ldd switch_postgresql_stareg.so.0.0.0 
statically linked

but why the difference, I have no clue.

tiian avatar Mar 14 '25 22:03 tiian

In file liblixapq.h, and the same applies for liblixamy.h, there was a missing "extern":

extern struct xa_switch_t xapqls;

for some reasons, it worked for 16 years, but on latest Ubuntu versions it generated a shared object that didn't link liblixapq library.

Commit 814f8c9241700a289b0e7e82f097ce80a91f8c14 fixes the issue, even if the tests are not yet passed on Ubuntu 22.04 (something else must still be fixed)

tiian avatar Mar 15 '25 11:03 tiian