I cannot vouch for our current system as I did not design it. I maintained the prior build system, which had Gradle invoking CMake. The pure-CMake setup is new. It's possible Gradle read AndroidManifest.xml, saw the minSdkVersion there, and translated that into a CMake define...
Conversation
If this is the case, then this simply means that our new non-Gradle setup would need to have the human specify those AndroidManifest.xml-related defines by hand. But I'm not clear who they should be defined to (to CMake? To toolchain.cmake? To clang?)
1
It does seem real suspicious that -DFORTIFY_SOURCE=2 is being set but ONLY on the .c files that are building wrong, and I have literally no idea where that -D came from because we didn't tell it to do that.
1
You definitely need -D__ANDROID_API__=21 in CPPFLAGS to match your minSdkVersion 21. It's broken overall, but you only happen to be seeing it when _FORTIFY_SOURCE is used because _FORTIFY_SOURCE will automatically use the new symbols introduced for newly fortified functions.
1
1
If you run `CPPFLAGS=-D__ANDROID_API__=21 cmake` instead of `cmake`, that may work properly.
I don't understand why it would ever be not enabling _FORTIFY_SOURCE=2 by default unless it's building those files without optimization. It's generally passed by default everywhere.
2
As an interesting fact, I am (as noted I am getting used to a new version of the build process) not sure if I am building debug or release. Possibly I am building both at once, or neither.
1
It *sounds* like it might be optimizing some files (where it would pass -D_FORTIFY_SOURCE=2 by default) and not others. The _FORTIFY_SOURCE thing is just what let you know it's broken though. Real issue is not having minSdkVersion set for C and C++ so it's defaulting to 30+.
1
Okay so check this out, if I manually set the __ANDROID_API__ it says I defined it twice. Could --target=aarch64-none-linux-android26 be doing something magic?
1
You probably just need to set --target=aarch64-none-linux-android21 rather than --target=aarch64-none-linux-android26. It's the minSdkVersion that needs to be set at compile time for __ANDROID_API__ rather than the targetSdkVersion which is checked at runtime.
1
Since your code needs to link properly in an Android API 21 environment since minSdkVersion is 21. Stuff that varies based on targetSdkVersion has to be handled at runtime.
So, I believe what is controlling this is -D ANDROID_NATIVE_API_LEVEL=26 , which is being passed to CMake (not clang) and is most likely being interpreted by the CMake toolchain file (script). Problem: If I set this to 21, I get this legitimate-looking error:
1
This is what the hardware vendor explicitly recommends when using their gradle-based build… I guess I'll try bumping to 23.
1
Show replies

