Skip to content

NDK best practices documentation #768

@enh

Description

@enh

#748 (comment) 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions