android / ndk

The Android Native Development Kit
1.98k stars 257 forks source link

[BUG] NDK r28 beta1: issues with existing polyfills #2081

Open dg0yt opened 1 week ago

dg0yt commented 1 week ago

Description

This is in response to the r28 beta1 release notes.

If your project contains polyfills for any of those APIs, this change may break your build due to the conflicting declarations. The simplest fix is to rename your polyfill to not collide with libc. For example, rename conflicting_api to conflicting_api_fallback and call that instead. Use

define conflicting_api() conflicting_api_fallback() if you want to avoid

rewriting callsites.

Please open a bug if you run into issues with existing polyfills. We may be able to add the polyfill directly to the NDK.

A test build in vcpkg CI (which uses android 21) shows a lot of breakage related to __INTRODUCED_IN() with polyfills from gnulib. There is no full picture yet because the build error cascade starts early. The first hit is mempcpy in GNU libiconv. I added a patch to rename the polyfill, but the next failures is already gettext-libintl.

In the non-gnulib group, openssl is affected, removing many ports from the build. For poppler, I assume that GNU libiconv used to be the polyfill, but I didn't verify that. "libiconv as a polyfill" might be a broader pattern.

I grepped the arm64 logs for __INTRODUCED_IN. Transformed and compressed:

gettext-libintl 'feof_unlocked' is unavailable: introduced in Android 23
gettext-libintl 'fgets_unlocked' is unavailable: introduced in Android 28
gettext-libintl 'mblen' is unavailable: introduced in Android 26
gettext-libintl 'mempcpy' is unavailable: introduced in Android 23
gettext-libintl 'nl_langinfo' is unavailable: introduced in Android 26
gsasl 'error_at_line' is unavailable: introduced in Android 23
gsasl 'error' is unavailable: introduced in Android 23
gsasl 'error_message_count' is unavailable: introduced in Android 23
gsasl 'error_print_progname' is unavailable: introduced in Android 23
gsasl 'fflush_unlocked' is unavailable: introduced in Android 28
gsasl 'fputs_unlocked' is unavailable: introduced in Android 28
gsasl '__freading' is unavailable: introduced in Android 28
gsasl '__fsetlocking' is unavailable: introduced in Android 23
gsasl 'getrandom' is unavailable: introduced in Android 28
gsasl 'iconv_close' is unavailable: introduced in Android 28
gsasl 'iconv' is unavailable: introduced in Android 28
gsasl 'iconv_open' is unavailable: introduced in Android 28
gsasl 'mblen' is unavailable: introduced in Android 26
gsasl 'nl_langinfo' is unavailable: introduced in Android 26
libconfuse 'fmemopen' is unavailable: introduced in Android 23
libidn2 'error_at_line' is unavailable: introduced in Android 23
libidn2 'error' is unavailable: introduced in Android 23
libidn2 'error_message_count' is unavailable: introduced in Android 23
libidn2 'error_print_progname' is unavailable: introduced in Android 23
libidn2 'nl_langinfo' is unavailable: introduced in Android 26
libidn2 'strchrnul' is unavailable: introduced in Android 24
liblsl 'pthread_getname_np' is unavailable: introduced in Android 26
libuv 'freeifaddrs' is unavailable: introduced in Android 24
libuv 'getifaddrs' is unavailable: introduced in Android 24
libuv 'preadv' is unavailable: introduced in Android 24
libuv 'pthread_barrier_destroy' is unavailable: introduced in Android 24
libuv 'pthread_barrier_init' is unavailable: introduced in Android 24
libuv 'pthread_barrier_wait' is unavailable: introduced in Android 24
libuv 'pwritev' is unavailable: introduced in Android 24
openssl 'getentropy' is unavailable: introduced in Android 28
poppler 'iconv_close' is unavailable: introduced in Android 28
poppler 'iconv' is unavailable: introduced in Android 28
poppler 'iconv_open' is unavailable: introduced in Android 28

Patching gnutext-libintl would probably add many more. (All those packages build with NDK r26. NDK r27 is still blocked by its bugs.)

Affected versions

r28

Canary version

beta1

Host OS

Linux

Host OS version

vcpkg CI image

Affected ABIs

arm64-v8a

Build system

Other (specify below)

Other build system

No response

minSdkVersion

21

Device API level

No response

dg0yt commented 1 week ago

In gettext libintl, the mempcpy related errors also include:

[..]gettext-runtime/intl/dcigettext.c:1723:1: error: static declaration of 'mempcpy' follows non-static declaration
DanAlbert commented 1 week ago

Ooh, if vcpkg's CI has issues that gives us a great place to go look at the scope of the problem. Thanks! I should remember to try that whenever I'm making ambitious changes in the future.

We'll have a look and see what can be done. My gut says that we'll re-hide the stuff that's causing problems for r28 and work on upstreaming fixes. If it were a shorter list of projects I'd say we should just fix those projects and ship r28 as-is, but if it's hit a non-trivial number of projects just in vcpkg, that's a lot of patches to upstream, and a lot of package updates that developers would need to take to get those fixes.

A complete rollback is an option, but it's sort of the last resort. For the reasons mentioned in the changelog, this is a step in the right direction that we want to take, so I'd like to see us make progress wherever we can do so safely. I'm okay with gradual progress though, so if we need to re-hide the stuff that's broadly polyfilled already we can do that to avoid breaks while we fix the various open source projects to be compatible with the change.