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

Conversation

aaronfranke
Copy link
Member

Implements godotengine/godot-proposals#3374 on 3.x. Only Clang Debug builds work on RISC-V right now.

SConstruct Outdated Show resolved Hide resolved
@akien-mga akien-mga added this to the 3.5 milestone Oct 22, 2021
@aaronfranke aaronfranke force-pushed the 3.x-riscv branch 2 times, most recently from 76f0279 to 52fa61e Compare October 22, 2021 15:59
@aaronfranke aaronfranke requested a review from a team as a code owner October 22, 2021 15:59
SConstruct Outdated
Comment on lines 497 to 498
if env["arch"] == "" and machine() == "riscv64":
env["arch"] = "rv64"
Copy link
Member

@akien-mga akien-mga Oct 22, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would move this to the Linux detect.py too. It won't add the arch to extra_suffix, but this isn't done for i386, i686, x86_64, armv7hl or aarch64 on Linux currently, so we shouldn't do it for rv64 only.

Like it's done for aarch64 currently, it should be clear to someone compiling on RISC-V hardware that their godot.linuxbsd.opt.tools.64 binary targets RISC-V (especially if they passed arch=rv64 for that).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

BTW, this check also makes it impossible to cross-compile from RISC-V to other architectures.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I made the change locally to test it. To my surprise, it actually does add the arch to the suffix. It calls the configure method on line 397. So yeah, moving this to detect.py works well.

BTW, this check also makes it impossible to cross-compile from RISC-V to other architectures.

It's not possible to cross-compile for x86 regardless as far as I can tell. For this code specifically, it doesn't make it impossible because this code only runs if env["arch"] == "" so you just have to say arch=arm64 or arch=x86_64, even if it's not picked up by the engine, this will stop it from being equal to "". Still, as I mentioned it's not possible to cross-compile for x86 regardless, we don't have any code in the build system to tell the compiler to target x86. Also, cross-compiling from RISC-V is super niche :P

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

True, specifying a different arch would work. You can still cross-compile by passing CC and CXX manually to use the compilers for that architecture.

Supports RV64GC (RISC-V 64-bit with general-purpose and compressed-instruction extensions)
@akien-mga
Copy link
Member

With the current form I think it's fine to merge for 3.4 even if it's not critical for that release. It's an extra option provided as is, without expectation that it actually works. But that's a start.

@akien-mga akien-mga modified the milestones: 3.5, 3.4 Oct 22, 2021
@akien-mga akien-mga merged commit 18aaa88 into godotengine:3.x Oct 22, 2021
@akien-mga
Copy link
Member

Thanks!

@danboid
Copy link

danboid commented May 29, 2023

I'm going to try building godot under Debian sid on my VisionFive2. Am I right in thinking the build command is:

scons platform=linuxbsd use_llvm=yes

Thanks

@aaronfranke
Copy link
Member Author

@danboid Yes, that is correct. Actually just scons use_llvm=yes should be sufficient and it will auto-detect platform=linuxbsd arch=rv64 from your OS and hardware.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants