crtbegin_static is built with min_sdk_version: "current"

crtbegin_static is used by static exectuables which are guaranteed to be
with the latest library regardless of their target API level.

This change is in fact not a regression as crtbegin_static has been
built with __ANDROID_API__=10000 before
I645e6bb1234c27ae0a69b7b87a59206cfd350744 when __ANDROID_API__ tracked
sdk_version, not min_sdk_version. sdk_version was not set for crtbegin_*
objects and therefore the default "current" was (incorrectly) used.

With this change, we are recovering the original behavior for the static
variant, while the building of the dynamic variant becomes more correct
- it's now with __ANDROID_API__=16.

Without this change, several static executables fail to build as 1)
crtbegin_static for them is built with __ANDROID_API__=16 and 2)
libc_init_common.cpp uses pthread_atfork which is available only after
API level 23. We hit undefined symbol error when linking.

Bug: 134795810
Test: m

Change-Id: I1430e57302951df33530ea0ae91b0d7a0609bf3d
This commit is contained in:
Jiyong Park 2021-01-12 23:14:37 +09:00
parent bb19208d66
commit 268a60019d

View file

@ -2097,6 +2097,8 @@ cc_object {
local_include_dirs: ["include"],
srcs: ["arch-common/bionic/crtbegin.c"],
defaults: ["crt_defaults"],
// When using libc.a, we're using the latest library regardless of target API level.
min_sdk_version: "current",
}
cc_object {
@ -2107,6 +2109,8 @@ cc_object {
"crtbrand",
],
defaults: ["crt_defaults"],
// When using libc.a, we're using the latest library regardless of target API level.
min_sdk_version: "current",
}
cc_object {