SDL icon indicating copy to clipboard operation
SDL copied to clipboard

Support functions with underscores with SDL_LoadFunction on all platforms?

Open ccawley2011 opened this issue 3 years ago • 1 comments

The dlopen implementation of SDL_LoadFunction automatically prepends underscores to function names if necessary, however the Windows and OS/2 implementations don't, which results in additional workarounds in the EGL and hidapi code.

ccawley2011 avatar Sep 15 '22 21:09 ccawley2011

Would you like to submit a PR?

slouken avatar Sep 15 '22 23:09 slouken

The os/2 side is handled by https://github.com/libsdl-org/SDL/pull/6430 and the hack in hidapi is removed.

Don't know why the workarounds in SDL_egl.c::SDL_EGL_GetProcAddress are needed, and by who.

sezero avatar Oct 23 '22 11:10 sezero

Don't know why the workarounds in SDL_egl.c::SDL_EGL_GetProcAddress are needed, and by who.

@slouken (and @icculus): Do you know the reason? As far as I can see, that one is the only thing that keeps this ticket open, because the only other dynamic loader left untouched is win32 where a workaround should not be needed.

sezero avatar Oct 24 '22 09:10 sezero

Do you know the reason?

I don't know for sure, but historically, before macOS had a real implementation of dlopen(), you had to put an underscore in front of shared library symbols or they wouldn't be found (because the Mach-O format stores symbols like that for reasons I don't know). This isn't needed in modern times, and it was never needed on most platforms, but it's possible there's some thing out there that still requires this. macOS never used EGL, fwiw, but I could imagine stumbling on some platform with the same weirdness about this as early macOS.

Anyhow, no actual answer here, just possible clues.

icculus avatar Oct 25 '22 03:10 icculus

Do you know the reason?

I don't know for sure, but historically, before macOS had a real implementation of dlopen(),

Even if that were the case, our dlopen version of SDL_LoadFunction already does that. That's why I was asking.

sezero avatar Oct 25 '22 06:10 sezero

I think the workaround exists because the EGL code used to directly call dlsym, and it was kept when the code was changed to use SDL_LoadFunction in https://github.com/SDL-mirror/SDL/commit/3fcc35f5bb715d897e5001b44b1748fd32c81ab2 despite the fact that it's no longer needed for Unix platforms.

ccawley2011 avatar Oct 25 '22 11:10 ccawley2011

Then we should just remove the underscore thing from there and close this ticket, yes?

sezero avatar Oct 25 '22 11:10 sezero

Created https://github.com/libsdl-org/SDL/pull/6443 for this

sezero avatar Oct 25 '22 12:10 sezero

Yeah, I think just remove it.

icculus avatar Oct 25 '22 12:10 icculus