Building for android, getting error compiling SDL_wave.c Edit: errors on other steps randomly

The build output is shown below.
Compiles and runs fine if I build it for mac.
(I’m on OSX El Capitan, 10.11.6)

I can give whatever other specs might help, but honestly I’m at a bit of a loss in coming up with what would be relevant…

Is this a bug in llvm?

Edit: if I try multiple times, it errors on different steps… I have the output for it failing on

[armeabi] Compile thumb  : SDL2 <= SDL_syshaptic.c
fatal error: error in backend: Cannot select: 0x7fb91418edc0: i32 = ARMISD::SSAT 

as well as

[armeabi] Compile thumb  : SDL2 <= SDL_sysjoystick.c
fatal error: error in backend: Cannot select: 0x7fc2a4112fc0: i32 = ARMISD::SSAT 

So, now I’m even more unsure what could possibly be happening…

android-project $ ndk-build
Android NDK: WARNING: APP_PLATFORM android-23 is larger than android:minSdkVersion 10 in ./AndroidManifest.xml    
[armeabi] Compile thumb  : SDL2 <= SDL.c
[armeabi] Compile thumb  : SDL2 <= SDL_assert.c
[armeabi] Compile thumb  : SDL2 <= SDL_error.c
[armeabi] Compile thumb  : SDL2 <= SDL_hints.c
[armeabi] Compile thumb  : SDL2 <= SDL_log.c
[armeabi] Compile thumb  : SDL2 <= SDL_audio.c
[armeabi] Compile thumb  : SDL2 <= SDL_audiocvt.c
[armeabi] Compile thumb  : SDL2 <= SDL_audiodev.c
[armeabi] Compile thumb  : SDL2 <= SDL_audiotypecvt.c
[armeabi] Compile thumb  : SDL2 <= SDL_mixer.c
[armeabi] Compile thumb  : SDL2 <= SDL_wave.c
fatal error: error in backend: Cannot select: 0x7fb0c18dbdc0: i32 = ARMISD::SSAT 0x7fb0c08ad880, Constant:i32<15>
  0x7fb0c08ad880: i32 = add 0x7fb0c08ada40, 0x7fb0c18dbc00
