android-riscv64 icon indicating copy to clipboard operation
android-riscv64 copied to clipboard

cmake: add riscv64 android to upstream?

Open truboxl opened this issue 1 year ago • 5 comments

Is it time to add riscv64-linux-android to cmake? I try building projects with NDK r27c but cmake seems to fall short of support. I patch the cmake files myself to add the missing support.

--- a/Modules/Platform/Android/abi-riscv64-Clang.cmake
+++ b/Modules/Platform/Android/abi-riscv64-Clang.cmake
@@ -0,0 +1 @@
+include(Platform/Android/abi-common-Clang)
--- a/Modules/Platform/Android-Determine.cmake
+++ b/Modules/Platform/Android-Determine.cmake
@@ -353,6 +353,10 @@
   set(NDK_ABI_x86_64_ARCH              "x86_64")
   set(NDK_ABI_x86_64_TRIPLE            "x86_64-linux-android")
   set(NDK_ABI_x86_64_LLVM_TRIPLE       "x86_64-none-linux-android")
+  set(NDK_ABI_riscv64_PROC             "riscv64")
+  set(NDK_ABI_riscv64_ARCH             "riscv64")
+  set(NDK_ABI_riscv64_TRIPLE           "riscv64-linux-android")
+  set(NDK_ABI_riscv64_LLVM_TRIPLE      "riscv64-none-linux-android")
 
   set(NDK_PROC_aarch64_ABI "arm64-v8a")
   set(NDK_PROC_armv7-a_ABI "armeabi-v7a")
@@ -362,13 +366,15 @@
   set(NDK_PROC_mips_ABI    "mips")
   set(NDK_PROC_mips64_ABI  "mips64")
   set(NDK_PROC_x86_64_ABI  "x86_64")
+  set(NDK_PROC_riscv64_ABI "riscv64")
 
-  set(NDK_ARCH_arm64_ABI  "arm64-v8a")
-  set(NDK_ARCH_arm_ABI    "armeabi")
-  set(NDK_ARCH_mips_ABI   "mips")
-  set(NDK_ARCH_mips64_ABI "mips64")
-  set(NDK_ARCH_x86_ABI    "x86")
-  set(NDK_ARCH_x86_64_ABI "x86_64")
+  set(NDK_ARCH_arm64_ABI   "arm64-v8a")
+  set(NDK_ARCH_arm_ABI     "armeabi")
+  set(NDK_ARCH_mips_ABI    "mips")
+  set(NDK_ARCH_mips64_ABI  "mips64")
+  set(NDK_ARCH_x86_ABI     "x86")
+  set(NDK_ARCH_x86_64_ABI  "x86_64")
+  set(NDK_ARCH_riscv64_ABI "riscv64")
 endif()
 
 # Validate inputs.
@@ -525,6 +531,9 @@
     if(CMAKE_ANDROID_ARCH_ABI MATCHES "64(-v8a)?$" AND CMAKE_SYSTEM_VERSION LESS 21)
       set(CMAKE_SYSTEM_VERSION 21)
     endif()
+    if(CMAKE_ANDROID_ARCH_ABI MATCHES "^riscv64$" AND CMAKE_SYSTEM_VERSION LESS 35)
+      set(CMAKE_SYSTEM_VERSION 35)
+    endif()
   else()
     file(GLOB _ANDROID_APIS_1 RELATIVE "${CMAKE_ANDROID_NDK}/platforms" "${CMAKE_ANDROID_NDK}/platforms/android-[0-9]")
     file(GLOB _ANDROID_APIS_2 RELATIVE "${CMAKE_ANDROID_NDK}/platforms" "${CMAKE_ANDROID_NDK}/platforms/android-[0-9][0-9]")

truboxl avatar Nov 20 '24 16:11 truboxl

lol that mips/mips64 are in that list...

enh-google avatar Nov 20 '24 17:11 enh-google

I think can assign me for this issue (is this how it works here?)

truboxl avatar Jun 21 '25 03:06 truboxl

@DanAlbert but this doesn't seem unreasonable, given that ndk-build already has support?

enh-google avatar Jun 23 '25 14:06 enh-google

(and please feel free to remove mips/mips64 while you're there!)

enh-google avatar Jun 23 '25 14:06 enh-google

The NDK's toolchain file already supports it. This is about the upstream thing which we don't maintain or support. No objections from me, just FYI to anyone reading this that if you're using that without having read the caution here, you should read that.

DanAlbert avatar Jun 24 '25 19:06 DanAlbert