Skip to content

Commit bf60aac

Browse files
committed
build(runtime): keep building the armeabi-v7a runtime as A32
With the NDK defaults no longer overwritten, armeabi-v7a picks up the toolchain's -mthumb and the runtime's own code turns into Thumb-2. That shrank the stripped v7 library by 480 KB (-140 KB gzipped, runtime code -33%), but on a Samsung SM-G780G (API 33, optimized release, 32-bit process) it made the JNI bridge consistently slower than the A32 build we have shipped so far: static.noop() 175 -> 210 ns (+19.5%) static.add(int,int) +14.4% instance.getInt() +10.2% instance.echo(String) +10.9% field.get int +12.8% geomean, 63 rows +4-11% Pass -DANDROID_ARM_MODE=arm so the toolchain leaves -mthumb out (clang's armv7 default is A32) while every other NDK default still applies. V8's prebuilt archive is unaffected and stays Thumb-2.
1 parent 4595c58 commit bf60aac

2 files changed

Lines changed: 5 additions & 3 deletions

File tree

‎test-app/runtime/CMakeLists.txt‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ MESSAGE(STATUS "## ANDROID_NDK_ROOT: " ${ANDROID_NDK_ROOT})
2020

2121

2222
# These are appended to CMAKE_CXX_FLAGS, never assigned over it: the NDK toolchain
23-
# puts its ABI flags there, among them -march=armv7-a -mthumb and, for x86 below
24-
# API 24, -mstackrealign.
23+
# puts its ABI flags there, among them -march=armv7-a and, for x86 below API 24,
24+
# -mstackrealign.
2525
set(COMMON_CMAKE_ARGUMENTS "-std=c++20 -Werror -Wno-unused-result -fexceptions -fno-builtin-stpcpy -fno-rtti -DV8_31BIT_SMIS_ON_64BIT_ARCH -DV8_31BIT_SMIS_ON_64BIT_ARCH -DV8_ENABLE_REGEXP_INTERPRETER_THREADED_DISPATCH -DV8_EMBEDDED_BUILTINS -Wno-vla-extension -Wno-deprecated -Wno-vla-cxx-extension")
2626

2727

‎test-app/runtime/build.gradle‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,9 @@ android {
121121
}
122122

123123
cppFlags "-std=c++20"
124-
arguments "-DANDROID_STL=c++_static", "-DANDROID_NDK_ROOT=${NDK_PATH}", "-DANDROID_SUPPORT_FLEXIBLE_PAGE_SIZES=ON"
124+
// armeabi-v7a runtime code is built as A32 rather than the NDK's default
125+
// Thumb-2: Thumb measured 10-20% slower on the JNI call paths.
126+
arguments "-DANDROID_STL=c++_static", "-DANDROID_NDK_ROOT=${NDK_PATH}", "-DANDROID_SUPPORT_FLEXIBLE_PAGE_SIZES=ON", "-DANDROID_ARM_MODE=arm"
125127
}
126128
}
127129

0 commit comments

Comments
 (0)