-
Notifications
You must be signed in to change notification settings - Fork 30
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Generate or provide a non-minimal SDL_config.h for Unix platforms #229
Comments
Sure! Feel free to make a PR for this. |
Fwiw, we opted not to do this in sdl12-compat, where the config file was more crucial and often misused like this...and were surprised that we could fake our way through most of it. An app could build against SDL2 headers without a custom config script, unlike SDL 1.2, so I was hoping all of this would go away, but we had a report from Fedora already of an app checking for I'm hoping we can get away with adding a few more hacks like that, and most apps will be happy. We'll know more as distros start chewing through their packages with sdl2-compat, though. |
I think the way to test this systematically would be:
(I'm not replacing "real SDL2" with sdl2-compat in Debian any time soon - we're meant to be freezing for Debian 13 somewhat soon, so Debian 14 seems like a better target for switching to sdl2-compat.) |
Taking Debian packages that depend on SDL2 and start with digits or "A" as my initial sample, it isn't looking great so far. Obvious build failures like these are actually less of a concern for me, I'm more worried about silent miscompilation resulting in a routine rebuild of a game becoming non-functional (like for example turning off rendering support because sdl2-compat doesn't claim to support a desired graphics backend).
|
I wonder how hard it would be to automate comparing the binaries between two builds...in theory, if the only difference is the SDL2 headers, an identical binary means we did what was expected. But yeah, we'll probably need to add a The good news is that SDL3 removed this nonsense completely, so sdl3-compat won't have this issue in ten years. :) |
That's exactly what I was trying to do ( Perhaps I can get better comparisons by building with |
I've added a conservative UNIX platform header in be424f7, does this take care of our needs here? |
That looks like the sort of thing I had in mind. I'll compare it with what "real SDL2" gives us.
This seems good enough on Linux, but error-prone on other Unixes. we should probably have a
in a .c file that includes this header, to make sure we aren't mis-detecting it on some weird platform.
Perhaps a better comment would be:
Can we use Or at least use |
I believe All these changes sound good, want to make a PR? |
I'll add it to my queue (your bug is important to us, please hold) |
As discussed on libsdl-org#229, if we're going to try to detect this from compiler predefined macros like `__LP64__`, we should verify that we've done it correctly; otherwise, we could end up incorrectly assuming 32-bit pointers on a 64-bit Unix platform that doesn't define `__LP64__` (if such a thing exists). This static assertion succeeds on all Debian architectures where a build has been attempted, including all release architectures and several unofficial ports. It might fail on non-Linux kernels or non-GNU libc, but if it does, our build on those platforms would have been using the wrong value for `SIZEOF_VOIDP` already, so it'll only be detecting a pre-existing bug. Signed-off-by: Simon McVittie <smcv@collabora.com>
As discussed on #229, if we're going to try to detect this from compiler predefined macros like `__LP64__`, we should verify that we've done it correctly; otherwise, we could end up incorrectly assuming 32-bit pointers on a 64-bit Unix platform that doesn't define `__LP64__` (if such a thing exists). This static assertion succeeds on all Debian architectures where a build has been attempted, including all release architectures and several unofficial ports. It might fail on non-Linux kernels or non-GNU libc, but if it does, our build on those platforms would have been using the wrong value for `SIZEOF_VOIDP` already, so it'll only be detecting a pre-existing bug. Signed-off-by: Simon McVittie <smcv@collabora.com>
If we want OS distributions (mostly Linux, but also *BSD, Hurd, Haiku, etc.) to eventually replace their SDL2 packages with sdl2-compat, then sdl2-compat's development headers should be as close as is feasible to being a drop-in replacement for "real" SDL2.
Unfortunately, SDL 2 has
SDL_config.h
as part of its API, defining various symbols that are really implementation details of SDL rather than anything that an application should be relying on, such asHAVE_MEMSET
andSDL_AUDIO_DRIVER_ALSA
. libsdl-org/sdl12-compat#302, libsdl-org/sdl12-compat#299, libsdl-org/sdl12-compat#297 are examples of places where we needed to make sdl12-compat bug-for-bug compatible with "real" SDL 1.2. I expect that for SDL 2, there should hopefully be less need to do that, but some of it will probably be necessary.At the moment, in Debian I'm ignoring the SDL_config.h that ships with sdl2-compat, and instead providing a hand-edited header based on the one that Debian's "real SDL2" packaging generates at build-time, which makes some reasonable assumptions about Debian's toolchain, such as:
SDL_TIMER_UNIX
,SDL_VIDEO_DRIVER_X11
andHAVE_DBUS_DBUS_H
defined(__linux__)
(all official Debian ports are Linux, but there are kFreeBSD and Hurd versions maintained by other-kernel enthusiasts)defined(__linux__)
(in principle Wayland should be implementable anywhere, but in Debian's ports, in practice we only have it on Linux)Can we perhaps generalize that into a
SDL_config_unix.h
that is analogous toSDL_config_windows.h
, but with more#ifdef
?The text was updated successfully, but these errors were encountered: