moritz-wundke / Boost-for-Android

Android port of Boost C++ Libraries
995 stars 479 forks source link

Build Boost 1.70.0 By NDK r21e, product libthread libsystem size is unnormal #266

Open khailifz opened 2 months ago

khailifz commented 2 months ago

We once had a colleague who submitted the compiled Android version of boost dynamic library in the code warehouse, but he resigned. Now we want to use the source code to compile it, and found that his version, regardless of the size of the thread library or system library, was compiled by myself. The difference is a lot, the following is the result of readelf

His boost lib

-rwxr-xr-x 1 root 6295760 Nov 28 16:01 libboost_thread-clang-mt-1_70.so

readelf -d libboost_thread-clang-mt-a64-1_70.so.1.70.0

Dynamic section at offset 0xdcbc0 contains 28 entries: Tag Type Name/Value 0x0000000000000001 (NEEDED) Shared library: [libm.so] 0x0000000000000001 (NEEDED) Shared library: [libdl.so] 0x0000000000000001 (NEEDED) Shared library: [libc.so] 0x000000000000000e (SONAME) Library soname: [libboost_thread-clang-mt-a64-1_70.so.1.70.0] 0x0000000000000019 (INIT_ARRAY) 0xd6508 0x000000000000001b (INIT_ARRAYSZ) 16 (bytes) 0x000000000000001a (FINI_ARRAY) 0xd6518 0x000000000000001c (FINI_ARRAYSZ) 16 (bytes) 0x0000000000000004 (HASH) 0x1c8 0x000000006ffffef5 (GNU_HASH) 0x44a8 0x0000000000000005 (STRTAB) 0x15dd8 0x0000000000000006 (SYMTAB) 0x8d58 0x000000000000000a (STRSZ) 105438 (bytes) 0x000000000000000b (SYMENT) 24 (bytes) 0x0000000000000003 (PLTGOT) 0xdddc0 0x0000000000000002 (PLTRELSZ) 9288 (bytes) 0x0000000000000014 (PLTREL) RELA 0x0000000000000017 (JMPREL) 0x44bc8 0x0000000000000007 (RELA) 0x30b58 0x0000000000000008 (RELASZ) 82032 (bytes) 0x0000000000000009 (RELAENT) 24 (bytes) 0x000000000000001e (FLAGS) BIND_NOW 0x000000006ffffffb (FLAGS_1) Flags: NOW 0x000000006ffffffe (VERNEED) 0x30b18 0x000000006fffffff (VERNEEDNUM) 2 0x000000006ffffff0 (VERSYM) 0x2f9b6 0x000000006ffffff9 (RELACOUNT) 1421 0x0000000000000000 (NULL) 0x0

my boost lib

-rwxr-xr-x 1 root 1334544 May 14 09:07 libboost_thread-clang-mt-a64-1_70.so.1.70.0
$ readelf -d libboost_thread-clang-mt-a64-1_70.so.1.70.0 Dynamic section at offset 0x25878 contains 29 entries: Tag Type Name/Value 0x0000000000000001 (NEEDED) Shared library: [libc++_shared.so] 0x0000000000000001 (NEEDED) Shared library: [libm.so] 0x0000000000000001 (NEEDED) Shared library: [libdl.so] 0x0000000000000001 (NEEDED) Shared library: [libc.so] 0x000000000000000e (SONAME) Library soname: [libboost_thread-clang-mt-a64-1_70.so.1.70.0] 0x0000000000000019 (INIT_ARRAY) 0x24ce8 0x000000000000001b (INIT_ARRAYSZ) 16 (bytes) 0x000000000000001a (FINI_ARRAY) 0x24cf8 0x000000000000001c (FINI_ARRAYSZ) 16 (bytes) 0x0000000000000004 (HASH) 0x1c8 0x000000006ffffef5 (GNU_HASH) 0xaa8 0x0000000000000005 (STRTAB) 0x2ca8 0x0000000000000006 (SYMTAB) 0x1040 0x000000000000000a (STRSZ) 11572 (bytes) 0x000000000000000b (SYMENT) 24 (bytes) 0x0000000000000003 (PLTGOT) 0x26a88 0x0000000000000002 (PLTRELSZ) 2640 (bytes) 0x0000000000000014 (PLTREL) RELA 0x0000000000000017 (JMPREL) 0x9f70 0x0000000000000007 (RELA) 0x5c80 0x0000000000000008 (RELASZ) 17136 (bytes) 0x0000000000000009 (RELAENT) 24 (bytes) 0x000000000000001e (FLAGS) BIND_NOW 0x000000006ffffffb (FLAGS_1) Flags: NOW 0x000000006ffffffe (VERNEED) 0x5c40 0x000000006fffffff (VERNEEDNUM) 2 0x000000006ffffff0 (VERSYM) 0x59dc 0x000000006ffffff9 (RELACOUNT) 399 0x0000000000000000 (NULL) 0x0

Boost Version: 1.70.0 NDK Version: r21e Other modification: build-android.sh change link=static to link=shared

build command is ./build-android.sh /home/software/android_ndk/android-ndk-r21e --arch=arm64-v8a,armeabi-v7a --boost=1.70.0