mirror of
https://github.com/saymrwulf/onnxruntime.git
synced 2026-07-19 19:00:47 +00:00
Manually add optimization flag for Android Release builds. (#12390)
With recent versions of NDK (since 23), the `-O` optimization level compile flag is not being passed when building in the "Release" configuration. More details here: https://github.com/android/ndk/issues/1740 Our "Release" Android builds have been built without the optimization flag since we upgraded from NDK 21. This change is a workaround to manually add `-O3` for "Release" Android builds.
This commit is contained in:
parent
6bb807ef74
commit
f77ab4fea6
1 changed files with 10 additions and 0 deletions
|
|
@ -318,6 +318,16 @@ if (onnxruntime_EXTENDED_MINIMAL_BUILD AND NOT onnxruntime_MINIMAL_BUILD)
|
|||
set(onnxruntime_MINIMAL_BUILD ON)
|
||||
endif()
|
||||
|
||||
# work around Android NDK bug which doesn't include -O flag for Release configuration
|
||||
# https://github.com/android/ndk/issues/1740
|
||||
# TODO: remove this when the NDK version(s) we support get fixed
|
||||
if (CMAKE_SYSTEM_NAME STREQUAL "Android")
|
||||
# NB: attempting to match the effects of this fix: https://android-review.googlesource.com/c/platform/ndk/+/2168845
|
||||
string(APPEND CMAKE_C_FLAGS_RELEASE " -O3")
|
||||
string(APPEND CMAKE_CXX_FLAGS_RELEASE " -O3")
|
||||
string(APPEND CMAKE_ASM_FLAGS_RELEASE " -O3")
|
||||
endif()
|
||||
|
||||
# Enable space optimization for gcc/clang
|
||||
# Cannot use "-ffunction-sections -fdata-sections" if we enable bitcode (iOS)
|
||||
if (NOT MSVC AND NOT onnxruntime_ENABLE_BITCODE)
|
||||
|
|
|
|||
Loading…
Reference in a new issue