Skip to content

Commit e846aa8

Browse files
authored
Merge pull request #19658 from hrydgard/support-16kb-pages
Add support for 16kb page size on Android
2 parents 3d54c52 + 2feaeef commit e846aa8

File tree

8 files changed

+44
-12
lines changed

8 files changed

+44
-12
lines changed

CMakeLists.txt

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -396,7 +396,7 @@ if(NOT MSVC)
396396
# This one is very useful but has many false positives.
397397
add_compile_options("$<$<COMPILE_LANGUAGE:CXX>:-Wno-class-memaccess>")
398398
else()
399-
add_compile_options(-Wno-deprecated-declarations)
399+
add_compile_options(-Wno-deprecated-declarations -Wno-missing-braces)
400400
endif()
401401

402402
if(ANDROID)
@@ -2718,6 +2718,11 @@ set(WindowsFiles
27182718
Windows/stdafx.h
27192719
)
27202720

2721+
if(ANDROID AND ARM64)
2722+
# Support 16kb page size on Android
2723+
target_link_options(${CoreLibName} PRIVATE "-Wl,-z,max-page-size=16384")
2724+
endif()
2725+
27212726
list(APPEND LinkCommon ${CoreLibName} ${CMAKE_THREAD_LIBS_INIT})
27222727

27232728
if(WIN32)
@@ -2904,6 +2909,9 @@ if(TargetBin)
29042909
else()
29052910
add_executable(${TargetBin} ${NativeAppSource})
29062911
endif()
2912+
if(ANDROID AND ARM64)
2913+
target_link_options(${TargetBin} PRIVATE "-Wl,-z,max-page-size=16384")
2914+
endif()
29072915
target_link_libraries(${TargetBin} ${LinkCommon} Common)
29082916
endif()
29092917

Common/Log/LogManager.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ void LogManager::LogLine(LogLevel level, Log type, const char *file, int line, c
263263
const char *hostThreadName = GetCurrentThreadName();
264264
if ((hostThreadName && strcmp(hostThreadName, "EmuThread") != 0) || !hleCurrentThreadName) {
265265
// Use the host thread name.
266-
threadName = hostThreadName;
266+
threadName = hostThreadName ? hostThreadName : "unknown";
267267
} else {
268268
// Use the PSP HLE thread name.
269269
threadName = hleCurrentThreadName;

Common/MemoryUtil.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,12 @@ int GetMemoryProtectPageSize() {
352352
if (sys_info.dwPageSize == 0)
353353
GetSystemInfo(&sys_info);
354354
return sys_info.dwPageSize;
355+
#else
356+
static int pageSize = 0;
357+
if (!pageSize) {
358+
pageSize = sysconf(_SC_PAGE_SIZE);
359+
}
360+
return pageSize;
355361
#endif
356-
return MEM_PAGE_SIZE;
357362
}
358363
#endif // !PPSSPP_PLATFORM(SWITCH)

android/build.gradle

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ dependencies {
1818

1919
// Convenient wrapper around DocumentContract. Might look into writing our own
2020
// to see if there's some performance to squeeze at some point, but doubt it.
21-
implementation "androidx.documentfile:documentfile:1.0.1"
21+
implementation "androidx.documentfile:documentfile:1.1.0"
2222
}
2323

2424
android {
@@ -47,7 +47,14 @@ android {
4747
}
4848

4949
compileSdk 35
50-
ndkVersion "21.4.7075529"
50+
51+
ndkVersion "27.2.12479018"
52+
53+
compileOptions {
54+
sourceCompatibility JavaVersion.VERSION_11
55+
targetCompatibility JavaVersion.VERSION_11
56+
}
57+
5158
defaultConfig {
5259
/*
5360
configurations.all {
@@ -71,7 +78,7 @@ android {
7178
file("versionname.txt").text = androidGitVersion.name()
7279
file("versioncode.txt").text = androidGitVersion.code().toString()
7380

74-
minSdk 9
81+
minSdk 21
7582
targetSdk 35
7683
if (project.hasProperty("ANDROID_VERSION_CODE") && project.hasProperty("ANDROID_VERSION_NAME")) {
7784
versionCode ANDROID_VERSION_CODE
@@ -137,9 +144,10 @@ android {
137144
cmake {
138145
// Available arguments listed at https://developer.android.com/ndk/guides/cmake.html
139146
arguments '-DANDROID=true',
140-
'-DANDROID_PLATFORM=android-16',
147+
'-DANDROID_PLATFORM=android-21',
141148
'-DANDROID_TOOLCHAIN=clang',
142149
'-DANDROID_CPP_FEATURES=',
150+
'-DANDROID_SUPPORT_FLEXIBLE_PAGE_SIZES=ON',
143151
'-DANDROID_STL=c++_static'
144152
}
145153
}
@@ -154,11 +162,12 @@ android {
154162
cmake {
155163
// Available arguments listed at https://developer.android.com/ndk/guides/cmake.html
156164
arguments '-DANDROID=true',
157-
'-DANDROID_PLATFORM=android-16',
165+
'-DANDROID_PLATFORM=android-21',
158166
'-DANDROID_TOOLCHAIN=clang',
159167
'-DANDROID_CPP_FEATURES=',
160168
'-DANDROID_STL=c++_static',
161169
'-DANDROID_ARM_NEON=TRUE',
170+
'-DANDROID_SUPPORT_FLEXIBLE_PAGE_SIZES=ON',
162171
'-DGOLD=TRUE'
163172
}
164173
}
@@ -174,10 +183,11 @@ android {
174183
cmake {
175184
// Available arguments listed at https://developer.android.com/ndk/guides/cmake.html
176185
arguments '-DANDROID=true',
177-
'-DANDROID_PLATFORM=android-16',
186+
'-DANDROID_PLATFORM=android-21',
178187
'-DANDROID_TOOLCHAIN=clang',
179188
'-DANDROID_CPP_FEATURES=',
180189
'-DANDROID_STL=c++_static',
190+
'-DANDROID_SUPPORT_FLEXIBLE_PAGE_SIZES=ON',
181191
'-DANDROID_LEGACY=TRUE'
182192
}
183193
}
@@ -193,13 +203,15 @@ android {
193203
cmake {
194204
// Available arguments listed at https://developer.android.com/ndk/guides/cmake.html
195205
arguments '-DANDROID=true',
196-
'-DANDROID_PLATFORM=android-16',
206+
'-DANDROID_PLATFORM=android-21',
197207
'-DANDROID_TOOLCHAIN=clang',
198208
'-DANDROID_CPP_FEATURES=',
199209
'-DANDROID_STL=c++_static',
200210
'-DANDROID_ARM_NEON=TRUE',
211+
'-DANDROID_SUPPORT_FLEXIBLE_PAGE_SIZES=ON',
201212
'-DOPENXR=TRUE',
202-
'-DANDROID_LEGACY=TRUE'
213+
'-DANDROID_LEGACY=TRUE',
214+
'-DANDROID_SUPPORT_FLEXIBLE_PAGE_SIZES=ON'
203215
}
204216
}
205217
ndk {

android/jni/Application.mk

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@ APP_STL := c++_static
22
APP_PLATFORM := android-9
33
APP_ABI := arm64-v8a armeabi-v7a x86_64
44
APP_GNUSTL_CPP_FEATURES := exceptions
5+
APP_SUPPORT_FLEXIBLE_PAGE_SIZES := true
56
NDK_TOOLCHAIN_VERSION := clang

android/jni/Locals.mk

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,4 +68,6 @@ ifeq ($(TARGET_ARCH_ABI),arm64-v8a)
6868
LOCAL_C_INCLUDES += $(LOCAL_PATH)/../../ffmpeg/android/arm64/include
6969
LOCAL_C_INCLUDES += $(LOCAL_PATH)/../../ext/libadrenotools/include
7070
LOCAL_C_INCLUDES += $(LOCAL_PATH)/../../ext/libadrenotools/lib/linkernsbypass
71+
72+
LOCAL_LDFLAGS += "-Wl,-z,max-page-size=16384"
7173
endif

build.gradle

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,8 @@ allprojects {
1414
google()
1515
mavenCentral()
1616
}
17+
// The below can be used to show more deprecated stuff in the build output.
18+
// tasks.withType(JavaCompile).configureEach {
19+
// options.compilerArgs << "-Xlint:deprecation"
20+
// }
1721
}

0 commit comments

Comments
 (0)