Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

android: Enable tls_model("local_dynamic") for NDK-less builds on LLVM >= 17 #349

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

MarijnS95
Copy link

PR #347 fixed/removed using the "initial-exec" TLS model for Android which is no longer compatible since LLVM 17 where ELF TLS is enabled by default for API level 29.

It opted to instead enable "local-dynamic", but only if the minimum API level is 29 and the NDK is version 26 or higher, and otherwise doesn't define a TLS model at all. However, this did not consider simple build cases where e.g. clang --target aarch64-linux-android29 may be invoked without ever including an NDK header that sets __NDK_MAJOR__ 26 or higher (noting that LLVM 17 is used since r26): https://togithub.com/mjansson/rpmalloc/pull/347#discussion_r1912096361

Instead, check if the __clang_major__ define is 17 or higher, but also keep the original comparison in place just in case even if it's superfluous. Also remove unnecessary defined(XXX) checks, since the C specification clarifies that undefined tokens are replaced with 0 which aptly turn the >= into false.

…LVM >= 17

PR mjansson#347 fixed/removed using the `"initial-exec"` TLS model for Android
which is no longer compatible since LLVM 17 where ELF TLS is enabled by
default for API level 29.

It opted to instead enable `"local-dynamic"`, but only if the minimum
API level is 29 _and_ the NDK is version 26 or higher, and otherwise
doesn't define a TLS model at all.  However, this did not consider
simple build cases where e.g. `clang --target aarch64-linux-android29`
may be invoked without ever including an NDK header that sets
`__NDK_MAJOR__ 26` or higher (noting that LLVM 17 is used since r26):
https://togithub.com/mjansson/rpmalloc/pull/347#discussion_r1912096361

Instead, check if the `__clang_major__` define is `17` or higher, but
also keep the original comparison in place just in case even if it's
superfluous.  Also remove unnecessary `defined(XXX)` checks, since the C
specification clarifies that undefined tokens are replaced with `0`
which aptly turn the `>=` into `false`.
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.

1 participant