Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/dotnet/runtime.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Köplinger <alex.koeplinger@outlook.com>2022-07-01 01:26:14 +0300
committerGitHub <noreply@github.com>2022-07-01 01:26:14 +0300
commit921029babd3a21f3d901a08d359ce6e9b8098c32 (patch)
tree5dac200db075a0a43601591805825095fe4c95ab /src/native/libs
parentac39683d6a8b7eb110334fac394bb66c0de8806d (diff)
Update Android NDK and set optimization flags (#68354)
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 https://github.com/android/ndk/issues/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 https://github.com/dotnet/runtime/issues/68330
Diffstat (limited to 'src/native/libs')
-rw-r--r--src/native/libs/CMakeLists.txt8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/native/libs/CMakeLists.txt b/src/native/libs/CMakeLists.txt
index 577a6dee6b7..04088e9e41d 100644
--- a/src/native/libs/CMakeLists.txt
+++ b/src/native/libs/CMakeLists.txt
@@ -103,7 +103,13 @@ if (CLR_CMAKE_TARGET_UNIX OR CLR_CMAKE_TARGET_BROWSER)
if (CLR_CMAKE_TARGET_ARCH_ARMV7L AND DEFINED ENV{CROSSCOMPILE} AND CMAKE_C_COMPILER_VERSION VERSION_LESS 3.9)
add_compile_options (-O1)
else ()
- add_compile_options (-O3)
+ if(CLR_CMAKE_TARGET_ANDROID)
+ # -O2 optimization generates faster/smaller code on Android
+ # TODO: This duplicates the settings in eng/native/configureoptimization.cmake, we should unify it
+ add_compile_options (-O2)
+ else()
+ add_compile_options (-O3)
+ endif ()
endif ()
else ()
message(FATAL_ERROR "Unknown build type. Set CMAKE_BUILD_TYPE to DEBUG or RELEASE.")