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

[BUG] Default release flags changed to O3 with unified cmake toolchain in r23-beta5 #1536

Closed
fplk0 opened this issue Jul 13, 2021 · 15 comments
Closed
Assignees
Labels

Comments

@fplk0
Copy link

fplk0 commented Jul 13, 2021

Description

In ndk r21e, default release flags for armeabi-v7a have Os, and for all other archs it's O2.
In ndk r23 beta 5, those flags are set to O3 for all archs.
This can potentially cause a significant bin size regressions for many consumers.
simple-cmake.zip
With that dummy project (the error is intentional to view the compiler flags w/ ninja):
cmake .. -DCMAKE_TOOLCHAIN_FILE='~/Downloads/android-ndk-r23-beta5/build/cmake/android.toolchain.cmake' -DANDROID_ABI="armeabi-v7a with NEON" -DANDROID_NATIVE_API_LEVEL=21 -G Ninja -DCMAKE_BUILD_TYPE=Release; ninja
shows that O3 is being passed to compile flags,
cmake .. -DCMAKE_TOOLCHAIN_FILE='~/Downloads/android-ndk-r21e/build/cmake/android.toolchain.cmake' -DANDROID_ABI="armeabi-v7a with NEON" -DANDROID_NATIVE_API_LEVEL=21 -G Ninja -DCMAKE_BUILD_TYPE=Release; ninja
shows that Oz is being passed, as expected.
Similar with arm64-v8a ABI, with O2 in older toolchain being replaced by O3.
AFAIK overall O3 is considered non-beneficial for performance, and I'd argue that on older armeabi-v7a devices code size savings from Oz will yield (much?) better performance overall than O3.
Note that for cmake 3.20 and below it implicitly uses legacy toolchain file instead, and still applies the correct flags (Oz/O2); it'd be quite unexpected that bumping the cmake version will change the compilation flags that dramatically without any notice.

Environment Details

  • NDK Version: r23-beta5
  • Build system: cmake + android toolchain; cmake version 3.21.0-rc3
  • Host OS: mac / probably unrelated
  • NDK API level: 21
@fplk0 fplk0 added the bug label Jul 13, 2021
@DanAlbert
Copy link
Member

We need to think about how we want the default behavior to work. Reducing behavioral differences as compared to the stock CMake behavior was one of the key reasons for unifying the two interfaces, so my initial reaction is that the fix here is to document that folks should exercise caution and inspect their compile command lines (as you have) when updating past CMake 3.20. The alternative would be akin to undoing the work. I don't think there's much in the way of an option 3, but I haven't given it much thought yet.

That's the answer for what we need to do in the NDK. On your end, I'd guess you're better off being explicit and telling CMake that you want MinSizeRel and not Release. I don't know if I've ever tried that though, so hopefully it knows to do things like use -Oz for Clang instead of -Os...

I don't think there's MinSizeRelWithDebInfo though, so not an answer for everyone (and I don't know how much control over the build type AGP users have).

@fplk0
Copy link
Author

fplk0 commented Jul 20, 2021

Thanks @DanAlbert, I understand your view, and, if the end goal is unification with cmake, then this all sounds reasonable.
The point to discuss is the fact that "Release" in cmake is like a de-facto default configuration(and afaik Gradle uses it by default too According to this, agp started to use RelWithDebInfo, which is never documented anywhere afaik), and I'm not sure, from android's infra standpoint, that size-bloated binary without debug info is a meaningful default for the android platform that most of the developers want to release to prod.
Yet another point to discuss is that RelWithDebInfo uses O2 while Release uses O3 :)
Regarding your point about MinSizeRel, no, it uses Os for clang instead of Oz :(
If we look in the other direction, on xcode/ios the default is Os for both architectures (and with debug info). I can understand why such a release configuration that cmake uses makes sense for desktop platforms, but I'm not sure if it's the best for mobile platforms.
Sorry, this message ended up very chaotic, but I just made several discoveries in the process of writing it.

So, to summarize, in my opinion:

  • I think that at least both of those flags need to be very visible in the changelog as those are quite nasty side effects which some people might discover on accident after, say, anything bumps cmake on the builder.
  • I think that it makes sense to have Os as default, but I don't think that this change is viable at this point. Those who care about performance or size will choose the flag they need or LTO; for those who don't, anything different from O0 is fine and the change might cause extra confusion.
  • I don't think that O3 makes sense anywhere as default.
  • Continued, I think that RelWithDebInfo and Release should only differ by the "-g" flag which they are not atm. It makes sense to make both of those O2 (or even Os).

@DanAlbert
Copy link
Member

I think that at least both of those flags need to be very visible in the changelog as those are quite nasty side effects which some people might discover on accident after, say, anything bumps cmake on the builder.

Agreed. Done: https://android-review.googlesource.com/c/platform/ndk/+/1773073

[the other points]

More or less agreed here as well. The last point (minimizing differences between RelWithDebInfo and Release) isn't something we have control over since upstream CMake can introduce new differences whenever they want, but for the others I suspect we can teach CMake that the default release optimization for Android should be something other than what it is for desktops and servers.

The info about iOS's defaults is interesting as well. The old NDK behavior here was to default to -Oz for 32-bit Thumb (yes, ARM and thumb were actually different 😭), and -O2 for everything else. That disparity has always bothered me but I lack the data to know in which direction to unify them (or if they should be changed at all). I'm hesitant to decrease the default optimization level without being able to quantify the pros and cons...

I think the thing for us to do here that no one will argue with will be be to fix CMake to make MinSizeRel use -Oz for Clang, and probably to give CMake a MinSizeRelWithDebInfo build type.

Changing the default flags of Release is something I'm less confident we could do, and I don't think it's even possible to change the default CMAKE_BUILD_TYPE based on the platform. It's worth noting that AGP will already use RelWithDebInfo though, so if we get MinSizeRelWithDebInfo added we could use that instead in AGP.

@enh-google
Copy link
Collaborator

(yeah, thank you @Sfairat for the detailed and well thought-out commentary!)

@fplk0
Copy link
Author

fplk0 commented Jul 21, 2021

Thanks @DanAlbert,
Looked deeper into what Cmake does and yes, it's by design that RelWithDebInfo and Release are different (see the discussion here); so there's nothing else to do w/ defaults, and I'm closing the issue. Thanks for the discussion!

@fplk0 fplk0 closed this as completed Jul 21, 2021
@DanAlbert
Copy link
Member

Filed https://gitlab.kitware.com/cmake/cmake/-/issues/22458 to track the definite piece of follow up work. I'm pretty sure I have the patch to send, but need to work out how to run their tests...

@fplk0
Copy link
Author

fplk0 commented Aug 13, 2021

btw @DanAlbert I realized that there's another inconsistency I didn't point about - right now, non-legacy toolchain file has

# https://github.com/android/ndk/issues/133
if(CMAKE_ANDROID_ARCH_ABI MATCHES "^armeabi" AND NOT CMAKE_ANDROID_ARM_MODE)
  string(APPEND _ANDROID_NDK_INIT_CFLAGS_RELEASE " -Oz")
endif()

..Now, looking at this, I realized that I missed a very well actionable item for this.
What's happening is that later in flags.cmake we discard _ANDROID_NDK_INIT_CFLAGS_RELEASE via set(_ANDROID_NDK_INIT_CFLAGS_RELEASE).
There're two real ways around this to fix it in NDK - set the value as CACHE inside android.toolchain.cmake (probably more of a hack, it's not really CACHE var); remove the "clearing" in flags.cmake.
Alternatively, Oz can be just removed from android.toolchain.cmake given that unification with cmake is one of the goals. However, it'll be a reversal of #133.
Reopening the issue given that it IMO is an actionable concern.

