The size of android libtvm_runtime.so is too large

Hi all I cross-build android libtvm_runtime.so,Use the following script, and The size of the generated library is close to 8M, How to reduce the size of the library? Thanks!

#!/bin/bash
set -e
export ANDROID_NDK=/home/yangjie/android-ndk-r23b
BUILD_DIR=buildruntime
mkdir $BUILD_DIR
cd $BUILD_DIR
cmake ../ \
      -DCMAKE_TOOLCHAIN_FILE=$ANDROID_NDK/build/cmake/android.toolchain.cmake \
      -DCMAKE_BUILD_TYPE=Release \
      -DANDROID_ABI="arm64-v8a" \
      -DANDROID_NATIVE_API_LEVEL=android-17
make runtime -j20

You could strip the debug sections from the shared object:

${ANDROID_NDK}/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-strip -g libtvm_runtime.so

That will reduce the size of the file, but not the size of any loadable segments. Is the file size your main concern?

1 Like

Hi @kparzysz
Thanks, This command is very useful, reducing the size by half,The current size is close to 4M. Is there any other optimization method? I need the final volume below 2M, preferably around 1M.

Hi @kparzysz Thanks, This command is very useful, reducing the size by half,The current size is close to 4M. Is there any other optimization method? I need the final volume below 2M, preferably around 1M.