mirror of
https://github.com/dart-lang/sdk
synced 2024-10-04 16:35:01 +00:00
[build] Android RISCV64 using a Canary NDK.
Change-Id: I447941fd4eee0c1e4394b3ab5c0b9c36a7b4c257 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/330701 Reviewed-by: Zach Anderson <zra@google.com> Commit-Queue: Ryan Macnak <rmacnak@google.com>
This commit is contained in:
parent
7369dcb401
commit
90d488b98e
11
DEPS
11
DEPS
|
@ -605,6 +605,17 @@ Var("dart_root") + "/third_party/pkg/tar":
|
|||
"dep_type": "cipd",
|
||||
},
|
||||
|
||||
Var("dart_root") + "/third_party/canary_ndk": {
|
||||
"packages": [
|
||||
{
|
||||
"package": "flutter/android/ndk/${{os}}-amd64",
|
||||
"version": "version:r27.0.10869015"
|
||||
}
|
||||
],
|
||||
"condition": "download_android_deps",
|
||||
"dep_type": "cipd",
|
||||
},
|
||||
|
||||
Var("dart_root") + "/third_party/android_tools": {
|
||||
"packages": [
|
||||
{
|
||||
|
|
|
@ -55,6 +55,9 @@ if (is_android) {
|
|||
|
||||
# Path to the Android NDK and SDK.
|
||||
android_ndk_root = "//third_party/android_tools/ndk"
|
||||
if (current_cpu == "riscv64") {
|
||||
android_ndk_root = "//third_party/canary_ndk"
|
||||
}
|
||||
android_ndk_include_dir = "$android_ndk_root/usr/include"
|
||||
|
||||
android_sdk = "${android_sdk_root}/platforms/android-${android_sdk_version}"
|
||||
|
@ -70,7 +73,9 @@ if (is_android) {
|
|||
|
||||
# Subdirectories inside android_ndk_root that contain the sysroot for the
|
||||
# associated platform.
|
||||
if (current_cpu == "x64" || current_cpu == "arm64") {
|
||||
if (current_cpu == "riscv64") {
|
||||
android_api_level = 35
|
||||
} else if (current_cpu == "x64" || current_cpu == "arm64") {
|
||||
android_api_level = 22
|
||||
} else {
|
||||
android_api_level = 19
|
||||
|
@ -86,11 +91,13 @@ if (is_android) {
|
|||
arm_android_toolchain_root = "$android_ndk_root/toolchains/arm-linux-androideabi-${_android_toolchain_version}/prebuilt/${android_host_os}-${android_host_arch}"
|
||||
x86_64_android_toolchain_root = "$android_ndk_root/toolchains/x86_64-${_android_toolchain_version}/prebuilt/${android_host_os}-${android_host_arch}"
|
||||
arm64_android_toolchain_root = "$android_ndk_root/toolchains/aarch64-linux-android-${_android_toolchain_version}/prebuilt/${android_host_os}-${android_host_arch}"
|
||||
riscv64_android_toolchain_root = "$android_ndk_root/toolchains/llvm/prebuilt/${android_host_os}-${android_host_arch}"
|
||||
|
||||
x86_android_lib = "$llvm_android_toolchain_root/sysroot/usr/lib/i686-linux-android/${android_api_level}"
|
||||
arm_android_lib = "$llvm_android_toolchain_root/sysroot/usr/lib/arm-linux-androideabi/${android_api_level}"
|
||||
x86_64_android_lib = "$llvm_android_toolchain_root/sysroot/usr/lib/x86_64-linux-android/${android_api_level}"
|
||||
arm64_android_lib = "$llvm_android_toolchain_root/sysroot/usr/lib/aarch64-linux-android/${android_api_level}"
|
||||
riscv64_android_lib = "$llvm_android_toolchain_root/sysroot/usr/lib/riscv64-linux-android/${android_api_level}"
|
||||
|
||||
# Location of libgcc. This is only needed for the current GN toolchain, so we
|
||||
# only need to define the current one, rather than one for every platform
|
||||
|
@ -115,6 +122,11 @@ if (is_android) {
|
|||
android_target_triple = "aarch64-linux-android"
|
||||
android_toolchain_root = "$arm64_android_toolchain_root"
|
||||
android_lib = "$arm64_android_lib"
|
||||
} else if (current_cpu == "riscv64") {
|
||||
android_prebuilt_arch = "android-riscv64"
|
||||
android_target_triple = "riscv64-linux-android"
|
||||
android_toolchain_root = "$riscv64_android_toolchain_root"
|
||||
android_lib = "$riscv64_android_lib"
|
||||
} else {
|
||||
assert(false, "Need android libgcc support for your target arch.")
|
||||
}
|
||||
|
@ -157,6 +169,8 @@ if (is_android) {
|
|||
android_app_abi = "x86_64"
|
||||
} else if (current_cpu == "arm64") {
|
||||
android_app_abi = "arm64-v8a"
|
||||
} else if (current_cpu == "riscv64") {
|
||||
android_app_abi = "riscv64"
|
||||
} else {
|
||||
assert(false, "Unknown Android ABI: " + current_cpu)
|
||||
}
|
||||
|
|
|
@ -415,6 +415,9 @@ config("compiler") {
|
|||
} else if (current_cpu == "x64") {
|
||||
cflags += [ "--target=x86_64-linux-androideabi" ]
|
||||
ldflags += [ "--target=x86_64-linux-androideabi" ]
|
||||
} else if (current_cpu == "riscv64") {
|
||||
cflags += [ "--target=riscv64-linux-android" ]
|
||||
ldflags += [ "--target=riscv64-linux-android" ]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -600,11 +603,6 @@ config("runtime_library") {
|
|||
|
||||
lib_dirs += [ "$android_libcpp_root/libs/$android_app_abi" ]
|
||||
|
||||
libs += [
|
||||
"$android_libcpp_library",
|
||||
"c++abi",
|
||||
]
|
||||
|
||||
if (android_api_level < 21) {
|
||||
libs += [ "android_support" ]
|
||||
}
|
||||
|
@ -619,6 +617,11 @@ config("runtime_library") {
|
|||
"dl",
|
||||
"m",
|
||||
]
|
||||
if (current_cpu == "riscv64") {
|
||||
libs -= [ "gcc" ]
|
||||
lib_dirs += [ "//third_party/canary_ndk/toolchains/llvm/prebuilt/${android_host_os}-${android_host_arch}/lib/clang/17/lib/linux/" ]
|
||||
libs += [ "clang_rt.builtins-riscv64-android" ]
|
||||
}
|
||||
|
||||
# Clang with libc++ does not require an explicit atomic library reference.
|
||||
if (!is_clang) {
|
||||
|
|
|
@ -45,6 +45,11 @@ template("android_gcc_toolchain") {
|
|||
not_needed([ "tool_prefix" ])
|
||||
prefix =
|
||||
rebase_path("//buildtools/${host_os}-x64/clang/bin", root_build_dir)
|
||||
if (current_cpu == "riscv64") {
|
||||
prefix = rebase_path(
|
||||
"//third_party/canary_ndk/toolchains/llvm/prebuilt/${android_host_os}-${android_host_arch}/bin",
|
||||
root_build_dir)
|
||||
}
|
||||
|
||||
cc = compiler_prefix + prefix + "/clang"
|
||||
cxx = compiler_prefix + prefix + "/clang++"
|
||||
|
@ -130,3 +135,10 @@ android_gcc_toolchains_helper("arm64") {
|
|||
tool_prefix = "$llvm_android_toolchain_root/bin/aarch64-linux-android-"
|
||||
toolchain_cpu = "aarch64"
|
||||
}
|
||||
|
||||
android_gcc_toolchains_helper("riscv64") {
|
||||
android_ndk_lib_dir = riscv64_android_lib
|
||||
|
||||
tool_prefix = "$llvm_android_toolchain_root/bin/riscv64-linux-android-"
|
||||
toolchain_cpu = "riscv64"
|
||||
}
|
||||
|
|
|
@ -384,6 +384,7 @@ def ProcessOptions(args):
|
|||
'arm64',
|
||||
'x64c',
|
||||
'arm64c',
|
||||
'riscv64',
|
||||
]:
|
||||
print(
|
||||
"Cross-compilation to %s is not supported for architecture %s."
|
||||
|
|
Loading…
Reference in a new issue