How to reduce the size of libchrome.so when build Chromium Android?

916 views
Skip to first unread message

Hsing-Wang Liao

unread,
Mar 15, 2017, 5:21:22 AM3/15/17
to Chromium-dev
I want to have a Chromium core in my app, but the libchrome.so is about 50M, It is too big. How can I reduce the size? Can any body share me the args.gn file?

Primiano Tucci

unread,
Mar 15, 2017, 6:40:34 AM3/15/17
to kuo...@gmail.com, Chromium-dev
Is this arm32 or arm64? By looking at our chromeperf dashboard [1] the expected size of libchrome.so for an official build on arm 32 is 26 MB.
using: is_official_build=true, debug=false, should be enough to get to that state.


On Wed, Mar 15, 2017 at 9:21 AM Hsing-Wang Liao <kuo...@gmail.com> wrote:
I want to have a Chromium core in my app, but the libchrome.so is about 50M, It is too big. How can I reduce the size? Can any body share me the args.gn file?

--
--
Chromium Developers mailing list: chromi...@chromium.org
View archives, change email options, or unsubscribe:
http://groups.google.com/a/chromium.org/group/chromium-dev
---
You received this message because you are subscribed to the Google Groups "Chromium-dev" group.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/chromium-dev/a1530490-b76e-4d06-8488-992d23dd5355%40chromium.org.

Hsing-Wang Liao

unread,
Mar 15, 2017, 7:11:03 AM3/15/17
to Chromium-dev
This is my new args.gn file:

target_os = "android"
target_cpu = "arm"
is_official_build = true
is_debug = false
symbol_level = 0
enable_nacl = false
proprietary_codecs = true
ffmpeg_branding = "Chrome"
remove_webcore_debug_symbols = true

I don't know it is arm32 or arm64. Can I get a small libchrome.so file by using these args? Thanks.

在 2017年3月15日星期三 UTC+8下午6:40:34,Primiano Tucci写道:

Anthony Berent

unread,
Mar 15, 2017, 7:20:48 AM3/15/17
to kuo...@gmail.com, Chromium-dev
It will be arm32. "arm" on its own means arm32.

--
--
Chromium Developers mailing list: chromi...@chromium.org
View archives, change email options, or unsubscribe:
http://groups.google.com/a/chromium.org/group/chromium-dev
---
You received this message because you are subscribed to the Google Groups "Chromium-dev" group.

Primiano Tucci

unread,
Mar 15, 2017, 7:31:24 AM3/15/17
to abe...@chromium.org, kuo...@gmail.com, Chromium-dev
Those gn args should give you a 26 MB .so, not 50MB
Can you paste the output of readelf -WS libchrome.so ?

Ядвига Храповицкая

unread,
Mar 15, 2017, 8:25:16 AM3/15/17
to Chromium-dev


среда, 15 марта 2017 г., 12:21:22 UTC+3 пользователь Hsing-Wang Liao написал:
I want to have a Chromium core in my app, but the libchrome.so is about 50M, It is too big. How can I reduce the size? Can any body share me the args.gn file?
Будем знакомы: ТопливоДар! Оздоровлю твоего любимца АВТО, Экологию, сэкономлю топливо и пополню кошелек! 
Заказ товара по ссылке: http://6354.topdar.info/retail 
Обучение бесплатно в Академии "Успех Вместе"в 14:00 и 19:30 

Hsing-Wang Liao

unread,
Mar 16, 2017, 5:53:58 AM3/16/17
to Chromium-dev
I get a 47M libchrome.so file:

$ du -h libchrome.so
47M libchrome.so

$ readelf -WS libchrome.so
There are 30 section headers, starting at offset 0x2ed6c08:

Section Headers:
  [Nr] Name              Type            Addr     Off    Size   ES Flg Lk Inf Al
  [ 0]                   NULL            00000000 000000 000000 00      0   0  0
  [ 1] .interp           PROGBITS        00000174 000174 000013 00   A  0   0  1
  [ 2] .note.gnu.build-id NOTE            00000188 000188 000024 00   A  0   0  4
  [ 3] .dynsym           DYNSYM          000001ac 0001ac 001960 10   A  4   1  4
  [ 4] .dynstr           STRTAB          00001b0c 001b0c 000fb9 00   A  0   0  1
  [ 5] .hash             HASH            00002ac8 002ac8 000a7c 04   A  3   0  4
  [ 6] .gnu.version      VERSYM          00003544 003544 00032c 02   A  3   0  2
  [ 7] .gnu.version_d    VERDEF          00003870 003870 00001c 00   A  4   1  4
  [ 8] .gnu.version_r    VERNEED         0000388c 00388c 000060 00   A  4   3  4
  [ 9] .rel.dyn          REL             000038ec 0038ec 28b1d0 08   A  3   0  4
  [10] .rel.plt          REL             0028eabc 28eabc 000b00 08  AI  3  11  4
  [11] .plt              PROGBITS        0028f5bc 28f5bc 001094 00  AX  0   0  4
  [12] .text             PROGBITS        00290680 290680 22e0584 00  AX  0   0 64
  [13] .ARM.exidx        ARM_EXIDX       02570c04 2570c04 1753b8 08  AL 12   0  4
  [14] .ARM.extab        PROGBITS        026e5fbc 26e5fbc 02d308 00   A  0   0  4
  [15] .rodata           PROGBITS        02713300 2713300 5d8234 00   A  0   0 256
  [16] .eh_frame         PROGBITS        02ceb534 2ceb534 00002c 00   A  0   0  4
  [17] .eh_frame_hdr     PROGBITS        02ceb560 2ceb560 000014 00   A  0   0  4
  [18] .data.rel.ro.local PROGBITS        02cec890 2ceb890 0c1a98 00  WA  0   0 16
  [19] .data.rel.ro      PROGBITS        02dae330 2dad330 1042c8 00  WA  0   0 16
  [20] .init_array       INIT_ARRAY      02eb25f8 2eb15f8 0000e4 00  WA  0   0
4
  [21] .fini_array       FINI_ARRAY      02eb26dc 2eb16dc 000008 00  WA  0   0  4
  [22] .dynamic          DYNAMIC         02eb26e4 2eb16e4 000130 08  WA  4   0  4
  [23] .got              PROGBITS        02eb2820 2eb1820 00b7e0 00  WA  0   0  4
  [24] .data             PROGBITS        02ebe000 2ebd000 0199f8 00  WA  0   0 32
  [25] .bss              NOBITS          02ed7a00 2ed69f8 1d6c68 00  WA  0   0 32
  [26] .comment          PROGBITS        00000000 2ed69f8 00007f 01  MS  0   0  1
  [27] .note.gnu.gold-version NOTE            00000000 2ed6a78 00001c 00      0   0  4
  [28] .ARM.attributes   ARM_ATTRIBUTES  00000000 2ed6a94 00003c 00      0   0  1
  [29] .shstrtab         STRTAB          00000000 2ed6ad0 000136 00      0   0  1
Key to Flags:
  W (write), A (alloc), X (execute), M (merge), S (strings)
  I (info), L (link order), G (group), T (TLS), E (exclude), x (unknown)
  O (extra OS processing required) o (OS specific), p (processor specific)

If I set symbol_level = 1, the file is:

$ du -h libchrome.so
47M    libchrome.so

$ readelf -WS libchrome.so
There are 28 section headers, starting at offset 0x2ed6bf0:

Section Headers:
  [Nr] Name              Type            Addr     Off    Size   ES Flg Lk Inf Al
  [ 0]                   NULL            00000000 000000 000000 00      0   0  0
  [ 1] .interp           PROGBITS        00000154 000154 000013 00   A  0   0  1
  [ 2] .note.gnu.build-id NOTE            00000168 000168 000024 00   A  0   0  4
  [ 3] .dynsym           DYNSYM          0000018c 00018c 001960 10   A  4   1  4
  [ 4] .dynstr           STRTAB          00001aec 001aec 000fb9 00   A  0   0  1
  [ 5] .hash             HASH            00002aa8 002aa8 000a7c 04   A  3   0  4
  [ 6] .gnu.version      VERSYM          00003524 003524 00032c 02   A  3   0  2
  [ 7] .gnu.version_d    VERDEF          00003850 003850 00001c 00   A  4   1  4
  [ 8] .gnu.version_r    VERNEED         0000386c 00386c 000060 00   A  4   3  4
  [ 9] .rel.dyn          REL             000038cc 0038cc 28b1d0 08   A  3   0  4
  [10] .rel.plt          REL             0028ea9c 28ea9c 000b00 08  AI  3  11  4
  [11] .plt              PROGBITS        0028f59c 28f59c 001094 00  AX  0   0  4
  [12] .text             PROGBITS        00290640 290640 22e0544 00  AX  0   0 64
  [13] .ARM.exidx        ARM_EXIDX       02570b84 2570b84 1753b8 08  AL 12   0  4
  [14] .ARM.extab        PROGBITS        026e5f3c 26e5f3c 02d308 00   A  0   0  4
  [15] .rodata           PROGBITS        02713300 2713300 5d8234 00   A  0   0 256
  [16] .data.rel.ro.local PROGBITS        02cec890 2ceb890 0c1a98 00  WA  0   0 16
  [17] .data.rel.ro      PROGBITS        02dae330 2dad330 1042c8 00  WA  0   0 16
  [18] .init_array       INIT_ARRAY      02eb25f8 2eb15f8 0000e4 00  WA  0   0  4
  [19] .fini_array       FINI_ARRAY      02eb26dc 2eb16dc 000008 00  WA  0   0  4
  [20] .dynamic          DYNAMIC         02eb26e4 2eb16e4 000130 08  WA  4   0  4
  [21] .got              PROGBITS        02eb2820 2eb1820 00b7e0 00  WA  0   0  4
  [22] .data             PROGBITS        02ebe000 2ebd000 0199f8 00  WA  0   0 32
  [23] .bss              NOBITS          02ed7a00 2ed69f8 1d6c68 00  WA  0   0 32
  [24] .comment          PROGBITS        00000000 2ed69f8 00007f 01  MS  0   0  1
  [25] .note.gnu.gold-version NOTE            00000000 2ed6a78 00001c 00      0   0  4
  [26] .ARM.attributes   ARM_ATTRIBUTES  00000000 2ed6a94 00003c 00      0   0  1
  [27] .shstrtab         STRTAB          00000000 2ed6ad0 00011e 00      0   0  1
