Skip to content

Commit bf1e27c

Browse files
Dan AlbertDanAlbert
authored andcommitted
Enable riscv64 for most samples.
This isn't a supported ABI yet, but I want to enable it here to get ahead of some of that work. I just disabled that config for any of the samples which don't already work with rv64. There are a few reasons why some samples don't work with rv64 yet, noted in the comments next to the line that disables the ABI. Most of them are because some upstream dependency doesn't yet include rv64 libraries, and there's nothing we can do about that here. I haven't actually tested that any of these run because I don't have the hardware to do so.
1 parent fd32862 commit bf1e27c

File tree

13 files changed

+169
-8
lines changed

13 files changed

+169
-8
lines changed

audio-echo/app/src/main/cpp/CMakeLists.txt

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.22.1)
22
project(echo LANGUAGES C CXX)
33

44
add_library(echo
5-
SHARED
5+
SHARED
66
audio_main.cpp
77
audio_player.cpp
88
audio_recorder.cpp
@@ -12,12 +12,28 @@ add_library(echo
1212

1313
#include libraries needed for echo lib
1414
target_link_libraries(echo
15-
PRIVATE
15+
PRIVATE
1616
OpenSLES
1717
android
1818
log
1919
atomic)
2020

2121
target_compile_options(echo
22-
PRIVATE
23-
-Wall -Werror)
22+
PRIVATE
23+
-Wall
24+
-Werror
25+
)
26+
27+
if (ANDROID_ABI STREQUAL riscv64)
28+
# This sample uses OpenSLES, which was deprecated in API 26. Our
29+
# minSdkVersion is 21, but we also build for riscv64, which isn't a
30+
# supported ABI yet and so that configuration is built for the latest API
31+
# level supported by the NDK.
32+
#
33+
# Longer term, this sample should probably be deleted. App developers
34+
# should be using Oboe rather than OpenSLES, and we already have a separate
35+
# sample for Oboe. There is some potentially useful audio latency
36+
# measurement in this sample that should be moved to the Oboe sample before
37+
# we delete it though.
38+
target_compile_options(echo PRIVATE -Wno-deprecated-declarations)
39+
endif ()

build-logic/src/main/java/com/android/ndk/samples/buildlogic/AndroidApplicationConventionPlugin.kt

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,22 @@ class AndroidApplicationConventionPlugin : Plugin<Project> {
3232
arguments.add("-DANDROID_SUPPORT_FLEXIBLE_PAGE_SIZES=ON")
3333
}
3434
}
35+
36+
ndk {
37+
// riscv64 isn't a supported Android ABI yet (August 2025), but we're
38+
// enabling it here as part of that experiment. Until it's a supported ABI,
39+
// don't include this in your app, as Play will block uploads of APKs which
40+
// contain riscv64 libraries.
41+
abiFilters.addAll(
42+
listOf(
43+
"arm64-v8a",
44+
"armeabi-v7a",
45+
"riscv64",
46+
"x86",
47+
"x86_64",
48+
)
49+
)
50+
}
3551
}
3652
compileOptions {
3753
sourceCompatibility = Versions.JAVA

build-logic/src/main/java/com/android/ndk/samples/buildlogic/AndroidLibraryConventionPlugin.kt

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,21 @@ class AndroidLibraryConventionPlugin : Plugin<Project> {
3535
arguments.add("-DANDROID_SUPPORT_FLEXIBLE_PAGE_SIZES=ON")
3636
}
3737
}
38+
ndk {
39+
// riscv64 isn't a supported Android ABI yet (August 2025), but we're
40+
// enabling it here as part of that experiment. Until it's a supported ABI,
41+
// don't include this in your app, as Play will block uploads of APKs which
42+
// contain riscv64 libraries.
43+
abiFilters.addAll(
44+
listOf(
45+
"arm64-v8a",
46+
"armeabi-v7a",
47+
"riscv64",
48+
"x86",
49+
"x86_64",
50+
)
51+
)
52+
}
3853
}
3954
compileOptions {
4055
sourceCompatibility = Versions.JAVA

hello-libs/app/build.gradle

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,12 @@ android {
1414
arguments '-DANDROID_STL=c++_static'
1515
}
1616
}
17+
18+
ndk {
19+
// This sample relies on prebuilt libraries, and we haven't built
20+
// rv64 versions of those libraries yet.
21+
abiFilters.remove("riscv64")
22+
}
1723
}
1824

