-
-
Notifications
You must be signed in to change notification settings - Fork 12
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
Wii: broken partial SDL2 usage #81
Comments
It's not "more minimal", it's "more incompleted" version that I started a while ago before devkitPro did their own version. Actually, it's possible to build SDL2 itself with disabling several sub-systems via SDL2's CMake options (like, disable the whole Video subsystem or disabling Joysticks subsystem completely). |
It's certainly possible to make a build that disables some subsystems, but I think an ideal solution that allows people to use the mainline build would look like: (1) Add public facing per-subsystem init functions to allow better unused symbol stripping |
for now i can not comment about SDL or SDL2 stuff, as thats not part of my expertise, but as for the wiiuse stuff, i think in general wiiuse should not crash if WPAD_Init() is called twice. be it from SDL or a coding mistake. |
DacoTaco, thanks for the note. You should be able to reproduce this issue easily by initializing SDL2 in any example that currently uses wiiuse, then connecting (or reconnecting) a new Wiimote. Stack traces can lie, but if I recall correctly, there was a hardware exception triggered in wiiuse code that was called on a Bluetooth event. |
SDL2 already has options to initialize certain sub-systems by flags of SDL_Init(). So, it's just need to init only subsystems are declared at SDL_Init()'s argument as flags. |
That's not enough to help with code size and static memory, because almost no compilers will do the relevant cross-function control flow analysis to strip symbols pertaining to the unused subsystems based on a flags bitmask, but most compilers will strip symbols based on a function reachability graph. I suppose another solution could be to find some way to force-inline the SDL_Init function. It's much more likely that a within-function control flow analysis would avoid adding the unused symbols. |
With the static memory the custom build with disabling of unnecessary sub-systems should work. Or splitting the library to separated components, but that's more idea for SDL3. |
Sounds like a great plan, thanks a lot for the update. [Edit: this comment was in response to the note which is now below it.] |
just to have some public info about this, we might be splitting this up in 3 issues. one is the missing dependency in pacman, the other is the WPAD_Init issue and another is the SDL code size issue. we have some ideas to tackle the latter (as it is a bigger technical challenge than the others) and we have a few ideas that @mardy can try if he has time. |
This allows building a client application without linking to opengx, if the client itself does not need OpenGL. The opengx functions used by SDL are defined as weak, so that they will be used only if a strong symbol is not found during linking. $ nm /opt/devkitpro/portlibs/wii/lib/libSDL2.a | grep ogx 00000000 W ogx_get_proc_address 00000000 W ogx_initialize Partial fix for devkitPro#81
This allows building a client application without linking to opengx, if the client itself does not need OpenGL. The opengx functions used by SDL are defined as weak, so that they will be used only if a strong symbol is not found during linking. $ nm /opt/devkitpro/portlibs/wii/lib/libSDL2.a | grep ogx 00000000 W ogx_get_proc_address 00000000 W ogx_initialize Partial fix for #81
@ds-sloth : got a minimal project i can build/test the wiimote thing with? been trying to reproduce it but can't get it to crash haha |
Are you trying to disconnect and reconnect Wiimotes while your test app is running? That's the specific thing that causes crashes for me. If you can't get your app to crash by doing that, then let me try to strip down our usage of the wiiuse API to the minimum and make you a test app. |
These parts should have been fixed by the recent changes to SDL2 and opengx to use weak linking. I also updated the SDL2 package with the opengx dependency. If those work for you then I think we can close this and open another for the wiimote issue. |
Thanks a lot for making these changes. I just got the time to test them out now. I ran into a hiccup at first: we use CMake and your shipped After I manually removed Lastly, the system crash when disconnecting and reconnecting a Wiimote still exists, so I will file a new issue for that whenever we close this one. |
The |
Can you please try a build with the |
@mardy, you're right, sorry for the confusion. My understanding was that the goal of #82 was to make the behavior depend on whether the |
This allows building a client application without linking to opengx, if the client itself does not need OpenGL. The opengx functions used by SDL are defined as weak, so that they will be used only if a strong symbol is not found during linking. $ nm /opt/devkitpro/portlibs/wii/lib/libSDL2.a | grep ogx 00000000 W ogx_get_proc_address 00000000 W ogx_initialize Partial fix for #81
Bug Report
Thanks for maintaining this project!
devkitPro's SDL2 port has recently become much more complete, which is a very good thing, but it has resulted in certain unintended consequences for applications like https://github.com/TheXTech/TheXTech which use some, but not all, SDL2 features. For context, TheXTech on homebrew uses SDL2's RWops, thread, and audio APIs, but does not use any other major SDL2 features. We directly use wiiuse and libogc/video/gx to interface with Wiimotes and the Wii's video/rendering system.
What's the issue you encountered?
When I updated my SDL2 package from release 2.28.5-12 to release 2.28.5-13 last month, I noticed the following issues:
I'm happy to split this into multiple issues if you prefer.
How can the issue be reproduced?
Environment?
Additional context
For now we are using our own, much more minimal build of SDL2 for Wii (https://github.com/Wohlstand/SDL, branch
wii-support
). This works fine for our CI, but is inconvenient for users who might want to build our engine locally.The text was updated successfully, but these errors were encountered: