From 5c47fc3419d516fb224078b1b650196b72bd5dce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Tue, 26 Nov 2024 13:50:23 +0100 Subject: [PATCH 1/4] Bump the NDK version --- android/build.gradle | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/android/build.gradle b/android/build.gradle index 844803333a..e8d3099ac8 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -47,7 +47,9 @@ android { } compileSdk 35 - ndkVersion "21.4.7075529" + + ndkVersion "27.2.12479018" + defaultConfig { /* configurations.all { From 5bc08cfae71cc53316f924902ba02191de96435c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Sun, 5 Jan 2025 16:03:22 +0100 Subject: [PATCH 2/4] Android build setup: Enable flexible page sizes --- android/build.gradle | 4 ++++ android/jni/Application.mk | 1 + 2 files changed, 5 insertions(+) diff --git a/android/build.gradle b/android/build.gradle index e8d3099ac8..a05779baae 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -142,6 +142,7 @@ android { '-DANDROID_PLATFORM=android-16', '-DANDROID_TOOLCHAIN=clang', '-DANDROID_CPP_FEATURES=', + '-DANDROID_SUPPORT_FLEXIBLE_PAGE_SIZES=ON', '-DANDROID_STL=c++_static' } } @@ -161,6 +162,7 @@ android { '-DANDROID_CPP_FEATURES=', '-DANDROID_STL=c++_static', '-DANDROID_ARM_NEON=TRUE', + '-DANDROID_SUPPORT_FLEXIBLE_PAGE_SIZES=ON', '-DGOLD=TRUE' } } @@ -180,6 +182,7 @@ android { '-DANDROID_TOOLCHAIN=clang', '-DANDROID_CPP_FEATURES=', '-DANDROID_STL=c++_static', + '-DANDROID_SUPPORT_FLEXIBLE_PAGE_SIZES=ON', '-DANDROID_LEGACY=TRUE' } } @@ -200,6 +203,7 @@ android { '-DANDROID_CPP_FEATURES=', '-DANDROID_STL=c++_static', '-DANDROID_ARM_NEON=TRUE', + '-DANDROID_SUPPORT_FLEXIBLE_PAGE_SIZES=ON', '-DOPENXR=TRUE', '-DANDROID_LEGACY=TRUE' } diff --git a/android/jni/Application.mk b/android/jni/Application.mk index 9282f31bd4..1dd906f0a1 100644 --- a/android/jni/Application.mk +++ b/android/jni/Application.mk @@ -2,4 +2,5 @@ APP_STL := c++_static APP_PLATFORM := android-9 APP_ABI := arm64-v8a armeabi-v7a x86_64 APP_GNUSTL_CPP_FEATURES := exceptions +APP_SUPPORT_FLEXIBLE_PAGE_SIZES := true NDK_TOOLCHAIN_VERSION := clang From 20491e0077b3fa4c94175c7d67d0e147277845a6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Sun, 5 Jan 2025 17:21:37 +0100 Subject: [PATCH 3/4] Update to the new ARM64 ffmpeg build --- ffmpeg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ffmpeg b/ffmpeg index 82049cca2e..654c7da2cc 160000 --- a/ffmpeg +++ b/ffmpeg @@ -1 +1 @@ -Subproject commit 82049cca2e4c1516ed00a77b502a21f91b7843f4 +Subproject commit 654c7da2ccffc7fd147abbe809aad7ba9e50b0a4 From 2feaeef837b8caf119bdb55b9e4865ce1cac3c77 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Wed, 19 Jun 2024 11:25:32 +0200 Subject: [PATCH 4/4] Add support for 16kb page size on Android --- CMakeLists.txt | 10 +++++++++- Common/Log/LogManager.cpp | 2 +- Common/MemoryUtil.cpp | 7 ++++++- android/build.gradle | 20 +++++++++++++------- android/jni/Locals.mk | 2 ++ build.gradle | 4 ++++ 6 files changed, 35 insertions(+), 10 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 5dc7962c33..8247a34496 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -396,7 +396,7 @@ if(NOT MSVC) # This one is very useful but has many false positives. add_compile_options("$<$:-Wno-class-memaccess>") else() - add_compile_options(-Wno-deprecated-declarations) + add_compile_options(-Wno-deprecated-declarations -Wno-missing-braces) endif() if(ANDROID) @@ -2718,6 +2718,11 @@ set(WindowsFiles Windows/stdafx.h ) +if(ANDROID AND ARM64) + # Support 16kb page size on Android + target_link_options(${CoreLibName} PRIVATE "-Wl,-z,max-page-size=16384") +endif() + list(APPEND LinkCommon ${CoreLibName} ${CMAKE_THREAD_LIBS_INIT}) if(WIN32) @@ -2904,6 +2909,9 @@ if(TargetBin) else() add_executable(${TargetBin} ${NativeAppSource}) endif() + if(ANDROID AND ARM64) + target_link_options(${TargetBin} PRIVATE "-Wl,-z,max-page-size=16384") + endif() target_link_libraries(${TargetBin} ${LinkCommon} Common) endif() diff --git a/Common/Log/LogManager.cpp b/Common/Log/LogManager.cpp index d07e7c381b..3b9a896e28 100644 --- a/Common/Log/LogManager.cpp +++ b/Common/Log/LogManager.cpp @@ -263,7 +263,7 @@ void LogManager::LogLine(LogLevel level, Log type, const char *file, int line, c const char *hostThreadName = GetCurrentThreadName(); if ((hostThreadName && strcmp(hostThreadName, "EmuThread") != 0) || !hleCurrentThreadName) { // Use the host thread name. - threadName = hostThreadName; + threadName = hostThreadName ? hostThreadName : "unknown"; } else { // Use the PSP HLE thread name. threadName = hleCurrentThreadName; diff --git a/Common/MemoryUtil.cpp b/Common/MemoryUtil.cpp index 297290844a..be2a14ddbe 100644 --- a/Common/MemoryUtil.cpp +++ b/Common/MemoryUtil.cpp @@ -352,7 +352,12 @@ int GetMemoryProtectPageSize() { if (sys_info.dwPageSize == 0) GetSystemInfo(&sys_info); return sys_info.dwPageSize; +#else + static int pageSize = 0; + if (!pageSize) { + pageSize = sysconf(_SC_PAGE_SIZE); + } + return pageSize; #endif - return MEM_PAGE_SIZE; } #endif // !PPSSPP_PLATFORM(SWITCH) diff --git a/android/build.gradle b/android/build.gradle index a05779baae..0b23ecbd5d 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -18,7 +18,7 @@ dependencies { // Convenient wrapper around DocumentContract. Might look into writing our own // to see if there's some performance to squeeze at some point, but doubt it. - implementation "androidx.documentfile:documentfile:1.0.1" + implementation "androidx.documentfile:documentfile:1.1.0" } android { @@ -50,6 +50,11 @@ android { ndkVersion "27.2.12479018" + compileOptions { + sourceCompatibility JavaVersion.VERSION_11 + targetCompatibility JavaVersion.VERSION_11 + } + defaultConfig { /* configurations.all { @@ -73,7 +78,7 @@ android { file("versionname.txt").text = androidGitVersion.name() file("versioncode.txt").text = androidGitVersion.code().toString() - minSdk 9 + minSdk 21 targetSdk 35 if (project.hasProperty("ANDROID_VERSION_CODE") && project.hasProperty("ANDROID_VERSION_NAME")) { versionCode ANDROID_VERSION_CODE @@ -139,7 +144,7 @@ android { cmake { // Available arguments listed at https://developer.android.com/ndk/guides/cmake.html arguments '-DANDROID=true', - '-DANDROID_PLATFORM=android-16', + '-DANDROID_PLATFORM=android-21', '-DANDROID_TOOLCHAIN=clang', '-DANDROID_CPP_FEATURES=', '-DANDROID_SUPPORT_FLEXIBLE_PAGE_SIZES=ON', @@ -157,7 +162,7 @@ android { cmake { // Available arguments listed at https://developer.android.com/ndk/guides/cmake.html arguments '-DANDROID=true', - '-DANDROID_PLATFORM=android-16', + '-DANDROID_PLATFORM=android-21', '-DANDROID_TOOLCHAIN=clang', '-DANDROID_CPP_FEATURES=', '-DANDROID_STL=c++_static', @@ -178,7 +183,7 @@ android { cmake { // Available arguments listed at https://developer.android.com/ndk/guides/cmake.html arguments '-DANDROID=true', - '-DANDROID_PLATFORM=android-16', + '-DANDROID_PLATFORM=android-21', '-DANDROID_TOOLCHAIN=clang', '-DANDROID_CPP_FEATURES=', '-DANDROID_STL=c++_static', @@ -198,14 +203,15 @@ android { cmake { // Available arguments listed at https://developer.android.com/ndk/guides/cmake.html arguments '-DANDROID=true', - '-DANDROID_PLATFORM=android-16', + '-DANDROID_PLATFORM=android-21', '-DANDROID_TOOLCHAIN=clang', '-DANDROID_CPP_FEATURES=', '-DANDROID_STL=c++_static', '-DANDROID_ARM_NEON=TRUE', '-DANDROID_SUPPORT_FLEXIBLE_PAGE_SIZES=ON', '-DOPENXR=TRUE', - '-DANDROID_LEGACY=TRUE' + '-DANDROID_LEGACY=TRUE', + '-DANDROID_SUPPORT_FLEXIBLE_PAGE_SIZES=ON' } } ndk { diff --git a/android/jni/Locals.mk b/android/jni/Locals.mk index 6d3b83f52b..0b757e492b 100644 --- a/android/jni/Locals.mk +++ b/android/jni/Locals.mk @@ -68,4 +68,6 @@ ifeq ($(TARGET_ARCH_ABI),arm64-v8a) LOCAL_C_INCLUDES += $(LOCAL_PATH)/../../ffmpeg/android/arm64/include LOCAL_C_INCLUDES += $(LOCAL_PATH)/../../ext/libadrenotools/include LOCAL_C_INCLUDES += $(LOCAL_PATH)/../../ext/libadrenotools/lib/linkernsbypass + + LOCAL_LDFLAGS += "-Wl,-z,max-page-size=16384" endif diff --git a/build.gradle b/build.gradle index ecf0fd7f51..b451c04b31 100644 --- a/build.gradle +++ b/build.gradle @@ -14,4 +14,8 @@ allprojects { google() mavenCentral() } + // The below can be used to show more deprecated stuff in the build output. + // tasks.withType(JavaCompile).configureEach { + // options.compilerArgs << "-Xlint:deprecation" + // } }