android / android/ndk

document that libc.a can only be used when __ANDROID_API__ is the latest API level (but that does not affect compatibility, because -static)

Open
#1,600 4 comments 0 reactions 0 assignees View on GitHub
docs
Dominant language
No language data
Stars
2.3k
Forks
310
PR merge metrics
No merged PRs in 30d

Description

bash can be successfully built with ndk r21, but can not be built with ndk r22-r23 due to following error:

```
ld: error: duplicate symbol: strchrnul
>>> defined at strchrnul.c
>>> strchrnul.o:(strchrnul) in archive ./lib/sh/libsh.a
>>> defined at static_function_dispatch.S:39 (bionic/libc/arch-arm64/static_function_dispatch.S:39)
>>> static_function_dispatch.o:(.text+0x30) in archive /home/kubast2/Android/Sdk/ndk/22.1.7171670/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/lib/aarch64-linux-android/21/libc.a
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [Makefile:582: bash] Error 1
```

from the error log, the `strchrnul` function exists in android-21's `libc.a`, but actually it was introduced in android-24

```
#if __ANDROID_API__ >= 24
char* strchrnul(const char* __s, int __ch) __attribute_pure__ __INTRODUCED_IN(24);
#endif /* __ANDROID_API__ >= 24 */
```

Contributor guide

Open the contributing guide

Research direction

Start by reviewing the reported bash build failure with NDK r22-r23 and the referenced android-21 libc.a and static_function_dispatch.S paths. Document that libc.a is usable only with the latest __ANDROID_API__ level, and explain why static linking does not affect compatibility; done when the behavior and version range are clear to NDK users.

Written by the indexing model from the issue text.

Assessment

Tech stack
bash
Domain
documentation
Issue type
Documentation
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.