Skip to content
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

[3.x] Add support for the RISC-V architecture #53509

Merged
merged 1 commit into from
Oct 22, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions core/os/os.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -670,6 +670,15 @@ bool OS::has_feature(const String &p_feature) {
if (p_feature == "arm") {
return true;
}
#elif defined(__riscv)
#if __riscv_xlen == 8
if (p_feature == "rv64") {
return true;
}
#endif
if (p_feature == "riscv") {
return true;
}
#endif

if (_check_internal_feature_support(p_feature)) {
Expand Down
4 changes: 2 additions & 2 deletions modules/denoise/config.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
def can_build(env, platform):
# Thirdparty dependency OpenImage Denoise includes oneDNN library
# which only supports 64-bit architectures.
# and the version we use only supports x86_64.
# It's also only relevant for tools build and desktop platforms,
# as doing lightmap generation and denoising on Android or HTML5
# would be a bit far-fetched.
# Note: oneDNN doesn't support ARM64, OIDN needs updating to the latest version
supported_platform = platform in ["x11", "osx", "windows", "server"]
supported_bits = env["bits"] == "64"
supported_arch = env["arch"] != "arm64"
supported_arch = env["arch"] != "arm64" and not env["arch"].startswith("rv")

# Hack to disable on Linux arm64. This won't work well for cross-compilation (checks
# host, not target) and would need a more thorough fix by refactoring our arch and
Expand Down
2 changes: 1 addition & 1 deletion modules/mono/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@


def can_build(env, platform):
return True
return not env["arch"].startswith("rv")


def configure(env):
Expand Down
2 changes: 2 additions & 0 deletions modules/raycast/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ def can_build(env, platform):
return False

# Depends on Embree library, which only supports x86_64 and aarch64.
if env["arch"].startswith("rv"):
return False

if platform == "android":
return env["android_arch"] in ["arm64v8", "x86_64"]
Expand Down
2 changes: 1 addition & 1 deletion modules/regex/config.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
def can_build(env, platform):
return True
return not env["arch"].startswith("rv")


def configure(env):
Expand Down
2 changes: 2 additions & 0 deletions modules/webm/config.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
def can_build(env, platform):
if env["arch"].startswith("rv"):
return False
return platform not in ["iphone"]


Expand Down
7 changes: 7 additions & 0 deletions platform/x11/detect.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,13 @@ def configure(env):
if env["bits"] == "default":
env["bits"] = "64" if is64 else "32"

if env["arch"] == "" and platform.machine() == "riscv64":
env["arch"] = "rv64"

if env["arch"] == "rv64":
# G = General-purpose extensions, C = Compression extension (very common).
env.Append(CCFLAGS=["-march=rv64gc"])

## Compiler configuration

if "CXX" in env and "clang" in os.path.basename(env["CXX"]):
Expand Down