Closed icculus closed 2 months ago
Are the .m
files built with -fvisibility=hidden
?
I did some quick googling and couldn't find anything obvious to prevent those class symbols from being exported, but maybe I'm missing something.
Changing the prefix seems like a reasonable backup option but I still hope there's a better way..
I'm just going to rename all the symbols from "SDL" to "SDL3" in SDL3, which is honestly probably Good Enough until someone says otherwise. It'll prevent both the dynapi issue and prevent issues with something that links against SDL2 and SDL3 for some reason, as well.
Does apple have a concept similar to the symbol versioning we do on Linux?
They might, but not for the Objective-C class namespace.
So this is a weird situation that isn't an emergency but could become one later:
What will happen is that the app will load SDL2, which will see SDL_DYNAMIC_API and load sdl2-compat, which will load SDL3.
And this will (currently) work correctly, but it prints this to stderr:
Note that we don't use real SDL2, except for its entry points serving to bounce us into sdl2-compat's entry points, but the system's dynamic loader will still dump its Objective-C classes into the global namespace, apparently.
This doesn't happen with DYLD_LIBRARY_PATH=/path/to/sdl2-compat, because real SDL2 is never loaded at all, and sdl2-compat doesn't have any of these Objective-C classes itself, since it relies of SDL3 for the heavy lifting.
None of these Objective-C classes are public APIs, so we could either find a command line that tells the compiler not to export them (if such a thing exists; this might just be how Objective-C works), a command line to say "all Objective-C classes should be wrapped in a namespace" if something like that exists, or we should go manually change all these in SDL3 to have an
SDL3_
prefix.