KDE: The Never-Ending Story

So KDE 3.1 on OSX is coming closer. For the most part everything is cleaned up, and I've got most of it building, but we're still running into some weird symbol problems with OSX's linker (no way!)

(Read on for the full, gory details.)

The short version is:

MacOSX treats dynamic shared libraries and loadable modules differently, unlike pretty much every other platform on the planet. When someone passes -module to libtool, it creates a MacOSX "bundle" (loadable module), otherwise it makes a .dylib (roughly analogous to shared libraries in other OSes).

Unfortunately, there is an ugly side-effect to this. On any other platform (ie, on ELF platforms) you can use modules and shared libraries interchangably, they're the same thing. On OSX, you can't link against a module! Only a shared library.

TONS of stuff in KDE is building modules that are then linked against. The solution we came up with is to make anything that's a linked module into two libraries, one that's the "shared" version, and one that's a module. Incidentally, it appears the NetBSD folks came up with the same thing independently (and before) us -- a.out NetBSD acts like OSX in this respect.

So instead of libartsmidi.so, we have libartsmidi_shared.dylib, and then when we want to make the bundle, we make a dummy .cpp file that is empty, and link that against the shared library version.

Our spiffy little trick doesn't work all the time, though.

In some cases, for some unknown reason, we're ending up with modules that have no symbols other than some dyld hints. There's no way for something that's dlopening libartsmidi.so to know that it needs to actually find all the symbols in libartsmidi_shared.dylib. Even better, if we change everything back at install time so that libartsmidi.so contains all the code, it *still* doesn't want to load correctly, even though this time around the symbols are there.

Somewhere along the way, KDE's messed-up symbol loading gets all confused.

Ben Hines thinks it's an issue with c++ static objects not loading properly, I don't understand the details of how c++ linking works enough to know whether this is the right direction or not, but this is starting to drive me nuts.

Most of KDE works fine, just because of side-effects of how things are linked together... but we have at least one, and probably more weird issues like this that will bite us.

If you understand deep OSX linker issues, let me know. =)

Share on Facebook

Comments are closed.