@fplk0 fplk0 reopened this Aug 13, 2021
grendello added a commit to grendello/xamarin-android that referenced this issue Aug 16, 2021
Context: https://github.com/android/ndk/wiki/Changelog-r23#changelog

The most important changes for Xamarin.Android:

NDK r23 removes GNU Binutils and so we need to switch to using our
bundled copy of them.

Upstream changes:

* Includes Android 12 APIs.
* Updated LLVM to clang-r416183b, based on LLVM 12 development.
  * [Issue 1047]: Fixes crash when using ASan with the CFI unwinder.
  * [Issue 1096]: Includes support for [Polly]. Enable by adding `-mllvm -polly`
    to your cflags.
  * [Issue 1230]: LLVM's libunwind is now used instead of libgcc for all
    architectures rather than just 32-bit Arm.
  * [Issue 1231]: LLVM's libclang_rt.builtins is now used instead of libgcc.
  * [Issue 1406]: Fixes crash with Neon intrinsic.
* Vulkan validation layer source and binaries are no longer shipped in the NDK.
  The latest are now posted directly to [GitHub](https://github.com/KhronosGroup/Vulkan-ValidationLayers/releases).
* Vulkan tools source is also removed, specifically vulkan_wrapper.
  It should be downloaded upstream from [GitHub](https://github.com/KhronosGroup/Vulkan-Tools).
* The toolchain file (android.toolchain.cmake) is refactored to base on CMake's
  integrated Android support. This new toolchain file will be enabled by default
  for CMake 3.21 and newer. No user side change is expected. But if anything goes
  wrong, please file a bug and set `ANDROID_USE_LEGACY_TOOLCHAIN_FILE=ON` to
  restore the legacy behavior.
    * When using the new behavior (when using CMake 3.21+ and not explicitly
      selecting the legacy toolchain), **default build flags may change**. One
      of the primary goals was to reduce the behavior differences between our
      toolchain and CMake, and CMake's default flags do not always match the
      legacy toolchain file. Most notably, if using `CMAKE_BUILD_TYPE=Release`,
      your optimization type will likely be `-O3` instead of `-O2` or `-Oz`. See
      [Issue 1536] for more information.
* [Issue 929]: `find_library` now prefers shared libraries from the sysroot over
  static libraries.
* [Issue 1390]: ndk-build now warns when building a static executable with the
  wrong API level.
* [Issue 1452]: `NDK_ANALYZE=1` now sets `APP_CLANG_TIDY=true` rather than using
  scan-build. clang-tidy performs all the same checks by default, and scan-build
  was no longer working. See the bug for more details, but no user-side changes
  should be needed.

[Issue 929]: android/ndk#929
[Issue 1047]: android/ndk#1047
[Issue 1096]: android/ndk#1096
[Issue 1230]: android/ndk#1230
[Issue 1231]: android/ndk#1231
[Issue 1390]: android/ndk#1390
[Issue 1406]: android/ndk#1406
[Issue 1452]: android/ndk#1452
[Issue 1536]: android/ndk#1536
[Polly]: https://polly.llvm.org/
grendello added a commit to grendello/xamarin-android that referenced this issue Aug 18, 2021
Context: https://github.com/android/ndk/wiki/Changelog-r23#changelog

The most important changes for Xamarin.Android:

NDK r23 removes GNU Binutils and so we need to switch to using our
bundled copy of them.

Upstream changes:

* Includes Android 12 APIs.
* Updated LLVM to clang-r416183b, based on LLVM 12 development.
  * [Issue 1047]: Fixes crash when using ASan with the CFI unwinder.
  * [Issue 1096]: Includes support for [Polly]. Enable by adding `-mllvm -polly`
    to your cflags.
  * [Issue 1230]: LLVM's libunwind is now used instead of libgcc for all
    architectures rather than just 32-bit Arm.
  * [Issue 1231]: LLVM's libclang_rt.builtins is now used instead of libgcc.
  * [Issue 1406]: Fixes crash with Neon intrinsic.
* Vulkan validation layer source and binaries are no longer shipped in the NDK.
  The latest are now posted directly to [GitHub](https://github.com/KhronosGroup/Vulkan-ValidationLayers/releases).
* Vulkan tools source is also removed, specifically vulkan_wrapper.
  It should be downloaded upstream from [GitHub](https://github.com/KhronosGroup/Vulkan-Tools).
* The toolchain file (android.toolchain.cmake) is refactored to base on CMake's
  integrated Android support. This new toolchain file will be enabled by default
  for CMake 3.21 and newer. No user side change is expected. But if anything goes
  wrong, please file a bug and set `ANDROID_USE_LEGACY_TOOLCHAIN_FILE=ON` to
  restore the legacy behavior.
    * When using the new behavior (when using CMake 3.21+ and not explicitly
      selecting the legacy toolchain), **default build flags may change**. One
      of the primary goals was to reduce the behavior differences between our
      toolchain and CMake, and CMake's default flags do not always match the
      legacy toolchain file. Most notably, if using `CMAKE_BUILD_TYPE=Release`,
      your optimization type will likely be `-O3` instead of `-O2` or `-Oz`. See
      [Issue 1536] for more information.
* [Issue 929]: `find_library` now prefers shared libraries from the sysroot over
  static libraries.
* [Issue 1390]: ndk-build now warns when building a static executable with the
  wrong API level.
* [Issue 1452]: `NDK_ANALYZE=1` now sets `APP_CLANG_TIDY=true` rather than using
  scan-build. clang-tidy performs all the same checks by default, and scan-build
  was no longer working. See the bug for more details, but no user-side changes
  should be needed.

[Issue 929]: android/ndk#929
[Issue 1047]: android/ndk#1047
[Issue 1096]: android/ndk#1096
[Issue 1230]: android/ndk#1230
[Issue 1231]: android/ndk#1231
[Issue 1390]: android/ndk#1390
[Issue 1406]: android/ndk#1406
[Issue 1452]: android/ndk#1452
[Issue 1536]: android/ndk#1536
[Polly]: https://polly.llvm.org/
grendello added a commit to grendello/xamarin-android that referenced this issue Aug 19, 2021
Context: https://github.com/android/ndk/wiki/Changelog-r23#changelog

The most important changes for Xamarin.Android:

NDK r23 removes GNU Binutils and so we need to switch to using our
bundled copy of them.

Upstream changes:

* Includes Android 12 APIs.
* Updated LLVM to clang-r416183b, based on LLVM 12 development.
  * [Issue 1047]: Fixes crash when using ASan with the CFI unwinder.
  * [Issue 1096]: Includes support for [Polly]. Enable by adding `-mllvm -polly`
    to your cflags.
  * [Issue 1230]: LLVM's libunwind is now used instead of libgcc for all
    architectures rather than just 32-bit Arm.
  * [Issue 1231]: LLVM's libclang_rt.builtins is now used instead of libgcc.
  * [Issue 1406]: Fixes crash with Neon intrinsic.
* Vulkan validation layer source and binaries are no longer shipped in the NDK.
  The latest are now posted directly to [GitHub](https://github.com/KhronosGroup/Vulkan-ValidationLayers/releases).
* Vulkan tools source is also removed, specifically vulkan_wrapper.
  It should be downloaded upstream from [GitHub](https://github.com/KhronosGroup/Vulkan-Tools).
* The toolchain file (android.toolchain.cmake) is refactored to base on CMake's
  integrated Android support. This new toolchain file will be enabled by default
  for CMake 3.21 and newer. No user side change is expected. But if anything goes
  wrong, please file a bug and set `ANDROID_USE_LEGACY_TOOLCHAIN_FILE=ON` to
  restore the legacy behavior.
    * When using the new behavior (when using CMake 3.21+ and not explicitly
      selecting the legacy toolchain), **default build flags may change**. One
      of the primary goals was to reduce the behavior differences between our
      toolchain and CMake, and CMake's default flags do not always match the
      legacy toolchain file. Most notably, if using `CMAKE_BUILD_TYPE=Release`,
      your optimization type will likely be `-O3` instead of `-O2` or `-Oz`. See
      [Issue 1536] for more information.
* [Issue 929]: `find_library` now prefers shared libraries from the sysroot over
  static libraries.
* [Issue 1390]: ndk-build now warns when building a static executable with the
  wrong API level.
* [Issue 1452]: `NDK_ANALYZE=1` now sets `APP_CLANG_TIDY=true` rather than using
  scan-build. clang-tidy performs all the same checks by default, and scan-build
  was no longer working. See the bug for more details, but no user-side changes
  should be needed.

[Issue 929]: android/ndk#929
[Issue 1047]: android/ndk#1047
[Issue 1096]: android/ndk#1096
[Issue 1230]: android/ndk#1230
[Issue 1231]: android/ndk#1231
[Issue 1390]: android/ndk#1390
[Issue 1406]: android/ndk#1406
[Issue 1452]: android/ndk#1452
[Issue 1536]: android/ndk#1536
[Polly]: https://polly.llvm.org/
grendello added a commit to grendello/xamarin-android that referenced this issue Aug 19, 2021
Context: https://github.com/android/ndk/wiki/Changelog-r23#changelog

The most important changes for Xamarin.Android:

NDK r23 removes GNU Binutils and so we need to switch to using our
bundled copy of them.

Upstream changes:

* Includes Android 12 APIs.
* Updated LLVM to clang-r416183b, based on LLVM 12 development.
  * [Issue 1047]: Fixes crash when using ASan with the CFI unwinder.
  * [Issue 1096]: Includes support for [Polly]. Enable by adding `-mllvm -polly`
    to your cflags.
  * [Issue 1230]: LLVM's libunwind is now used instead of libgcc for all
    architectures rather than just 32-bit Arm.
  * [Issue 1231]: LLVM's libclang_rt.builtins is now used instead of libgcc.
  * [Issue 1406]: Fixes crash with Neon intrinsic.
* Vulkan validation layer source and binaries are no longer shipped in the NDK.
  The latest are now posted directly to [GitHub](https://github.com/KhronosGroup/Vulkan-ValidationLayers/releases).
* Vulkan tools source is also removed, specifically vulkan_wrapper.
  It should be downloaded upstream from [GitHub](https://github.com/KhronosGroup/Vulkan-Tools).
* The toolchain file (android.toolchain.cmake) is refactored to base on CMake's
  integrated Android support. This new toolchain file will be enabled by default
  for CMake 3.21 and newer. No user side change is expected. But if anything goes
  wrong, please file a bug and set `ANDROID_USE_LEGACY_TOOLCHAIN_FILE=ON` to
  restore the legacy behavior.
    * When using the new behavior (when using CMake 3.21+ and not explicitly
      selecting the legacy toolchain), **default build flags may change**. One
      of the primary goals was to reduce the behavior differences between our
      toolchain and CMake, and CMake's default flags do not always match the
      legacy toolchain file. Most notably, if using `CMAKE_BUILD_TYPE=Release`,
      your optimization type will likely be `-O3` instead of `-O2` or `-Oz`. See
      [Issue 1536] for more information.
* [Issue 929]: `find_library` now prefers shared libraries from the sysroot over
  static libraries.
* [Issue 1390]: ndk-build now warns when building a static executable with the
  wrong API level.
* [Issue 1452]: `NDK_ANALYZE=1` now sets `APP_CLANG_TIDY=true` rather than using
  scan-build. clang-tidy performs all the same checks by default, and scan-build
  was no longer working. See the bug for more details, but no user-side changes
  should be needed.

[Issue 929]: android/ndk#929
[Issue 1047]: android/ndk#1047
[Issue 1096]: android/ndk#1096
[Issue 1230]: android/ndk#1230
[Issue 1231]: android/ndk#1231
[Issue 1390]: android/ndk#1390
[Issue 1406]: android/ndk#1406
[Issue 1452]: android/ndk#1452
[Issue 1536]: android/ndk#1536
[Polly]: https://polly.llvm.org/
grendello added a commit to grendello/xamarin-android that referenced this issue Aug 19, 2021
Context: https://github.com/android/ndk/wiki/Changelog-r23#changelog

The most important changes for Xamarin.Android:

NDK r23 removes GNU Binutils and so we need to switch to using our
bundled copy of them.

Upstream changes:

* Includes Android 12 APIs.
* Updated LLVM to clang-r416183b, based on LLVM 12 development.
  * [Issue 1047]: Fixes crash when using ASan with the CFI unwinder.
  * [Issue 1096]: Includes support for [Polly]. Enable by adding `-mllvm -polly`
    to your cflags.
  * [Issue 1230]: LLVM's libunwind is now used instead of libgcc for all
    architectures rather than just 32-bit Arm.
  * [Issue 1231]: LLVM's libclang_rt.builtins is now used instead of libgcc.
  * [Issue 1406]: Fixes crash with Neon intrinsic.
* Vulkan validation layer source and binaries are no longer shipped in the NDK.
  The latest are now posted directly to [GitHub](https://github.com/KhronosGroup/Vulkan-ValidationLayers/releases).
* Vulkan tools source is also removed, specifically vulkan_wrapper.
  It should be downloaded upstream from [GitHub](https://github.com/KhronosGroup/Vulkan-Tools).
* The toolchain file (android.toolchain.cmake) is refactored to base on CMake's
  integrated Android support. This new toolchain file will be enabled by default
  for CMake 3.21 and newer. No user side change is expected. But if anything goes
  wrong, please file a bug and set `ANDROID_USE_LEGACY_TOOLCHAIN_FILE=ON` to
  restore the legacy behavior.
    * When using the new behavior (when using CMake 3.21+ and not explicitly
      selecting the legacy toolchain), **default build flags may change**. One
      of the primary goals was to reduce the behavior differences between our
      toolchain and CMake, and CMake's default flags do not always match the
      legacy toolchain file. Most notably, if using `CMAKE_BUILD_TYPE=Release`,
      your optimization type will likely be `-O3` instead of `-O2` or `-Oz`. See
      [Issue 1536] for more information.
* [Issue 929]: `find_library` now prefers shared libraries from the sysroot over
  static libraries.
* [Issue 1390]: ndk-build now warns when building a static executable with the
  wrong API level.
* [Issue 1452]: `NDK_ANALYZE=1` now sets `APP_CLANG_TIDY=true` rather than using
  scan-build. clang-tidy performs all the same checks by default, and scan-build
  was no longer working. See the bug for more details, but no user-side changes
  should be needed.

[Issue 929]: android/ndk#929
[Issue 1047]: android/ndk#1047
[Issue 1096]: android/ndk#1096
[Issue 1230]: android/ndk#1230
[Issue 1231]: android/ndk#1231
[Issue 1390]: android/ndk#1390
[Issue 1406]: android/ndk#1406
[Issue 1452]: android/ndk#1452
[Issue 1536]: android/ndk#1536
[Polly]: https://polly.llvm.org/
grendello added a commit to grendello/xamarin-android that referenced this issue Aug 23, 2021
Context: https://github.com/android/ndk/wiki/Changelog-r23#changelog

The most important changes for Xamarin.Android:

NDK r23 removes GNU Binutils and so we need to switch to using our
bundled copy of them.

Upstream changes:

* Includes Android 12 APIs.
* Updated LLVM to clang-r416183b, based on LLVM 12 development.
  * [Issue 1047]: Fixes crash when using ASan with the CFI unwinder.
  * [Issue 1096]: Includes support for [Polly]. Enable by adding `-mllvm -polly`
    to your cflags.
  * [Issue 1230]: LLVM's libunwind is now used instead of libgcc for all
    architectures rather than just 32-bit Arm.
  * [Issue 1231]: LLVM's libclang_rt.builtins is now used instead of libgcc.
  * [Issue 1406]: Fixes crash with Neon intrinsic.
* Vulkan validation layer source and binaries are no longer shipped in the NDK.
  The latest are now posted directly to [GitHub](https://github.com/KhronosGroup/Vulkan-ValidationLayers/releases).
* Vulkan tools source is also removed, specifically vulkan_wrapper.
  It should be downloaded upstream from [GitHub](https://github.com/KhronosGroup/Vulkan-Tools).
* The toolchain file (android.toolchain.cmake) is refactored to base on CMake's
  integrated Android support. This new toolchain file will be enabled by default
  for CMake 3.21 and newer. No user side change is expected. But if anything goes
  wrong, please file a bug and set `ANDROID_USE_LEGACY_TOOLCHAIN_FILE=ON` to
  restore the legacy behavior.
    * When using the new behavior (when using CMake 3.21+ and not explicitly
      selecting the legacy toolchain), **default build flags may change**. One
      of the primary goals was to reduce the behavior differences between our
      toolchain and CMake, and CMake's default flags do not always match the
      legacy toolchain file. Most notably, if using `CMAKE_BUILD_TYPE=Release`,
      your optimization type will likely be `-O3` instead of `-O2` or `-Oz`. See
      [Issue 1536] for more information.
* [Issue 929]: `find_library` now prefers shared libraries from the sysroot over
  static libraries.
* [Issue 1390]: ndk-build now warns when building a static executable with the
  wrong API level.
* [Issue 1452]: `NDK_ANALYZE=1` now sets `APP_CLANG_TIDY=true` rather than using
  scan-build. clang-tidy performs all the same checks by default, and scan-build
  was no longer working. See the bug for more details, but no user-side changes
  should be needed.

[Issue 929]: android/ndk#929
[Issue 1047]: android/ndk#1047
[Issue 1096]: android/ndk#1096
[Issue 1230]: android/ndk#1230
[Issue 1231]: android/ndk#1231
[Issue 1390]: android/ndk#1390
[Issue 1406]: android/ndk#1406
[Issue 1452]: android/ndk#1452
[Issue 1536]: android/ndk#1536
[Polly]: https://polly.llvm.org/
grendello added a commit to grendello/xamarin-android that referenced this issue Aug 23, 2021
Context: https://github.com/android/ndk/wiki/Changelog-r23#changelog

The most important changes for Xamarin.Android:

NDK r23 removes GNU Binutils and so we need to switch to using our
bundled copy of them.

Upstream changes:

* Includes Android 12 APIs.
* Updated LLVM to clang-r416183b, based on LLVM 12 development.
  * [Issue 1047]: Fixes crash when using ASan with the CFI unwinder.
  * [Issue 1096]: Includes support for [Polly]. Enable by adding `-mllvm -polly`
    to your cflags.
  * [Issue 1230]: LLVM's libunwind is now used instead of libgcc for all
    architectures rather than just 32-bit Arm.
  * [Issue 1231]: LLVM's libclang_rt.builtins is now used instead of libgcc.
  * [Issue 1406]: Fixes crash with Neon intrinsic.
* Vulkan validation layer source and binaries are no longer shipped in the NDK.
  The latest are now posted directly to [GitHub](https://github.com/KhronosGroup/Vulkan-ValidationLayers/releases).
* Vulkan tools source is also removed, specifically vulkan_wrapper.
  It should be downloaded upstream from [GitHub](https://github.com/KhronosGroup/Vulkan-Tools).
* The toolchain file (android.toolchain.cmake) is refactored to base on CMake's
  integrated Android support. This new toolchain file will be enabled by default
  for CMake 3.21 and newer. No user side change is expected. But if anything goes
  wrong, please file a bug and set `ANDROID_USE_LEGACY_TOOLCHAIN_FILE=ON` to
  restore the legacy behavior.
    * When using the new behavior (when using CMake 3.21+ and not explicitly
      selecting the legacy toolchain), **default build flags may change**. One
      of the primary goals was to reduce the behavior differences between our
      toolchain and CMake, and CMake's default flags do not always match the
      legacy toolchain file. Most notably, if using `CMAKE_BUILD_TYPE=Release`,
      your optimization type will likely be `-O3` instead of `-O2` or `-Oz`. See
      [Issue 1536] for more information.
* [Issue 929]: `find_library` now prefers shared libraries from the sysroot over
  static libraries.
* [Issue 1390]: ndk-build now warns when building a static executable with the
  wrong API level.
* [Issue 1452]: `NDK_ANALYZE=1` now sets `APP_CLANG_TIDY=true` rather than using
  scan-build. clang-tidy performs all the same checks by default, and scan-build
  was no longer working. See the bug for more details, but no user-side changes
  should be needed.

[Issue 929]: android/ndk#929
[Issue 1047]: android/ndk#1047
[Issue 1096]: android/ndk#1096
[Issue 1230]: android/ndk#1230
[Issue 1231]: android/ndk#1231
[Issue 1390]: android/ndk#1390
[Issue 1406]: android/ndk#1406
[Issue 1452]: android/ndk#1452
[Issue 1536]: android/ndk#1536
[Polly]: https://polly.llvm.org/
grendello added a commit to grendello/xamarin-android that referenced this issue Aug 23, 2021
Context: https://github.com/android/ndk/wiki/Changelog-r23#changelog

The most important changes for Xamarin.Android:

NDK r23 removes GNU Binutils and so we need to switch to using our
bundled copy of them.

Upstream changes:

* Includes Android 12 APIs.
* Updated LLVM to clang-r416183b, based on LLVM 12 development.
  * [Issue 1047]: Fixes crash when using ASan with the CFI unwinder.
  * [Issue 1096]: Includes support for [Polly]. Enable by adding `-mllvm -polly`
    to your cflags.
  * [Issue 1230]: LLVM's libunwind is now used instead of libgcc for all
    architectures rather than just 32-bit Arm.
  * [Issue 1231]: LLVM's libclang_rt.builtins is now used instead of libgcc.
  * [Issue 1406]: Fixes crash with Neon intrinsic.
* Vulkan validation layer source and binaries are no longer shipped in the NDK.
  The latest are now posted directly to [GitHub](https://github.com/KhronosGroup/Vulkan-ValidationLayers/releases).
* Vulkan tools source is also removed, specifically vulkan_wrapper.
  It should be downloaded upstream from [GitHub](https://github.com/KhronosGroup/Vulkan-Tools).
* The toolchain file (android.toolchain.cmake) is refactored to base on CMake's
  integrated Android support. This new toolchain file will be enabled by default
  for CMake 3.21 and newer. No user side change is expected. But if anything goes
  wrong, please file a bug and set `ANDROID_USE_LEGACY_TOOLCHAIN_FILE=ON` to
  restore the legacy behavior.
    * When using the new behavior (when using CMake 3.21+ and not explicitly
      selecting the legacy toolchain), **default build flags may change**. One
      of the primary goals was to reduce the behavior differences between our
      toolchain and CMake, and CMake's default flags do not always match the
      legacy toolchain file. Most notably, if using `CMAKE_BUILD_TYPE=Release`,
      your optimization type will likely be `-O3` instead of `-O2` or `-Oz`. See
      [Issue 1536] for more information.
* [Issue 929]: `find_library` now prefers shared libraries from the sysroot over
  static libraries.
* [Issue 1390]: ndk-build now warns when building a static executable with the
  wrong API level.
* [Issue 1452]: `NDK_ANALYZE=1` now sets `APP_CLANG_TIDY=true` rather than using
  scan-build. clang-tidy performs all the same checks by default, and scan-build
  was no longer working. See the bug for more details, but no user-side changes
  should be needed.

[Issue 929]: android/ndk#929
[Issue 1047]: android/ndk#1047
[Issue 1096]: android/ndk#1096
[Issue 1230]: android/ndk#1230
[Issue 1231]: android/ndk#1231
[Issue 1390]: android/ndk#1390
[Issue 1406]: android/ndk#1406
[Issue 1452]: android/ndk#1452
[Issue 1536]: android/ndk#1536
[Polly]: https://polly.llvm.org/
grendello added a commit to grendello/xamarin-android that referenced this issue Aug 26, 2021
Context: https://github.com/android/ndk/wiki/Changelog-r23#changelog

The most important changes for Xamarin.Android:

NDK r23 removes GNU Binutils and so we need to switch to using our
bundled copy of them.

Upstream changes:

* Includes Android 12 APIs.
* Updated LLVM to clang-r416183b, based on LLVM 12 development.
  * [Issue 1047]: Fixes crash when using ASan with the CFI unwinder.
  * [Issue 1096]: Includes support for [Polly]. Enable by adding `-mllvm -polly`
    to your cflags.
  * [Issue 1230]: LLVM's libunwind is now used instead of libgcc for all
    architectures rather than just 32-bit Arm.
  * [Issue 1231]: LLVM's libclang_rt.builtins is now used instead of libgcc.
  * [Issue 1406]: Fixes crash with Neon intrinsic.
* Vulkan validation layer source and binaries are no longer shipped in the NDK.
  The latest are now posted directly to [GitHub](https://github.com/KhronosGroup/Vulkan-ValidationLayers/releases).
* Vulkan tools source is also removed, specifically vulkan_wrapper.
  It should be downloaded upstream from [GitHub](https://github.com/KhronosGroup/Vulkan-Tools).
* The toolchain file (android.toolchain.cmake) is refactored to base on CMake's
  integrated Android support. This new toolchain file will be enabled by default
  for CMake 3.21 and newer. No user side change is expected. But if anything goes
  wrong, please file a bug and set `ANDROID_USE_LEGACY_TOOLCHAIN_FILE=ON` to
  restore the legacy behavior.
    * When using the new behavior (when using CMake 3.21+ and not explicitly
      selecting the legacy toolchain), **default build flags may change**. One
      of the primary goals was to reduce the behavior differences between our
      toolchain and CMake, and CMake's default flags do not always match the
      legacy toolchain file. Most notably, if using `CMAKE_BUILD_TYPE=Release`,
      your optimization type will likely be `-O3` instead of `-O2` or `-Oz`. See
      [Issue 1536] for more information.
* [Issue 929]: `find_library` now prefers shared libraries from the sysroot over
  static libraries.
* [Issue 1390]: ndk-build now warns when building a static executable with the
  wrong API level.
* [Issue 1452]: `NDK_ANALYZE=1` now sets `APP_CLANG_TIDY=true` rather than using
  scan-build. clang-tidy performs all the same checks by default, and scan-build
  was no longer working. See the bug for more details, but no user-side changes
  should be needed.

[Issue 929]: android/ndk#929
[Issue 1047]: android/ndk#1047
[Issue 1096]: android/ndk#1096
[Issue 1230]: android/ndk#1230
[Issue 1231]: android/ndk#1231
[Issue 1390]: android/ndk#1390
[Issue 1406]: android/ndk#1406
[Issue 1452]: android/ndk#1452
[Issue 1536]: android/ndk#1536
[Polly]: https://polly.llvm.org/
grendello added a commit to grendello/xamarin-android that referenced this issue Aug 26, 2021
Context: https://github.com/android/ndk/wiki/Changelog-r23#changelog

The most important changes for Xamarin.Android:

NDK r23 removes GNU Binutils and so we need to switch to using our
bundled copy of them.

Upstream changes:

* Includes Android 12 APIs.
* Updated LLVM to clang-r416183b, based on LLVM 12 development.
  * [Issue 1047]: Fixes crash when using ASan with the CFI unwinder.
  * [Issue 1096]: Includes support for [Polly]. Enable by adding `-mllvm -polly`
    to your cflags.
  * [Issue 1230]: LLVM's libunwind is now used instead of libgcc for all
    architectures rather than just 32-bit Arm.
  * [Issue 1231]: LLVM's libclang_rt.builtins is now used instead of libgcc.
  * [Issue 1406]: Fixes crash with Neon intrinsic.
* Vulkan validation layer source and binaries are no longer shipped in the NDK.
  The latest are now posted directly to [GitHub](https://github.com/KhronosGroup/Vulkan-ValidationLayers/releases).
* Vulkan tools source is also removed, specifically vulkan_wrapper.
  It should be downloaded upstream from [GitHub](https://github.com/KhronosGroup/Vulkan-Tools).
* The toolchain file (android.toolchain.cmake) is refactored to base on CMake's
  integrated Android support. This new toolchain file will be enabled by default
  for CMake 3.21 and newer. No user side change is expected. But if anything goes
  wrong, please file a bug and set `ANDROID_USE_LEGACY_TOOLCHAIN_FILE=ON` to
  restore the legacy behavior.
    * When using the new behavior (when using CMake 3.21+ and not explicitly
      selecting the legacy toolchain), **default build flags may change**. One
      of the primary goals was to reduce the behavior differences between our
      toolchain and CMake, and CMake's default flags do not always match the
      legacy toolchain file. Most notably, if using `CMAKE_BUILD_TYPE=Release`,
      your optimization type will likely be `-O3` instead of `-O2` or `-Oz`. See
      [Issue 1536] for more information.
* [Issue 929]: `find_library` now prefers shared libraries from the sysroot over
  static libraries.
* [Issue 1390]: ndk-build now warns when building a static executable with the
  wrong API level.
* [Issue 1452]: `NDK_ANALYZE=1` now sets `APP_CLANG_TIDY=true` rather than using
  scan-build. clang-tidy performs all the same checks by default, and scan-build
  was no longer working. See the bug for more details, but no user-side changes
  should be needed.

[Issue 929]: android/ndk#929
[Issue 1047]: android/ndk#1047
[Issue 1096]: android/ndk#1096
[Issue 1230]: android/ndk#1230
[Issue 1231]: android/ndk#1231
[Issue 1390]: android/ndk#1390
[Issue 1406]: android/ndk#1406
[Issue 1452]: android/ndk#1452
[Issue 1536]: android/ndk#1536
[Polly]: https://polly.llvm.org/
grendello added a commit to grendello/xamarin-android that referenced this issue Aug 26, 2021
Context: https://github.com/android/ndk/wiki/Changelog-r23#changelog

The most important changes for Xamarin.Android:

NDK r23 removes GNU Binutils and so we need to switch to using our
bundled copy of them.

Upstream changes:

* Includes Android 12 APIs.
* Updated LLVM to clang-r416183b, based on LLVM 12 development.
  * [Issue 1047]: Fixes crash when using ASan with the CFI unwinder.
  * [Issue 1096]: Includes support for [Polly]. Enable by adding `-mllvm -polly`
    to your cflags.
  * [Issue 1230]: LLVM's libunwind is now used instead of libgcc for all
    architectures rather than just 32-bit Arm.
  * [Issue 1231]: LLVM's libclang_rt.builtins is now used instead of libgcc.
  * [Issue 1406]: Fixes crash with Neon intrinsic.
* Vulkan validation layer source and binaries are no longer shipped in the NDK.
  The latest are now posted directly to [GitHub](https://github.com/KhronosGroup/Vulkan-ValidationLayers/releases).
* Vulkan tools source is also removed, specifically vulkan_wrapper.
  It should be downloaded upstream from [GitHub](https://github.com/KhronosGroup/Vulkan-Tools).
* The toolchain file (android.toolchain.cmake) is refactored to base on CMake's
  integrated Android support. This new toolchain file will be enabled by default
  for CMake 3.21 and newer. No user side change is expected. But if anything goes
  wrong, please file a bug and set `ANDROID_USE_LEGACY_TOOLCHAIN_FILE=ON` to
  restore the legacy behavior.
    * When using the new behavior (when using CMake 3.21+ and not explicitly
      selecting the legacy toolchain), **default build flags may change**. One
      of the primary goals was to reduce the behavior differences between our
      toolchain and CMake, and CMake's default flags do not always match the
      legacy toolchain file. Most notably, if using `CMAKE_BUILD_TYPE=Release`,
      your optimization type will likely be `-O3` instead of `-O2` or `-Oz`. See
      [Issue 1536] for more information.
* [Issue 929]: `find_library` now prefers shared libraries from the sysroot over
  static libraries.
* [Issue 1390]: ndk-build now warns when building a static executable with the
  wrong API level.
* [Issue 1452]: `NDK_ANALYZE=1` now sets `APP_CLANG_TIDY=true` rather than using
  scan-build. clang-tidy performs all the same checks by default, and scan-build
  was no longer working. See the bug for more details, but no user-side changes
  should be needed.

[Issue 929]: android/ndk#929
[Issue 1047]: android/ndk#1047
[Issue 1096]: android/ndk#1096
[Issue 1230]: android/ndk#1230
[Issue 1231]: android/ndk#1231
[Issue 1390]: android/ndk#1390
[Issue 1406]: android/ndk#1406
[Issue 1452]: android/ndk#1452
[Issue 1536]: android/ndk#1536
[Polly]: https://polly.llvm.org/
grendello added a commit to grendello/xamarin-android that referenced this issue Aug 30, 2021
Context: https://github.com/android/ndk/wiki/Changelog-r23#changelog

The most important changes for Xamarin.Android:

NDK r23 removes GNU Binutils and so we need to switch to using our
bundled copy of them.

Upstream changes:

* Includes Android 12 APIs.
* Updated LLVM to clang-r416183b, based on LLVM 12 development.
  * [Issue 1047]: Fixes crash when using ASan with the CFI unwinder.
  * [Issue 1096]: Includes support for [Polly]. Enable by adding `-mllvm -polly`
    to your cflags.
  * [Issue 1230]: LLVM's libunwind is now used instead of libgcc for all
    architectures rather than just 32-bit Arm.
  * [Issue 1231]: LLVM's libclang_rt.builtins is now used instead of libgcc.
  * [Issue 1406]: Fixes crash with Neon intrinsic.
* Vulkan validation layer source and binaries are no longer shipped in the NDK.
  The latest are now posted directly to [GitHub](https://github.com/KhronosGroup/Vulkan-ValidationLayers/releases).
* Vulkan tools source is also removed, specifically vulkan_wrapper.
  It should be downloaded upstream from [GitHub](https://github.com/KhronosGroup/Vulkan-Tools).
* The toolchain file (android.toolchain.cmake) is refactored to base on CMake's
  integrated Android support. This new toolchain file will be enabled by default
  for CMake 3.21 and newer. No user side change is expected. But if anything goes
  wrong, please file a bug and set `ANDROID_USE_LEGACY_TOOLCHAIN_FILE=ON` to
  restore the legacy behavior.
    * When using the new behavior (when using CMake 3.21+ and not explicitly
      selecting the legacy toolchain), **default build flags may change**. One
      of the primary goals was to reduce the behavior differences between our
      toolchain and CMake, and CMake's default flags do not always match the
      legacy toolchain file. Most notably, if using `CMAKE_BUILD_TYPE=Release`,
      your optimization type will likely be `-O3` instead of `-O2` or `-Oz`. See
      [Issue 1536] for more information.
* [Issue 929]: `find_library` now prefers shared libraries from the sysroot over
  static libraries.
* [Issue 1390]: ndk-build now warns when building a static executable with the
  wrong API level.
* [Issue 1452]: `NDK_ANALYZE=1` now sets `APP_CLANG_TIDY=true` rather than using
  scan-build. clang-tidy performs all the same checks by default, and scan-build
  was no longer working. See the bug for more details, but no user-side changes
  should be needed.

[Issue 929]: android/ndk#929
[Issue 1047]: android/ndk#1047
[Issue 1096]: android/ndk#1096
[Issue 1230]: android/ndk#1230
[Issue 1231]: android/ndk#1231
[Issue 1390]: android/ndk#1390
[Issue 1406]: android/ndk#1406
[Issue 1452]: android/ndk#1452
[Issue 1536]: android/ndk#1536
[Polly]: https://polly.llvm.org/
grendello added a commit to grendello/xamarin-android that referenced this issue Aug 30, 2021
Context: https://github.com/android/ndk/wiki/Changelog-r23#changelog

The most important changes for Xamarin.Android:

NDK r23 removes GNU Binutils and so we need to switch to using our
bundled copy of them.

Upstream changes:

* Includes Android 12 APIs.
* Updated LLVM to clang-r416183b, based on LLVM 12 development.
  * [Issue 1047]: Fixes crash when using ASan with the CFI unwinder.
  * [Issue 1096]: Includes support for [Polly]. Enable by adding `-mllvm -polly`
    to your cflags.
  * [Issue 1230]: LLVM's libunwind is now used instead of libgcc for all
    architectures rather than just 32-bit Arm.
  * [Issue 1231]: LLVM's libclang_rt.builtins is now used instead of libgcc.
  * [Issue 1406]: Fixes crash with Neon intrinsic.
* Vulkan validation layer source and binaries are no longer shipped in the NDK.
  The latest are now posted directly to [GitHub](https://github.com/KhronosGroup/Vulkan-ValidationLayers/releases).
* Vulkan tools source is also removed, specifically vulkan_wrapper.
  It should be downloaded upstream from [GitHub](https://github.com/KhronosGroup/Vulkan-Tools).
* The toolchain file (android.toolchain.cmake) is refactored to base on CMake's
  integrated Android support. This new toolchain file will be enabled by default
  for CMake 3.21 and newer. No user side change is expected. But if anything goes
  wrong, please file a bug and set `ANDROID_USE_LEGACY_TOOLCHAIN_FILE=ON` to
  restore the legacy behavior.
    * When using the new behavior (when using CMake 3.21+ and not explicitly
      selecting the legacy toolchain), **default build flags may change**. One
      of the primary goals was to reduce the behavior differences between our
      toolchain and CMake, and CMake's default flags do not always match the
      legacy toolchain file. Most notably, if using `CMAKE_BUILD_TYPE=Release`,
      your optimization type will likely be `-O3` instead of `-O2` or `-Oz`. See
      [Issue 1536] for more information.
* [Issue 929]: `find_library` now prefers shared libraries from the sysroot over
  static libraries.
* [Issue 1390]: ndk-build now warns when building a static executable with the
  wrong API level.
* [Issue 1452]: `NDK_ANALYZE=1` now sets `APP_CLANG_TIDY=true` rather than using
  scan-build. clang-tidy performs all the same checks by default, and scan-build
  was no longer working. See the bug for more details, but no user-side changes
  should be needed.

[Issue 929]: android/ndk#929
[Issue 1047]: android/ndk#1047
[Issue 1096]: android/ndk#1096
[Issue 1230]: android/ndk#1230
[Issue 1231]: android/ndk#1231
[Issue 1390]: android/ndk#1390
[Issue 1406]: android/ndk#1406
[Issue 1452]: android/ndk#1452
[Issue 1536]: android/ndk#1536
[Polly]: https://polly.llvm.org/
jonpryor pushed a commit to dotnet/android that referenced this issue Aug 31, 2021
Context: https://github.com/android/ndk/wiki/Changelog-r23#changelog

The most important changes for Xamarin.Android:

NDK r23 removes GNU Binutils and so we need to switch to using our
bundled copy of them.

Upstream NDK r23changes:

  * Includes Android 12/API-31 APIs.

  * Updated LLVM to clang-r416183b, based on LLVM 12 development.
    * [Issue 1047]: Fixes crash when using ASan with the CFI unwinder.
    * [Issue 1096]: Includes support for [Polly].
      Enable by adding `-mllvm -polly` to your cflags.
    * [Issue 1230]: LLVM's `libunwind` is now used instead of `libgcc`
      for all architectures rather than just 32-bit ARM.
    * [Issue 1231]: LLVM's `libclang_rt.builtins` is now used instead
      of `libgcc`.
    * [Issue 1406]: Fixes crash with Neon intrinsic.

  * Vulkan validation layer source and binaries are no longer shipped
    in the NDK.  The latest are now posted directly to
    [KhronosGroup/Vulkan-ValidationLayers].

  * Vulkan tools source is also removed, specifically `vulkan_wrapper`.
    It should be downloaded upstream from [KhronosGroup/Vulkan-Tools].

  * Refactored the toolchain file `android.toolchain.cmake`, basing
    it on CMake's integrated Android support.  This new toolchain file
    will be enabled by default for CMake 3.21 and newer.
    No user side change is expected.  But if anything goes wrong,
    please file a bug and set `ANDROID_USE_LEGACY_TOOLCHAIN_FILE=ON`
    to restore the legacy behavior.
      * When using the new behavior (when using CMake 3.21+ and not
        explicitly selecting the legacy toolchain),
        **default build flags may change**.  One of the primary goals
        was to reduce the behavior differences between our toolchain
        and CMake, and CMake's default flags do not always match the
        legacy toolchain file.  Most notably, if using
        `CMAKE_BUILD_TYPE=Release`, your optimization type will likely
        be `-O3` instead of `-O2` or `-Oz`.
        See [Issue 1536] for more information.

  * [Issue 929]: `find_library` now prefers shared libraries from the
    sysroot over static libraries.

  * [Issue 1390]: `ndk-build` now warns when building a static
    executable with the wrong API level.

  * [Issue 1452]: `NDK_ANALYZE=1` now sets `APP_CLANG_TIDY=true` rather
    than using `scan-build`.  `clang-tidy` performs all the same checks
    by default, and `scan-build` was no longer working.
    See [Issue 1452] for more details; no user-side changes should
    be needed.

[Issue 929]: android/ndk#929
[Issue 1047]: android/ndk#1047
[Issue 1096]: android/ndk#1096
[Issue 1230]: android/ndk#1230
[Issue 1231]: android/ndk#1231
[Issue 1390]: android/ndk#1390
[Issue 1406]: android/ndk#1406
[Issue 1452]: android/ndk#1452
[Issue 1536]: android/ndk#1536
[Polly]: https://polly.llvm.org/
[KhronosGroup/Vulkan-ValidationLayers]: https://github.com/KhronosGroup/Vulkan-ValidationLayers/releases
[KhronosGroup/Vulkan-Tools]: https://github.com/KhronosGroup/Vulkan-Tools
@DanAlbert
Copy link
Member

I think the fix is actually simpler than that. It looks like that block just needs to move to flags.cmake. I think that was just an oversight in the migration. I test that manually and it seems fine, but am writing a test to verify consistency between the various modes before submitting it.

@DanAlbert DanAlbert self-assigned this Sep 2, 2021
@DanAlbert
Copy link
Member

Yet another point to discuss is that RelWithDebInfo uses O2 while Release uses O3 :)

Ugh, and more annoying than that, with the old toolchain for arm Release uses -Oz and RelWithDebInfo uses -O2 :( I'll go figure out how long that has been the default behavior in AGP. If it's been this way for a long time I think this is a great time for us to lose this arch-specific behavior, but if it's recent we'll need to decide whether to fix it or leave it.

@DanAlbert
Copy link
Member

The new behavior has only been shipping in AGP since the latest release, but I'm still leaning toward just admitting that we lost -Oz and removing some per-arch and android-only behavior from CMake. https://android-review.googlesource.com/c/platform/ndk/+/1826817 does that, but we're still discussing whether that's the right decision.

@DanAlbert
Copy link
Member

Decided to go that route. It's submitted and will be in r23b.

@bommo1
Copy link

bommo1 commented Sep 15, 2021

Is there a workaround besides using the legacy toolchain with an older CMake?

@DanAlbert
Copy link
Member

Just set your flags the way you want them.

@fplk0
Copy link
Author

fplk0 commented Sep 16, 2021

@bommo1 @DanAlbert To clarify, there's one more caveat to that - you will need to set CMAKE_<LANG>_FLAGS_<BUILD_TYPE>, as if you just append -Odesired to CMAKE_C_FLAGS it will be overridden by the default one, as in CMake O2/O3 is set via CMAKE_<LANG>_FLAGS_<BUILD_TYPE>, which are appended after regular CMAKE_<LANG>_FLAGS.

chenguoyin-alibaba pushed a commit to riscv-android-src/platform-ndk that referenced this issue Oct 21, 2021
Test: None
Bug: android/ndk#1536
Change-Id: I41b648e8c01d206eeefae56b53b2a326f95e5bf9
(cherry picked from commit a6c228b)
chenguoyin-alibaba pushed a commit to riscv-android-src/platform-ndk that referenced this issue Oct 21, 2021
Test: added test
Bug: android/ndk#1536
Change-Id: I5be285e59026af9d988b96551f58ff27744d0ed8
(cherry picked from commit 1a42764)
@rprichard
Copy link
Collaborator

Fixed in r23b.

akoeplinger added a commit to dotnet/runtime that referenced this issue Jun 30, 2022
Brings in new cmake 2.23.1 and Android NDK23c which fixes an issue with the binary size and perf of libmonosgen-2.0.so

In NDK23b they decided to no longer pass -O2 compiler optimization flag (for arm64, armv7 used -Oz) as part of the Android toolchain but delegate to upstream CMake behavior: https://github.com/android/ndk/wiki/Changelog-r23 and android/ndk#1536

CMake defaults to -O3 for Release builds but unfortunately this causes quite a noticable binary size increase and perf regression.

The Xamarin Android team measured startup time on an average of 10 runs of `dotnet new maui` on a Pixel 5:
```
-O3: 893.7ms
-O2: 600.2ms
-Oz: 649.1ms
```

We now explicitly pass in -O2 for Android builds.

Fixes #68330
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants