Skip to content

Commit

Permalink
Merge pull request #53508 from aaronfranke/riscv
Browse files Browse the repository at this point in the history
  • Loading branch information
akien-mga committed Oct 22, 2021
2 parents 3bebbca + 474d0f5 commit 9282b0d
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 4 deletions.
9 changes: 9 additions & 0 deletions core/os/os.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -431,6 +431,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
5 changes: 3 additions & 2 deletions modules/denoise/config.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
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.
desktop_platforms = ["linuxbsd", "osx", "windows"]
return env["tools"] and platform in desktop_platforms and env["bits"] == "64" and env["arch"] != "arm64"
supported_arch = env["bits"] == "64" and env["arch"] != "arm64" and not env["arch"].startswith("rv")
return env["tools"] and platform in desktop_platforms and supported_arch


def configure(env):
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
@@ -1,5 +1,7 @@
def can_build(env, platform):
# 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/theora/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 env.module_check_dependencies("theora", ["ogg", "vorbis"])


Expand Down
7 changes: 7 additions & 0 deletions platform/linuxbsd/detect.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,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

0 comments on commit 9282b0d

Please sign in to comment.