Skip to content

Bundle a copy of libc++_shared.so instead of the NDK's own file - #9

Merged
zeyus merged 1 commit into
NexusDynamic:mainfrom
MSOB7YY:copy-libcpp-to-output
Oct 6, 2026
Merged

zeyus merged 1 commit into
NexusDynamic:mainfrom
MSOB7YY:copy-libcpp-to-output

Conversation

@MSOB7YY

@MSOB7YY MSOB7YY commented Oct 4, 2026

Copy link
Copy Markdown
Contributor

Problem

The hook emits the NDK's sysroot/usr/lib/<triple>/libc++_shared.so itself as the code asset file. Flutter's DartBuild target lists asset files as build outputs (dart_build.d), and its build system deletes stale outputs, e.g. trackSharedBuildDirectory when the build configuration changes (a different ABI set, or a failed build). That deletes libc++_shared.so from the NDK.

Anything linking -lc++_shared against that NDK then fails (ld.lld: error: unable to find library -lc++_shared), and this package falls back to an older NDK or fails.

This is the root cause of #5: NDK 28 ships aarch64-linux-android/libc++_shared.so, it was deleted by the build.

Fix

Copy the resolved library into input.outputDirectory and emit the copy. The source stays a dependency, so the hook still re-runs when it changes.

Tests

test/hook_test.dart runs the hook through testBuildHook, checks the asset lives in the output directory, and that deleting it leaves the source intact.

Branched from v0.2.1 (the hook is unchanged since, merges cleanly into main). Packages still on ^0.2.1 (e.g. mecab_for_dart) would benefit from a 0.2.2 release.

Credits

made by claude

The Flutter tool records code asset files as build outputs and deletes
stale ones, which removed libc++_shared.so from the NDK sysroot and broke
later builds linking with -lc++_shared.
@zeyus

zeyus commented Oct 6, 2026

Copy link
Copy Markdown
Member

Huh, weird that the build system deletes files out of the build directory. I don't see any harm in merging this to work around it but I feel like this is an upstream bug, adding shared libs should not make the build system think it owns them.

@zeyus
zeyus merged commit 75fff85 into NexusDynamic:main Oct 6, 2026
@MSOB7YY

MSOB7YY commented Oct 6, 2026

Copy link
Copy Markdown
Contributor Author

exactly it should be flutter issue, but no harm for a workaround here since upstream can take time to to fix and publish (sry i forgot to mention this)

thank u for ur work ^^

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants