Skip to content

Commit

Permalink
Fix build/runtime API level for static exe tests.
Browse files Browse the repository at this point in the history
Static executable tests need this to run correctly. They need to build
against the newest API level (there's only one libc.a, which the headers
and CRT objects need to match), but can run against any API level.

We've been getting away with this for a while because it wasn't as
strict, but libc.a now has a dependency on ELF TLS, so we need the newer
CRT objects. We were further getting away with it because --gc-sections
was stripping the ELF TLS dependency.

Bug: android/ndk#1813
Test: this is the test, now it passes
Change-Id: Icc984f9fa3dc83ecd8c3dca8789be55bcb487119
  • Loading branch information
DanAlbert committed Jan 18, 2023
1 parent ae921f1 commit 6f42bc4
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 12 deletions.
Original file line number Diff line number Diff line change
@@ -1 +1 @@
APP_PLATFORM := android-21
APP_PLATFORM := latest
18 changes: 12 additions & 6 deletions tests/device/static-executable-exceptions/test_config.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
def build_unsupported(test):
# Static executables with libc++ require targeting a new enough API level
# to not need libandroid_support.
if test.config.api < 21:
return f"android-{test.config.api}"
import ndk.abis
from ndk.test.buildtest.case import Test

return None

def extra_cmake_flags() -> list[str]:
# Required for static executables.
return ["-DANDROID_PLATFORM=latest"]


def override_runtime_minsdkversion(test: Test) -> int | None:
# We build as latest because static executables require that, but static executables
# are compatible with old OS versions.
return ndk.abis.min_api_for_abi(test.config.abi)
1 change: 1 addition & 0 deletions tests/device/static-executable/jni/Application.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
APP_PLATFORM := latest
18 changes: 13 additions & 5 deletions tests/device/static-executable/test_config.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
def extra_cmake_flags():
# Match the ndk-build test. Using libc++ here would require us to target a
# newer API level since static executables and libandroid_support don't
# mix.
return ["-DANDROID_STL=system"]
import ndk.abis
from ndk.test.buildtest.case import Test


def extra_cmake_flags() -> list[str]:
# Required for static executables.
return ["-DANDROID_PLATFORM=latest"]


def override_runtime_minsdkversion(test: Test) -> int | None:
# We build as latest because static executables require that, but static executables
# are compatible with old OS versions.
return ndk.abis.min_api_for_abi(test.config.abi)

0 comments on commit 6f42bc4

Please sign in to comment.