NDK best practices documentation
- Dominant language
- No language data
- Stars
- 2.3k
- Forks
- 310
- PR merge metrics
- No merged PRs in 30d
Description
https://github.com/android-ndk/ndk/issues/748#issuecomment-411862124 had this:
> I agree with the first suggestion to use the -f*-sections only for the static library.
>
> As for the defaults, I don't think -fdata-sections is universally useful. If a function refers to multiple global data, each global needs its own section start address. Without -fdata-sections, there'd just be a reference to the data section and two offsets into it. https://stackoverflow.com/a/29951897 has a more detailed explanation. However, the flag is useful or a wash for libc++ since it has few, if any, global data.
>
> So -ffunction-sections, while ensuring that --gc-sections is passed to the linker, seems like a good default.
>
> OTOH, I could also make the case for not setting either and leaving the user to consider the trade-offs and opt into whatever behavior they want. Granted there's greater potential benefit (in terms of size) with setting this flag and a smaller potential disadvantage (in terms of execution speed).
>
> I guess it all comes down to informed choice - if there's a best-practices guide for the NDK, this trade-off should be mentioned there.
we should probably have a best practices doc, and add stuff like this.
Contributor guide
Research direction
Start with the linked comment in issue #748 and its discussion of -ffunction-sections, -fdata-sections, and --gc-sections, then review the referenced Stack Overflow explanation. Define the scope of an NDK best-practices guide and document the trade-offs and informed choices described in the issue; done means the guide includes this topic and related best practices.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- documentation
- Issue type
- Documentation
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100