1925
externalNativeBuild {

hello-neon/app/build.gradle

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,23 @@ plugins {
44

55
android {
66
namespace 'com.example.helloneon'
7-
7+
88
defaultConfig {
99
applicationId "com.example.helloneon"
1010
versionCode 1
1111
versionName "1.0"
12+
13+
ndk {
14+
// rv64 doesn't support Neon intrinsics. You shouldn't really use
15+
// those anyway, since they're just a non-portable wrapper around
16+
// the portable Clang vector intrinsics:
17+
//
18+
// https://clang.llvm.org/docs/LanguageExtensions.html#vectors-and-extended-vectors
19+
//
20+
// TODO: Delete this sample in favor of a better one.
21+
// https://github.com/android/ndk-samples/issues/1011
22+
abiFilters.remove("riscv64")
23+
}
1224
}
1325

1426
externalNativeBuild {

hello-oboe/app/build.gradle

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,18 @@ plugins {
55

66
android {
77
namespace 'com.google.example.hellooboe'
8-
8+
99
defaultConfig {
1010
applicationId "com.google.example.hellooboe"
1111
versionCode 1
1212
versionName "1.0"
1313
externalNativeBuild.cmake {
14-
arguments "-DANDROID_STL=c++_shared"
14+
arguments "-DANDROID_STL=c++_shared"
15+
}
16+
17+
ndk {
18+
// Oboe doesn't currently (August 2025) include riscv64 libraries.
19+
abiFilters.remove("riscv64")
1520
}
1621
}
1722

hello-vulkan/app/build.gradle

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ plugins {
2121

2222
android {
2323
namespace 'com.android.hellovk'
24-
24+
2525
defaultConfig {
2626
applicationId 'com.android.hellovk'
2727
// TODO: Figure out why this isn't 24.
@@ -35,6 +35,11 @@ android {
3535
shaders {
3636
glslcArgs.addAll(['-c'])
3737
}
38+
ndk {
39+
// GameActivity doesn't currently (August 2025) include riscv64
40+
// libraries.
41+
abiFilters.remove("riscv64")
42+
}
3843
}
3944

4045
externalNativeBuild {

native-activity/app/src/main/cpp/CMakeLists.txt

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,3 +41,16 @@ target_link_libraries(native-activity
4141
EGL
4242
GLESv1_CM
4343
log)
44+
45+
if (ANDROID_ABI STREQUAL riscv64)
46+
# This sample uses Sensor Manager and Choreographer APIs which are
47+
# deprecated in modern API levels. Our minSdkVersion is 21, but we also
48+
# build for riscv64, which isn't a supported ABI yet and so that
49+
# configuration is built for the latest API level supported by the NDK.
50+
#
51+
# This sample should be tweaked to use the replacement APIs when they're
52+
# available at runtime and only use the older APIs on older devices. For
53+
# now, just disable the deprecation warnings so we can get the riscv64
54+
# samples building in CI, and we can come back to clean that up later.
55+
target_compile_options(native-activity PRIVATE -Wno-deprecated-declarations)
56+
endif ()

prefab/curl-ssl/app/build.gradle

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,12 @@ android {
3434
}
3535
}
3636
}
37+
38+
ndk {
39+
// None of the ndkports libraries currently (August 2025) include
40+
// riscv64 libraries.
41+
abiFilters.remove("riscv64")
42+
}
3743
}
3844

3945
externalNativeBuild {

prefab/prefab-dependency/app/build.gradle

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,12 @@ android {
3434
}
3535
}
3636
}
37+
38+
ndk {
39+
// None of the ndkports libraries currently (August 2025) include
40+
// riscv64 libraries.
41+
abiFilters.remove("riscv64")
42+
}
3743
}
3844

3945
externalNativeBuild {

0 commit comments

Comments
 (0)