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

remove explicit API guards from bionic #2058

Closed
DanAlbert opened this issue Aug 21, 2024 · 3 comments
Closed

remove explicit API guards from bionic #2058

DanAlbert opened this issue Aug 21, 2024 · 3 comments
Assignees

Comments

@DanAlbert
Copy link
Member

Description

WEAK_API_DEFS doesn't work for anything in libc because we've got a tool that adds explicit API guards wherever there's an __INTRODUCED_IN (but only in bionic). That was a workaround we needed back when we supported GCC and could rely on __attribute__((availability)) everywhere, but that's long gone.

https://r.android.com/3236544 removes that. Can see from the one explicit guard I put back that there is potential for source compat break here. I'm planning to add explicit guards back wherever they're need to keep from breaking common 3p libraries, but there's no way to find those proactively.

The extremely conservative approach that wouldn't risk any source compat breaks but would still let us remove the tool that's supporting this (so still reduces our maintenance costs, but unfortunately would give up the advantage of making WEAK_API_DEFS work everywhere) would be to check in the preprocessed headers with the explicit guards. That can be the last resort, but it'd be much better if WEAK_API_DEFS can also benefit from this.

I'm feeling ambitious today so aiming for r28, but if the change doesn't land in time for beta 1 it'll get pushed to r29.

@DanAlbert DanAlbert self-assigned this Aug 21, 2024
@github-project-automation github-project-automation bot moved this to Unconfirmed in NDK r28 Aug 21, 2024
@licy183
Copy link

licy183 commented Aug 22, 2024

Should API guards be added to some structs?

gnulib checks whether the struct timezone_t is declared and determines whether to use mktime_z and its friends provided by GNU. If API Level < 35, NDK declares the timezone_t but doesn't declare mktime_z, and compilation failure will occur.

@enh-google
Copy link
Collaborator

Should API guards be added to some structs?

we'll probably have to do some, yes.

gnulib checks whether the struct timezone_t is declared and determines whether to use mktime_z and its friends provided by GNU. If API Level < 35, NDK declares the timezone_t but doesn't declare mktime_z, and compilation failure will occur.

if you work on gnulib, "please fix your configure file to check for the functions you want, rather than making potentially invalid assumptions like this" ... if you don't, yeah, this is the kind of thing we'll want to work around in the short term (but probably still file bugs with the libraries that have broken assumptions like this).

@DanAlbert
Copy link
Member Author

Yes, please fix those problems if you're able. If we hide structs or constants in the NDK it's a hack to keep those projects building that prevents other projects from using those types.

@github-project-automation github-project-automation bot moved this from Unconfirmed to Merged in NDK r28 Aug 23, 2024
jrguzman-ms pushed a commit to msft-mirror-aosp/platform.prebuilts.ndk that referenced this issue Aug 29, 2024
Test: ndk/checkbuild.py && ndk/run_tests.py
Bug: android/ndk#2058
Change-Id: Ie726e052618284c76c865bb1fce90ea6450c5a25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Merged
Development

No branches or pull requests

3 participants