-
-
Notifications
You must be signed in to change notification settings - Fork 21.6k
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
Improve architectures in OS::has_feature and make them work on MSVC #61732
Conversation
core/os/os.cpp
Outdated
if (p_feature == "arm64") { | ||
return true; | ||
} | ||
#elif defined(__arm__) | ||
#else |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#else | |
#elif defined(__arm__) || defined(_M_ARM) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was marked as resolved but I still think it makes sense. It's not needed per se due to the previous-level list of conditions, but that's more explicit and consistent with what is done for x86 arches.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I keep flip-flopping on this, but I added it in again and pushed to the PR.
b1315a8
to
1679eea
Compare
The #if conditions seem to work for MSVC (VS2022) x86, both 32 and 64 bit. ✔️ But when I run the example, I get a new error I hadn't noticed before, at object.cpp:1771
The instance bindings are first created at object.cpp:1794 while calling My suspicion is that this is unrelated, but this is far beyond my current understanding, since I just started looking at Godot code yesterday. I'll see if I can investigate further tomorrow. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Works with VS 2019 command line tools (both 32 and 64 bits), and does not cause regression on mingw.
As a note, we might want (at some point) to make the architecture and build feature(s) generated by the build system and included instead of detected via macros to better support different toolchains.
I am seeing a crash on the windows 32 bits build, but it is unrelated to this PR. I've confirmed that the correct features are set using the following script:
extends MainLoop
func _initialize():
for feat in ["x86_32", "x86_64"]:
print("%s: %s" % [feat, OS.has_feature(feat)])
1679eea
to
357af68
Compare
Thanks! |
This needs testing! I have not yet tested if this works as expected.
Based on this MSDN article, we need to check for
_M_IX86
,_M_X64
,_M_ARM
, and_M_ARM64
to detect x86 and ARM on MSVC. This should make thex86_64
,x86
,arm64
, andarm
OS features work on MSVC.I modified the logic a bit so that
x86_32
andarm32
are for the 32-bit versions specifically, andx86
andarm
will return true for both the 32-bit and 64-bit versions. I also added WebAssembly (wasm
,wasm32
,wasm64
) to the list of architectures, based on the defines here. For these reasons, this PR is also an enhancement.We should also backport some of these changes to 3.x (except leave "x86" and "arm" as they are for backwards compatibility for any 3.x projects using those to detect 32-bit versions of the architectures).