Repository navigation
aosp: Support devices older than Android 9 - #13108
Conversation
The AOSP starboard toolchains targeted NDK API level 28 so that aligned_alloc() would link, which made the native libraries fail to load on anything older than Android 9. Build for Cobalt's default API level 24 again and add posix_emu polyfills for the functions bionic gained later, each compiled only while the NDK level is below the function's: aligned_alloc() and getrandom(). The existing pthread_getname_np() polyfill, which only handled the calling thread, is re-enabled and fixed to work for every thread. The -Wunguarded-availability pragmas stay: in the NDK's weak-symbol mode the bionic declaration and its API level are always visible, so a polyfill does not silence the check. Bug: 569900934 Bug: 374300500
🤖 Gemini Suggested Commit Message💡 Pro Tips for a Better Commit Message:
|
|
There was a problem hiding this comment.
Code Review
This pull request re-enables and expands POSIX emulation/polyfills for Android (specifically targeting APIs < 26 and < 28). It adds a robust pthread_getname_np implementation that reads from /proc/self/task/<tid>/comm for non-current threads, introduces a getrandom polyfill using system calls, and provides an aligned_alloc polyfill using memalign. It also updates toolchain configurations and ABI wrappers to support these changes on older Android API levels. Feedback focuses on improving the correctness and POSIX compliance of the polyfills. Specifically, the aligned_alloc polyfill should validate that the alignment is a non-zero power of two and that the size is a multiple of the alignment to match native Bionic behavior. Additionally, the pthread_getname_np polyfill should map ENOENT to ESRCH when the target thread's proc directory does not exist.
…oid 9 Refer to original PR: #13108 The AOSP starboard toolchains targeted NDK API level 28 so that aligned_alloc() would link, which made the native libraries fail to load on anything older than Android 9. Build for Cobalt's default API level 24 again and add posix_emu polyfills for the functions bionic gained later, each compiled only while the NDK level is below the function's: aligned_alloc() and getrandom(). The existing pthread_getname_np() polyfill, which only handled the calling thread, is re-enabled and fixed to work for every thread. The -Wunguarded-availability pragmas stay: in the NDK's weak-symbol mode the bionic declaration and its API level are always visible, so a polyfill does not silence the check. Bug: 569900934 Bug: 374300500 (cherry picked from commit 4fdb36a)
…droid 9 (#13210) Automated cherry-pick roll to staging. Original pull requests: - #13108 CONFLICTED files: ``` starboard/aosp/arm/toolchain/BUILD.gn starboard/aosp/arm64/toolchain/BUILD.gn ``` To merge these changes, run the autoroll script: ```bash GITHUB_REPOSITORY=youtube/cobalt python3 cobalt/devinfra/github/autoroll/merge_autoroll.py \ --source-branch main \ --target-branch staging ```⚠️ This PR has conflicts that must be resolved manually (don't forget to update the `.github/AUTOROLL` file). Use the following commands to checkout the branch locally and resolve the conflicts in a separate commit: ```bash gh pr checkout <pull_request_number> -R youtube/cobalt # Resolve conflicts and update .github/AUTOROLL then git add <resolved_files> # Copy CONFLICTED commit's message and metadata # Replace CONFLICTED in title with RESOLVED git commit -c <conflicted_sha> git push origin autoroll-main-to-staging ``` --------- Co-authored-by: Henrique Ferreiro <hferreiro@igalia.com>
Refer to original PR: #13108 The AOSP starboard toolchains targeted NDK API level 28 so that aligned_alloc() would link, which made the native libraries fail to load on anything older than Android 9. Build for Cobalt's default API level 24 again and add posix_emu polyfills for the functions bionic gained later, each compiled only while the NDK level is below the function's: aligned_alloc() and getrandom(). The existing pthread_getname_np() polyfill, which only handled the calling thread, is re-enabled and fixed to work for every thread. The -Wunguarded-availability pragmas stay: in the NDK's weak-symbol mode the bionic declaration and its API level are always visible, so a polyfill does not silence the check. Bug: 569900934 Bug: 374300500 (cherry picked from commit 4fdb36a)
Refer to original PR: #13108 The AOSP starboard toolchains targeted NDK API level 28 so that aligned_alloc() would link, which made the native libraries fail to load on anything older than Android 9. Build for Cobalt's default API level 24 again and add posix_emu polyfills for the functions bionic gained later, each compiled only while the NDK level is below the function's: aligned_alloc() and getrandom(). The existing pthread_getname_np() polyfill, which only handled the calling thread, is re-enabled and fixed to work for every thread. The -Wunguarded-availability pragmas stay: in the NDK's weak-symbol mode the bionic declaration and its API level are always visible, so a polyfill does not silence the check. Bug: 569900934 Bug: 374300500 (cherry picked from commit 4fdb36a)
The AOSP starboard toolchains targeted NDK API level 28 so that aligned_alloc() would link, which made the native libraries fail to load on anything older than Android 9.
Build for Cobalt's default API level 24 again and add posix_emu polyfills for the functions bionic gained later, each compiled only while the NDK level is below the function's: aligned_alloc() and getrandom(). The existing pthread_getname_np() polyfill, which only handled the calling thread, is re-enabled and fixed to work for every thread.
The -Wunguarded-availability pragmas stay: in the NDK's weak-symbol mode the bionic declaration and its API level are always visible, so a polyfill does not silence the check.
Bug: 569900934
Bug: 374300500