-
Notifications
You must be signed in to change notification settings - Fork 405
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
love.system.getArch() proposal #2008
Comments
And since löve itself by default uses luaJIT, you can just do |
The jit module is always loaded when LuaJIT is used, so just |
Yes, I am using |
Maybe this could be added to the info table proposal in #1595 - in a new |
In the mean time, if you add all architectures to the search path, don't love and lua automatically pick the first one that loads successfully? |
Yes, I think lua will try to load all the libraries with matching name in the order that is listed in the search path, and will be satisfied with the first one that doesn't fail. Can be checked with strace. |
One curious thing that I discovered just now is the inclusion of CpuArch.h from LZMA here: love/src/libraries/physfs/physfs_lzmasdk.h Lines 482 to 483 in 0df51cf
Newer version of this header has It's also possible that with complete CMake migration (#1991) this preprocessor trickery is unnecessary, and CMake could just set the target architecture in a predefined macro (or could it?), and then only a small workaround would be needed for Apple platforms as they won't be using CMake. |
Using preprocessor checks is much preferred to putting it in a build system generator, the latter is really inflexible and stops code from working on more than one type of system without generating things again. For example on iOS and macOS the Xcode project builds for multiple architectures together and bundles the result together. Whereas on Windows where we use CMake, I can't switch between x64 and x86 in Visual Studio without regenerating the visual studio projects and other build setup. I'm not worried about implementing that part of the code, we already do similar preprocessor checks for a few things - e.g. in config.h. |
I am curious, how many combinations of OS/Arch does LÖVE support. This is the list of possible operating systems:
While it should be relatively easy to determine the possible architectures for the top of the list, the last options have some variety:
This is probably a pain to read, but I tried to list the architectures more or less uniformly. There are a lot of variations, and different operating systems might give them different names. Also, I was rewriting and editing my lists to be consistent as I was adding new info to it, so I might have made mistakes, used sources with false information in them, so this is for reference only, don't trust this information without confirming by doing your own research! Anyway, if you absolutely need to bundle native code with your library, compile it for these 5 architectures:
This would cover like 90% of the users. And if you want to get it to 99%, then also add these 3:
Finally, if you want to get it to like 99,9% then consider adding some legacy 32-bit architectures as well:
I am sure Windows and UWP builds will use exactly the same binary format, so I combined them into one. Not so sure about macOS ARM64 and iOS ARM64 code, pretty sure it must be different. And once again, Linux is a completely wild territory: if you will be linking against libc (and you probably will), Linux ARM64 and Android ARM64 binaries will be different (Android is using bionic libc, and most of the Linux distros are using GNU libc). And some Linux distros like Alpine are using musl libc, so neither binary would be compatible with it. What's the solution? In conclusion, I must say that the only way to support 100% of the platforms that LÖVE runs on, just avoid using native code, write in Lua. I have no other solution. If I made a mistake somewhere, please, feel free to correct me! |
On macOS and iOS it's fairly easy to compile for all architectures at once and have one library binary that has everything, like I mentioned earlier. x86 on Windows is close to being extinct. If you want, you could just have one binary for macOS, one for Windows, one for Linux, one for iOS, and one for Android (or take away the last two if you don't need to support mobile).
So far we haven't wanted to break code compatibility for this, but maybe it'll happen in the future. According to https://store.steampowered.com/hwsurvey/Steam-Hardware-Software-Survey-Welcome-to-Steam?platform=mac 70% of mac steam users have an arm64 system, so you might not want to leave that out - and your x64 library will fail to work on those systems anyway unless you strip out the arm64 part of love.app to make it use Rosetta x64 emulation. :) |
Similar to
love.system.getOS()
, it should just return the architecture that Love is running on. This is particularly useful for loading native code.I am now using https, and I want to use it on x86_64 and ARM64. Love2D can be compiled to both these architectures, but doesn't provide the interface that tells for which architecture is was compiled. If Love2D had such method, it would be easy to conditionally load the correct version of the library based on the values returned by getOS and getArch (or print a message that the combination that the user is using is not supported by the game).
This information is easy to get from LuaJIT.
The text was updated successfully, but these errors were encountered: