android / android/ndk

[BUG] Awfully slow compilation of a source file with a big global array on 32-bit targets

Open
#1,418 7 comments 0 reactions 2 assignees Claimed by @pirama-arumuga-nainar View on GitHub
bug
Dominant language
No language data
Stars
2.3k
Forks
310
PR merge metrics
No merged PRs in 30d

Description

--------------------------------------------------------------------------------

#### Description

Clang++ compilation of one specific source file in my project is terribly slow for 32-bit architectures.
On my Core i7-3770K, compiling `aarch64` object file takes 13 seconds, but compiling `armv7a` object file takes **32 minutes**, which is 150 times slower.
I am using `-Oz` optimization, but the results are the same with `-O2`.

The problem seems to happen because of a big globally-initialized array, which has around 390 entries.
If I edit file `src/table/settings.h` and replace the array `const SettingDesc _settings[]` with an empty array, compilation takes 2 seconds on all targets. If I reduce array size to 100 items, compilation of `armv7a` target is reduced to 24 seconds.

To reproduce: unpack `slow-compile.zip`, launch script `slow-compile.sh`, it will report compilation speed using `time` command.
I have included the source file and all the headers it uses into the archive.

[slow-compile.zip](https://github.com/android/ndk/files/5758554/slow-compile.zip)

#### Environment Details

* NDK Version: 22.0.7026061
* Build system: Standalone toolchain
* Host OS: Linux Debian 10
* ABI: armv7a-linux-androideabi16 i686-linux-android16
* NDK API level: 16
* Device API level: 29

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.