Skip to content

Flutter's Android tools ignore NDK symlinks and copy files instead, leading to huge disk usage #177286

@bc-lee

Description

@bc-lee

While investigating disk space shortages, I discovered that Flutter’s Android tools package includes a large NDK copy where all symlinks have been resolved into actual files.

Normal NDK from the official Android site:

[/path/to/ndk/28.2.13676358/toolchains/llvm/prebuilt/linux-x86_64/bin]$ ls -al | grep ^l
lrwxrwxrwx.  1 user user         8 Jul 27 07:59 clang -> clang-19
lrwxrwxrwx.  1 user user         5 Jul 27 07:59 clang++ -> clang
lrwxrwxrwx.  1 user user         6 Jul 27 07:59 ld -> ld.lld
lrwxrwxrwx.  1 user user         3 Jul 27 07:59 ld64.lld -> lld
lrwxrwxrwx.  1 user user         3 Jul 27 07:59 ld.lld -> lld
lrwxrwxrwx.  1 user user         3 Jul 27 07:59 lld-link -> lld
lrwxrwxrwx.  1 user user        15 Jul 27 07:59 llvm-addr2line -> llvm-symbolizer
lrwxrwxrwx.  1 user user         7 Jul 27 07:59 llvm-dlltool -> llvm-ar
lrwxrwxrwx.  1 user user         7 Jul 27 07:59 llvm-lib -> llvm-ar
lrwxrwxrwx.  1 user user         7 Jul 27 07:59 llvm-ranlib -> llvm-ar
lrwxrwxrwx.  1 user user        12 Jul 27 07:59 llvm-readelf -> llvm-readobj
lrwxrwxrwx.  1 user user        12 Jul 27 07:59 llvm-strip -> llvm-objcopy
lrwxrwxrwx.  1 user user         7 Jul 27 07:59 llvm-windres -> llvm-rc
lrwxrwxrwx.  1 user user         3 Jul 27 07:59 wasm-ld -> lld

NDK bundled with Flutter’s Android tools:

[/path/to/flutter/engine/src/flutter/third_party/android_tools/ndk/toolchains/llvm/prebuilt/linux-x86_64/bin]$ ls -al | grep ^l
[/path/to/flutter/engine/src/flutter/third_party/android_tools/ndk/toolchains/llvm/prebuilt/linux-x86_64/bin]$ ls -al clang*
-r-xr-xr-x. 1 user user 135276024 Oct  2 04:29 clang
-r-xr-xr-x. 1 user user 135276024 Oct  2 04:29 clang++
-r-xr-xr-x. 1 user user 135276024 Oct  2 04:29 clang-19
-r-xr-xr-x. 1 user user  75759408 Oct  2 04:29 clang-check
-r-xr-xr-x. 1 user user  44910272 Oct  2 04:29 clangd
-r-xr-xr-x. 1 user user   3817168 Oct  2 04:29 clang-format
-r-xr-xr-x. 1 user user  75664920 Oct  2 04:29 clang-scan-deps
-r-xr-xr-x. 1 user user  53089504 Oct  2 04:29 clang-tidy

As shown above, clang, clang++, and clang-19 are all separate files of ~135 MB each.
In the official NDK, they are symlinks to the same file.

This means Flutter’s Android tools are effectively duplicating large binaries, inflating the NDK’s size by hundreds (if not thousands) of megabytes.

Expected behavior

NDK binaries in Flutter’s Android tools should preserve symlinks instead of copying file contents.
This would significantly reduce disk usage and improve developer experience.

Environment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Important issues not at the top of the work listfyi-infraFor the attention of Infrastructure teamplatform-androidAndroid applications specificallyr: fixedIssue is closed as already fixed in a newer versionteam-androidOwned by Android platform teamtoolAffects the "flutter" command-line tool. See also t: labels.triaged-androidTriaged by Android platform team

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions