-
-
Notifications
You must be signed in to change notification settings - Fork 21.4k
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
Add loongarch64 support for Linux/*BSD #97822
Conversation
bundled PCRE2's JIT is not working on LoongArch, which is fixed on newer version. |
Merging this PR would require some members of the team to possess a loongarch64-based computer. What do you think @akien-mga ? |
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 review is a nitpick, in practice it probably doesn't matter, or won't within our lifetimes.
@@ -248,6 +248,9 @@ String Engine::get_architecture_name() const { | |||
return "ppc"; | |||
#endif | |||
|
|||
#elif defined(__loongarch__) | |||
return "loongarch64"; |
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.
https://loongson.github.io/LoongArch-Documentation/LoongArch-toolchain-conventions-EN.html
According to this page, __loongarch64
is a more specific check than __loongarch__
, which we can check for to return "loongarch64"
, and otherwise fall back to a more generic bitless name (like the rv64 code above), ensuring that in case somebody tries to compile on an 32-bit or 128-bit version of the architecture then Godot doesn't still claim to be the 64-bit version (or it can just not compile in those cases).
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 decide only do more specific check without fallback to generic name. there is no 32-bit LoongArch desktop CPU yet. I think it's better to notify future developers we didn't actually test it by explicitly only support 64-bit LoongArch CPU.
core/os/os.cpp
Outdated
#elif defined(__loongarch__) | ||
if (p_feature == "loongarch64") { | ||
return true; | ||
} |
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.
Same here, we can use the __loongarch64
define to be more specific about architecture feature flags.
#elif defined(__loongarch__) | |
if (p_feature == "loongarch64") { | |
return true; | |
} | |
#elif defined(__loongarch__) | |
#if defined(__loongarch64) | |
if (p_feature == "loongarch64") { | |
return true; | |
} | |
#endif | |
if (p_feature == "loongarch") { | |
return true; | |
} |
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.
Code looks fine.
Tested it in QEMU VM, seems to be building only with the following patch (but probably will also work with system libpng
):
diff --git a/drivers/png/SCsub b/drivers/png/SCsub
index 4268a66475..947f0f5f21 100644
--- a/drivers/png/SCsub
+++ b/drivers/png/SCsub
@@ -58,6 +58,8 @@ if env["builtin_libpng"]:
elif env["arch"] == "ppc64":
env_thirdparty.add_source_files(thirdparty_obj, thirdparty_dir + "powerpc/powerpc_init.c")
env_thirdparty.add_source_files(thirdparty_obj, thirdparty_dir + "powerpc/filter_vsx_intrinsics.c")
+ elif env["arch"] == "loongarch64":
+ env_thirdparty.Append(CPPDEFINES=["PNG_LOONGARCH_LSX_OPT=0"])
env.drivers_sources += thirdparty_obj
@@ -11,7 +11,7 @@ | |||
<members> | |||
<member name="binary_format/architecture" type="String" setter="" getter=""> | |||
Application executable architecture. | |||
Supported architectures: [code]x86_32[/code], [code]x86_64[/code], [code]arm64[/code], [code]arm32[/code], [code]rv64[/code], [code]ppc64[/code], and [code]ppc32[/code]. | |||
Supported architectures: [code]x86_32[/code], [code]x86_64[/code], [code]arm64[/code], [code]arm32[/code], [code]rv64[/code], [code]ppc64[/code], [code]ppc32[/code] and [code]loongarch64[/code]. |
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.
Supported architectures: [code]x86_32[/code], [code]x86_64[/code], [code]arm64[/code], [code]arm32[/code], [code]rv64[/code], [code]ppc64[/code], [code]ppc32[/code] and [code]loongarch64[/code]. | |
Supported architectures: [code]x86_32[/code], [code]x86_64[/code], [code]arm64[/code], [code]arm32[/code], [code]rv64[/code], [code]ppc64[/code], [code]ppc32[/code], and [code]loongarch64[/code]. |
Please keep the Oxford comma.
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.
Looks great to me!
Thanks! Congratulations on your first merged contribution! 🎉 |
This PR add support for 64 bit LoongArch CPU architecture.
Tested on Loongson 3A6000 with AMD RX590.