0x7fb0c08ada40: i32 = sra 0x7fb0c18dbff0, Constant:i32<8>
  0x7fb0c18dbff0: i32 = add 0x7fb0c08ace00, 0x7fb0c08ad260
    0x7fb0c08ace00: i32 = add 0x7fb0c08b0f10, 0x7fb0c18dc4c0
      0x7fb0c08b0f10: i32 = mul 0x7fb0c08adb20, 0x7fb0c08b1300
        0x7fb0c08adb20: i32,ch = load<LD2[%15](tbaa=<0x7fb0c0514eb8>), sext from i16> 0x7fb0c0527480, 0x7fb0c08adce0, undef:i32
          0x7fb0c08adce0: i32 = add 0x7fb0c08ad9d0, Constant:i32<2>
            0x7fb0c08ad9d0: i32,ch = CopyFromReg 0x7fb0c0527480, Register:i32 %vreg2
              0x7fb0c08b1760: i32 = Register %vreg2
            0x7fb0c08ace70: i32 = Constant<2>
          0x7fb0c08ad3b0: i32 = undef
        0x7fb0c08b1300: i32,ch = load<LD2[%12](tbaa=<0x7fb0c061a6f8>), sext from i16> 0x7fb0c0527480, 0x7fb0c08ad730, undef:i32
          0x7fb0c08ad730: i32 = add 0x7fb0c08ad570, Constant:i32<6>
            0x7fb0c08ad570: i32,ch = CopyFromReg 0x7fb0c0527480, Register:i32 %vreg0
              0x7fb0c18dc290: i32 = Register %vreg0
            0x7fb0c08b18b0: i32 = Constant<6>
          0x7fb0c08ad3b0: i32 = undef
      0x7fb0c18dc4c0: i32 = mul 0x7fb0c08ad8f0, 0x7fb0c08b1610
        0x7fb0c08ad8f0: i32,ch = load<LD2[%2](tbaa=<0x7fb0c0514eb8>), sext from i16> 0x7fb0c0527480, 0x7fb0c08ad9d0, undef:i32
          0x7fb0c08ad9d0: i32,ch = CopyFromReg 0x7fb0c0527480, Register:i32 %vreg2
            0x7fb0c08b1760: i32 = Register %vreg2
          0x7fb0c08ad3b0: i32 = undef
        0x7fb0c08b1610: i32,ch = load<LD2[%6](tbaa=<0x7fb0c061a6f8>), sext from i16> 0x7fb0c0527480, 0x7fb0c08b1220, undef:i32
          0x7fb0c08b1220: i32 = add 0x7fb0c08ad570, Constant:i32<4>
            0x7fb0c08ad570: i32,ch = CopyFromReg 0x7fb0c0527480, Register:i32 %vreg0
              0x7fb0c18dc290: i32 = Register %vreg0
            0x7fb0c08b0dc0: i32 = Constant<4>
          0x7fb0c08ad3b0: i32 = undef
    0x7fb0c08ad260: i32 = srl 0x7fb0c08ad420, Constant:i32<24>
      0x7fb0c08ad420: i32 = sra 0x7fb0c08ace00, Constant:i32<31>
        0x7fb0c08ace00: i32 = add 0x7fb0c08b0f10, 0x7fb0c18dc4c0
          0x7fb0c08b0f10: i32 = mul 0x7fb0c08adb20, 0x7fb0c08b1300
            0x7fb0c08adb20: i32,ch = load<LD2[%15](tbaa=<0x7fb0c0514eb8>), sext from i16> 0x7fb0c0527480, 0x7fb0c08adce0, undef:i32
              0x7fb0c08adce0: i32 = add 0x7fb0c08ad9d0, Constant:i32<2>


              0x7fb0c08ad3b0: i32 = undef
            0x7fb0c08b1300: i32,ch = load<LD2[%12](tbaa=<0x7fb0c061a6f8>), sext from i16> 0x7fb0c0527480, 0x7fb0c08ad730, undef:i32
              0x7fb0c08ad730: i32 = add 0x7fb0c08ad570, Constant:i32<6>


              0x7fb0c08ad3b0: i32 = undef
          0x7fb0c18dc4c0: i32 = mul 0x7fb0c08ad8f0, 0x7fb0c08b1610
            0x7fb0c08ad8f0: i32,ch = load<LD2[%2](tbaa=<0x7fb0c0514eb8>), sext from i16> 0x7fb0c0527480, 0x7fb0c08ad9d0, undef:i32
              0x7fb0c08ad9d0: i32,ch = CopyFromReg 0x7fb0c0527480, Register:i32 %vreg2

              0x7fb0c08ad3b0: i32 = undef
            0x7fb0c08b1610: i32,ch = load<LD2[%6](tbaa=<0x7fb0c061a6f8>), sext from i16> 0x7fb0c0527480, 0x7fb0c08b1220, undef:i32
              0x7fb0c08b1220: i32 = add 0x7fb0c08ad570, Constant:i32<4>


              0x7fb0c08ad3b0: i32 = undef
        0x7fb0c18dbc70: i32 = Constant<31>
      0x7fb0c08b16f0: i32 = Constant<24>
  0x7fb0c08ad810: i32 = Constant<8>
0x7fb0c18dbc00: i32 = mul 0x7fb0c08ad340, 0x7fb0c18dc300
  0x7fb0c08ad340: i32,ch = load<LD2[%24](tbaa=<0x7fb0c061a6f8>), zext from i16> 0x7fb0c0527480, 0x7fb0c18dc1b0, undef:i32
    0x7fb0c18dc1b0: i32 = add 0x7fb0c08ad570, Constant:i32<2>
      0x7fb0c08ad570: i32,ch = CopyFromReg 0x7fb0c0527480, Register:i32 %vreg0
        0x7fb0c18dc290: i32 = Register %vreg0
      0x7fb0c08ace70: i32 = Constant<2>
    0x7fb0c08ad3b0: i32 = undef
  0x7fb0c18dc300: i32 = ARMISD::CMOV 0x7fb0c08b1530, 0x7fb0c08b1ae0, Constant:i32<0>, Register:i32 %CPSR, 0x7fb0c08acf50
    0x7fb0c08b1530: i32 = add 0x7fb0c08b1ae0, Constant:i32<-16>
      0x7fb0c08b1ae0: i32 = AssertZext 0x7fb0c08b1840, ValueType:ch:i8
        0x7fb0c08b1840: i32,ch = CopyFromReg 0x7fb0c0527480, Register:i32 %vreg1
          0x7fb0c08ad5e0: i32 = Register %vreg1
      0x7fb0c08ad110: i32 = Constant<-16>
    0x7fb0c08b1ae0: i32 = AssertZext 0x7fb0c08b1840, ValueType:ch:i8
      0x7fb0c08b1840: i32,ch = CopyFromReg 0x7fb0c0527480, Register:i32 %vreg1
        0x7fb0c08ad5e0: i32 = Register %vreg1
    0x7fb0c18dc140: i32 = Constant<0>
    0x7fb0c08ad0a0: i32 = Register %CPSR
    0x7fb0c08acf50: glue = ARMISD::CMPZ 0x7fb0c08b1450, Constant:i32<0>
      0x7fb0c08b1450: i32 = and 0x7fb0c08b1ae0, Constant:i32<8>
        0x7fb0c08b1ae0: i32 = AssertZext 0x7fb0c08b1840, ValueType:ch:i8
          0x7fb0c08b1840: i32,ch = CopyFromReg 0x7fb0c0527480, Register:i32 %vreg1
            0x7fb0c08ad5e0: i32 = Register %vreg1
        0x7fb0c08ad810: i32 = Constant<8>
      0x7fb0c18dc140: i32 = Constant<0>
  0x7fb0c08b10d0: i32 = Constant<15>
In function: MS_ADPCM_nibble
clang: error: clang frontend command failed with exit code 70 (use -v to see invocation)
Android clang version 3.8.275480  (based on LLVM 3.8.275480)
Target: armv5te-none-linux-android
Thread model: posix
InstalledDir: /usr/local/Cellar/android-ndk/r14/toolchains/llvm/prebuilt/darwin-x86_64/bin
clang: note: diagnostic msg: PLEASE submit a bug report to http://llvm.org/bugs/ and include the crash backtrace, preprocessed source, and associated run script.
clang: note: diagnostic msg: 
********************

PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:
Preprocessed source(s) and associated run script(s) are located at:
clang: note: diagnostic msg: /var/folders/g6/j2xtb5gn5vg_0cx52d35t1ww0000gn/T/SDL_wave-789ad4.c
clang: note: diagnostic msg: /var/folders/g6/j2xtb5gn5vg_0cx52d35t1ww0000gn/T/SDL_wave-789ad4.sh
clang: note: diagnostic msg: 

********************
make: *** [obj/local/armeabi/objs/SDL2/src/audio/SDL_wave.o] Error 70
android-project $

Yes, this is a bug in llvm. You can change the compiler to gcc until this is fixed by editing your Application.mk and adding the line:

NDK_TOOLCHAIN_VERSION := 4.9

2 Likes

Oh goodness thank you so much! Was going crazy trying to make sense of this while lacking deep compiler knowledge. Thanks!

1 Like

Do you happen to know how to fix this with Gradle when using CMake, like with the latest Android Studio projects?

I haven’t tried, but these docs https://developer.android.com/ndk/guides/cmake.html#variables suggest you can do:

externalNativeBuild {
      cmake {
            arguments "-DANDROID_TOOLCHAIN=gcc",

Download the latest NDK beta version it’s fixed in that (This is the issue: https://github.com/android-ndk/ndk/issues/361)

You can see my example project for a gradle example:

NDK r15 is out now too and fixes this issue.