android-sdk-tools
android-sdk-tools copied to clipboard
Riscv64 support
How i can to add riscv64? update: i found this https://github.com/riscv-android-src/riscv-android/blob/main/doc/prebuilt_projects.md for build prebuilds and ndk.
Clang supports riscv backend, building from scratch is not required for ndk, you just need the sysroot of riscv
Do they provide precompiled toolchains? if there is, you can directly specify the sysroot flag clang --target=riscv64-linux-android --sysroot=/path/to/sysroot
Of course this just compiles, just like you can cross-compile aarch64 on x86_64, but you can't execute it
I cant build it by error
Ubunut 22.04 LTS
/home/ubuntu/bld/sdk-tools-source/src/logging/liblog/pmsg_reader.cpp:199:9: error: use of undeclared identifier 'SSIZE_MAX'
ret = SSIZE_MAX;
^
/home/ubuntu/bld/sdk-tools-source/src/logging/liblog/pmsg_reader.cpp:454:22: error: use of undeclared identifier 'SSIZE_MAX'
if (ret == SSIZE_MAX) {
^
/home/ubuntu/bld/sdk-tools-source/src/logging/liblog/pmsg_reader.cpp:468:18: error: use of undeclared identifier 'SSIZE_MAX'
return (ret == SSIZE_MAX) ? -ENOENT : ret;
I think it related with some dependency.
What OS are you using to build it?
ubuntu 21.04
android-ndk-r24
no dependency, the SSIZE_MAX is defined in android-ndk-r24/**/sysroot/usr/include/limits.h
python build.py \
--ndk=/path/to/android-ndk-xxx \
--arch aarch64
For test scripts i decided in first just build by guide README.md. I took fresh docker image with ubuntu 22.04 installed tools and run command
python build.py \
--ndk=/path/to/android-ndk-xxx \
--arch aarch64
I have the error
...
- Found PythonInterp: /usr/bin/python3.10 (found version "3.10.4")
--
-- 3.9.1.0
-- Found BISON: /usr/bin/bison (found version "3.8.2")
-- Found FLEX: /usr/bin/flex (found version "2.6.4")
-- /root/sdk-tools-source/src/aidl/aidl_language_l.cpp/root/sdk-tools-source/src/aidl/aidl_language_l.h
-- /root/sdk-tools-source/src/aidl/aidl_language_y.cpp/root/sdk-tools-source/src/aidl/aidl_language_y.h
-- Configuring done
CMake Error: The following variables are used in this project, but they are set to NOTFOUND.
Please set them or make sure they are set and tested correctly in the CMake files:
M_LIBRARY
linked by target "png-fix-itxt" in directory /root/sdk-tools-source/src/libpng
linked by target "png" in directory /root/sdk-tools-source/src/libpng
linked by target "png_static" in directory /root/sdk-tools-source/src/libpng
-- Generating done
CMake Generate step failed. Build files cannot be regenerated correctly.
modify src/libpng/CMakeLists.txt
if(UNIX AND NOT APPLE AND NOT BEOS AND NOT HAIKU)
find_library(M_LIBRARY m)
else()
# libm is not needed and/or not available
set(M_LIBRARY "")
endif()
# set M_LIBRARY direct
set(M_LIBRARY "m")
I did it but have the error
ld: error: unable to find library -lpthread
clang-14: error: linker command failed with exit code 1 (use -v to see invocation)
modify CMakeLists.txt, change -lpthread to -lc
or
add a libpthread.so, for example execute the following command:
echo 'INPUT(-lc)' > /path/to/android-ndk-xxx/**/sysroot/usr/lib/aarch64-linux-android/30/libpthread.so
android has no libpthread.so and librt.so
libpthread == libc
librt == libc
i did it
ar cr /path/to/android-ndk-xxx/**/sysroot/usr/lib/aarch64-linux-android/30/libpthread.a
but now I have another error related with libpng
[999/1474] Linking CXX executable bin/aapt
FAILED: bin/aapt
: && /root/n24/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android30-clang++ -fcolor-diagnostics -fPIC -Wno-attributes -std=gnu++2a -O3 -DNDEBUG -static build-tools/CMakeFiles/aapt.dir/__/src/base/tools/aapt/Main.cpp.o -o bin/aapt lib/liblibaapt.a lib/liblibandroidfw.a lib/liblibincfs.a lib/liblibutils.a lib/liblibcutils.a lib/liblibselinux.a lib/liblibsepol.a lib/liblibziparchive.a lib/liblibpackagelistparser.a lib/liblibbase.a lib/liblibbuildversion.a lib/liblibprocessgroup.a lib/libliblog.a src/expat/libexpat.a src/boringssl/crypto/libcrypto.a src/pcre/libpcre2-8.a lib/libjsoncpp.a src/libpng/libpng16.a -lc++_static -ldl -lz src/fmtlib/libfmt.a -lpthread -lm && :
ld: error: undefined symbol: png_do_expand_palette_rgba8_neon
>>> referenced by pngrtran.c
>>> pngrtran.c.o:(png_do_read_transformations) in archive src/libpng/libpng16.a
ld: error: undefined symbol: png_riffle_palette_neon
>>> referenced by pngrtran.c
>>> pngrtran.c.o:(png_do_read_transformations) in archive src/libpng/libpng16.a
ld: error: undefined symbol: png_do_expand_palette_rgb8_neon
>>> referenced by pngrtran.c
>>> pngrtran.c.o:(png_do_read_transformations) in archive src/libpng/libpng16.a
ld: error: undefined symbol: png_init_filter_functions_neon
>>> referenced by pngrutil.c
>>> pngrutil.c.o:(png_read_filter_row) in archive src/libpng/libpng16.a
clang-14: error: linker command failed with exit code 1 (use -v to see invocation)
modify libpng/CMakeLists.txt, about line 32
// enable NEON
add_definitions(-DPNG_ARM_NEON_INTRINSICS_AVAILABLE)
I modified it, but same error For clean test I removed sdk-tools-src directory. Also tried
add_definitions(-DPNG_ARM_NEON_INTRINSICS_AVAILABLE=1)
in out I see
/root/sts/src/libpng/pngrtran.c:23:13: warning: 'PNG_ARM_NEON_INTRINSICS_AVAILABLE' macro redefined [-Wmacro-redefined]
# define PNG_ARM_NEON_INTRINSICS_AVAILABLE
^
<command line>:1:9: note: previous definition is here
#define PNG_ARM_NEON_INTRINSICS_AVAILABLE 1
^
but I have same error
This error comes from CMAKE_SYSTEM_PROCESSOR detection,
CMAKE_SYSTEM_PROCESSOR == host arch(linux-x86_64), not aarch64 or arm, so the libpng_arm_sources source file will not be compiled, this problem will be fixed in the next update, use cmake_toolchain_file instead of using the clang compiler directly.
# set definitions and sources for arm
if(CMAKE_SYSTEM_PROCESSOR MATCHES "^arm" OR
CMAKE_SYSTEM_PROCESSOR MATCHES "^aarch64")
set(PNG_ARM_NEON_POSSIBLE_VALUES check on off)
set(PNG_ARM_NEON "check" CACHE STRING "Enable ARM NEON optimizations:
check: (default) use internal checking code;
off: disable the optimizations;
on: turn on unconditionally.")
set_property(CACHE PNG_ARM_NEON PROPERTY STRINGS
${PNG_ARM_NEON_POSSIBLE_VALUES})
list(FIND PNG_ARM_NEON_POSSIBLE_VALUES ${PNG_ARM_NEON} index)
if(index EQUAL -1)
message(FATAL_ERROR
"PNG_ARM_NEON must be one of [${PNG_ARM_NEON_POSSIBLE_VALUES}]")
elseif(NOT ${PNG_ARM_NEON} STREQUAL "off")
set(libpng_arm_sources
arm/arm_init.c
arm/filter_neon.S
arm/filter_neon_intrinsics.c
arm/palette_neon_intrinsics.c)
if(${PNG_ARM_NEON} STREQUAL "on")
add_definitions(-DPNG_ARM_NEON_OPT=2)
elseif(${PNG_ARM_NEON} STREQUAL "check")
add_definitions(-DPNG_ARM_NEON_CHECK_SUPPORTED)
endif()
else()
add_definitions(-DPNG_ARM_NEON_OPT=0)
endif()
endif()
You can also try to build it with Termux on the device, it should work
note that, need to download the termux-ndk I provided, because requires api >= 30