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

Unable to build lime with android ndk r28 #1923

Open
tobil4sk opened this issue Mar 12, 2025 · 4 comments
Open

Unable to build lime with android ndk r28 #1923

tobil4sk opened this issue Mar 12, 2025 · 4 comments

Comments

@tobil4sk
Copy link
Member

Two of our dependencies fail to build with android ndk r28:

openal:

./lib/openal/al/event.cpp:189:9: warning: ignoring temporary created by a constructor declared with 'nodiscard' attribute [-Wunused-value]
  189 |         std::lock_guard<std::mutex>{context->mEventCbLock};
      |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 warning generated.
Error: ./lib/openal/common/almalloc.cpp:24:12: error: use of undeclared identifier 'aligned_alloc'
   24 |     return aligned_alloc(alignment, size);
      |            ^
1 error generated.

sdl:

Error: ./lib/sdl/src/sensor/android/SDL_androidsensor.c:174:9: error: 'ALooper_pollAll' is unavailable: obsoleted in Android 1 - ALooper_pollAll may ignore wakes. Use ALooper_pollOnce instead. See The API documentation for more information
  174 |     if (ALooper_pollAll(0, NULL, &events, (void**)&source) == LOOPER_ID_USER) {
      |         ^
/home/tobil/Dev/Android/SDK/ndk/r28/toolchains/llvm/prebuilt/linux-x86_64/bin/../sysroot/usr/include/android/looper.h:234:5: note: 'ALooper_pollAll' has been explicitly marked unavailable here
  234 | int ALooper_pollAll(int timeoutMillis, int* outFd, int* outEvents, void** outData)
      |     ^
1 error generated.
@tobil4sk
Copy link
Member Author

Note, these issues also happen with r27c, which is currently the oldest ndk version that's still in support: https://github.com/android/ndk/wiki#releases

@joshtynjala
Copy link
Member

We recently updated the 8.3.0-Dev branch to use SDL 2.30.12. I wonder if that version supports NDK r27 and r28? That was the newest SDL2 update at the time, but it looks like there may be a couple of newer SDL2 updates since then that we could try.

@dimensionscape
Copy link
Member

dimensionscape commented Mar 12, 2025

aligned_alloc is introduced in sdk 28, so make sure the minSdkVersion is set to 28.

The sdl issue is due to ALooper_pollAll being obsolete. ALooper_pollOnce should be used instead. Cursory glance at sdl 2.30 shows they made the change here: https://github.com/libsdl-org/SDL/blob/9464f334b5637649fed69680dbc90250c91111b3/src/sensor/android/SDL_androidsensor.c#L164

So we should be ok

dimensionscape added a commit that referenced this issue Mar 12, 2025
Should resolve part of the issues related here: #1923 (comment)
@tobil4sk
Copy link
Member Author

aligned_alloc is introduced in sdk 28, so make sure the minSdkVersion is set to 28.

For some reason, with any ndk >= 20, hxcpp seems to ignore the PLATFORM define and instead reads the PLATFORM_NUMBER, which is later used to set PLATFORM internally.

https://github.com/HaxeFoundation/hxcpp/blob/dd050c019a85f4a12c9955265c82ec0e3307466d/tools/hxcpp/Setup.hx#L516-L527

https://github.com/HaxeFoundation/hxcpp/blob/dd050c019a85f4a12c9955265c82ec0e3307466d/toolchain/android-toolchain-clang.xml#L6

https://github.com/HaxeFoundation/hxcpp/blob/dd050c019a85f4a12c9955265c82ec0e3307466d/toolchain/android-toolchain-clang.xml#L31

The hxcpp setup seems a bit messy, but either way, replacing PLATFORM=android-28 with PLATFORM_NUMBER=28 would do what lime needs.

With this flag set and with the 8.3.0-Dev branch for the newer sdl, I am able to build the ndll successfully, thanks!

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

No branches or pull requests

3 participants