ericoporto / agsworks

A game store plugin for AGS, allows integrating with Steam and others.
MIT License
0 stars 0 forks source link

Explore interface libraries #2

Open ericoporto opened 1 month ago

ericoporto commented 1 month ago

The idea of using dynamic loading is to not require steam libraries when building but also to make the library more resilient. If that isn't possible for some reason, another strategy is to explore interface library, which would have stubs and then one would be able to switch it by the real library later

From https://github.com/libsdl-org/SDL/issues/9580

Not a dumb idea at all. It ties to this issue with the satellite libraries. I remembered this old Phoronix article about llvm creating interface libraries and tried it on the SDL library.

llvm-ifs --input-format=ELF libSDL3.so.0 --output-ifs libSDL3.txt

generates this file.

I pruned all non-SDL symbols and ran the following command:

llvm-ifs --endianness=little --arch=x86_64 --bitwidth=64 --input-format=IFS libSDL3.pruned.txt --output-elf libSDL3_ifs.so

Compiling and linking a SDL test executable against this interface library results in a working executable:

gcc ../test/testutils.c ../test/testsprite.c -I ../include libSDL3_test.a  -lunwind libSDL3_ifs.so -Wl,-rpath,$PWD

The only issue with the interface library is that:

The caveat is Steam and Galaxy are C++ APIs do things may have further complications...