Key to Flags:
  W (write), A (alloc), X (execute), M (merge), S (strings)
  I (info), L (link order), G (group), T (TLS), E (exclude), x (unknown)
  O (extra OS processing required) o (OS specific), p (processor specific)


在 2017年3月15日星期三 UTC+8下午7:31:24,Primiano Tucci写道:

Primiano Tucci

unread,
Mar 16, 2017, 6:20:09 AM3/16/17
to kuo...@gmail.com, Chromium-dev
Ok, I have been a bit misleading in my previous email. 26 MB is the size in the apk after compression. The actual size for an official APK is 43 MB (I just checked 59.0.3042.3).
Can't immediately tell why your .so is 4 MB off. One thing that bumps to my attention is that your .rel.dyn section is 2.6 MB while the official one is 335 KB.
Are you really sure you are using is_official_build=true? Are you by any chance using another toolchain?
This is how an official .so looks like:
$ greadelf -WS libchrome.so
There are 28 section headers, starting at offset 0x2b3cc18:

Section Headers:
  [Nr] Name              Type            Addr     Off    Size   ES Flg Lk Inf Al
  [ 0]                   NULL            00000000 000000 000000 00      0   0  0
  [ 1] .interp           PROGBITS        00236154 000154 000013 00   A  0   0  1
  [ 2] .note.gnu.build-id NOTE            00236168 000168 000024 00   A  0   0  4
  [ 3] .dynsym           DYNSYM          0023618c 00018c 001960 10   A  4   1  4
  [ 4] .dynstr           STRTAB          00237aec 001aec 000fb9 00   A  0   0  1
  [ 5] .hash             HASH            00238aa8 002aa8 000a7c 04   A  3   0  4
  [ 6] .gnu.version      VERSYM          00239524 003524 00032c 02   A  3   0  2
  [ 7] .gnu.version_d    VERDEF          00239850 003850 00001c 00   A  4   1  4
  [ 8] .gnu.version_r    VERNEED         0023986c 00386c 000060 00   A  4   3  4
  [ 9] .rel.dyn          LOOS+0x1        002398cc 0038cc 053c58 01   A  3   0  4
  [10] .rel.plt          REL             0028d524 057524 000b00 08  AI  3  11  4
  [11] .plt              PROGBITS        0028e024 058024 001094 00  AX  0   0  4
  [12] .text             PROGBITS        0028f0c0 0590c0 2316ee8 00  AX  0   0 64
  [13] .rodata           PROGBITS        025a6000 2370000 5dde74 00   A  0   0 256
  [14] .ARM.exidx        ARM_EXIDX       02b83e74 294de74 001b30 08  AL 12   0  4
  [15] .ARM.extab        PROGBITS        02b859a4 294f9a4 0036a4 00   A  0   0  4
  [16] .data.rel.ro.local PROGBITS        02b8a2a0 29532a0 0c0278 00  WA  0   0 16
  [17] .data.rel.ro      PROGBITS        02c4a520 2a13520 104098 00  WA  0   0 16
  [18] .init_array       INIT_ARRAY      02d4e5b8 2b175b8 0000e8 00  WA  0   0  4
  [19] .fini_array       FINI_ARRAY      02d4e6a0 2b176a0 000008 00  WA  0   0  4
  [20] .dynamic          DYNAMIC         02d4e6a8 2b176a8 000130 08  WA  4   0  4
  [21] .got              PROGBITS        02d4e7e0 2b177e0 00b820 00  WA  0   0  4
  [22] .data             PROGBITS        02d5a000 2b23000 019a20 00  WA  0   0 32
  [23] .bss              NOBITS          02d73a20 2b3ca20 1d6d08 00  WA  0   0 32
  [24] .comment          PROGBITS        00000000 2b3ca20 00007f 01  MS  0   0  1
  [25] .note.gnu.gold-version NOTE            00000000 2b3caa0 00001c 00      0   0  4
  [26] .ARM.attributes   ARM_ATTRIBUTES  00000000 2b3cabc 00003c 00      0   0  1
  [27] .shstrtab         STRTAB          00000000 2b3caf8 00011e 00      0   0  1

--
--
Chromium Developers mailing list: chromi...@chromium.org
View archives, change email options, or unsubscribe:
http://groups.google.com/a/chromium.org/group/chromium-dev
---
You received this message because you are subscribed to the Google Groups "Chromium-dev" group.

Torne (Richard Coles)

unread,
Mar 16, 2017, 8:55:08 AM3/16/17
to prim...@chromium.org, kuo...@gmail.com, Chromium-dev
You can drop some more size by setting exclude_unwind_tables=true at the cost of debuggerd no longer being able to produce useful stack backtraces at all. Chrome-branded builds use this because we use breakpad to collect crash info instead.

Reply all
Reply to author
Forward
0 new messages