We are currently migrating Bugzilla to GitHub issues.
Any changes made to the bug tracker now will be lost, so please do not post new bugs or make changes to them.
When we're done, all bug URLs will redirect to their equivalent location on the new bug tracker.

Bug 5036

Summary: Compile for Android using NDK r21 fails
Product: SDL Reporter: Ron Aaron <ron>
Component: buildAssignee: Sam Lantinga <slouken>
Status: WAITING --- QA Contact: Sam Lantinga <slouken>
Severity: blocker    
Priority: P2 CC: icculus
Version: 2.0.10   
Hardware: ARM   
OS: Android (All)   

Description Ron Aaron 2020-03-15 18:52:31 UTC
Compiling on macOS using the 'androidbuildlibs.sh' and NDK r21, the compiler gives:

armeabi-v7a] Compile thumb  : SDL2 <= SDL_hints.c
[armeabi-v7a] Compile thumb  : SDL2 <= SDL.c
In file included from ./src/SDL.c:37:
In file included from ./include/SDL.h:38:
In file included from ./include/SDL_cpuinfo.h:86:
In file included from /Users/ron/src/android-ndk-r21/toolchains/llvm/prebuilt/darwin-x86_64/lib64/clang/9.0.8/include/immintrin.h:14:
/Users/ron/src/android-ndk-r21/toolchains/llvm/prebuilt/darwin-x86_64/lib64/clang/9.0.8/include/mmintrin.h:50:12: error: invalid conversion between vector type
      '__m64' (vector of 1 'long long' value) and integer type 'int' of different size
    return (__m64)__builtin_ia32_vec_init_v2si(__i, 0);
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/ron/src/android-ndk-r21/toolchains/llvm/prebuilt/darwin-x86_64/lib64/clang/9.0.8/include/mmintrin.h:129:12: error: invalid conversion between vector
      type '__m64' (vector of 1 'long long' value) and integer type 'int' of different size
    return (__m64)__builtin_ia32_packsswb((__v4hi)__m1, (__v4hi)__m2);

etc...
Comment 1 Ron Aaron 2020-03-15 18:56:12 UTC
It does compile with NDK r21 on Linux.
Comment 2 Sam Lantinga 2020-03-16 19:33:20 UTC
I'm not seeing that either...?
stream-mac:SDL valve$ export PATH=$HOME/android/android-ndk-r21:$PATH
stream-mac:SDL valve$ ./build-scripts/androidbuildlibs.sh 
[armeabi-v7a] Compile thumb  : SDL2 <= SDL_hints.c
[armeabi-v7a] Compile thumb  : SDL2 <= SDL.c
[armeabi-v7a] Compile thumb  : SDL2 <= SDL_dataqueue.c
[armeabi-v7a] Compile thumb  : SDL2 <= SDL_assert.c
[armeabi-v7a] Compile thumb  : SDL2 <= SDL_log.c
Comment 3 Ron Aaron 2020-03-17 04:47:33 UTC
Strange. Perhaps it's to do with the XCode or OS version? Unlikely I would think, since the NDK is its own thing.

For reference, I'm on macOS 10.14.6 (Mojave), and XCode 11.3.1
Comment 4 Ryan C. Gordon 2020-03-20 20:38:33 UTC
Any chance you've run the configure or CMake scripts in this source tree on macOS, so it overwrote SDL_config.h with something macOS-specific?

(or it picked up SDL_config.h from an installed copy in /usr/local or something?)

This is trying to include the header for MMX support (mmintrin.h) which shouldn't happen on ARM Android, and SDL_cpuinfo.h decides to include that header based on something we'll set in SDL_config.h.

--ryan.