Disable the JIT hackery in app store builds

This commit is contained in:
Henrik Rydgård
2024-05-02 20:41:56 +02:00
parent 1f13eaa874
commit f6f45dda0a
5 changed files with 34 additions and 16 deletions
+1 -1
View File
@@ -2850,7 +2850,7 @@ if(IOS AND NOT LIBRETRO)
XCODE_ATTRIBUTE_TARGETED_DEVICE_FAMILY "iPhone/iPad"
XCODE_ATTRIBUTE_CLANG_ENABLE_OBJC_ARC YES
XCODE_ATTRIBUTE_ENABLE_BITCODE NO
XCODE_ATTRIBUTE_DEVELOPMENT_TEAM "97NS59EENG"
XCODE_ATTRIBUTE_DEVELOPMENT_TEAM ${DEVELOPMENT_TEAM_ID}
XCODE_ATTRIBUTE_CODE_SIGN_IDENTITY "Apple Development"
XCODE_ATTRIBUTE_CODE_SIGN_STYLE "Automatic"
)
+8
View File
@@ -1168,6 +1168,14 @@ void Config::Load(const char *iniFileName, const char *controllerIniFilename) {
if (iMaxRecent == 0)
iMaxRecent = 60;
// Fix JIT setting if no longer available.
if (!System_GetPropertyBool(SYSPROP_CAN_JIT)) {
if (iCpuCore == (int)CPUCore::JIT || iCpuCore == (int)CPUCore::JIT_IR) {
WARN_LOG(LOADER, "Forcing JIT off due to unavailablility");
iCpuCore = (int)CPUCore::IR_INTERPRETER;
}
}
if (iMaxRecent > 0) {
private_->ResetRecentIsosThread();
std::lock_guard<std::mutex> guard(private_->recentIsosLock);
+2 -1
View File
@@ -1770,6 +1770,7 @@ void DeveloperToolsScreen::CreateViews() {
bool canUseJit = System_GetPropertyBool(SYSPROP_CAN_JIT);
// iOS can now use JIT on all modes, apparently.
// The bool may come in handy for future non-jit platforms though (UWP XB1?)
// In iOS App Store builds, we disable the JIT.
static const char *cpuCores[] = {"Interpreter", "Dynarec/JIT (recommended)", "IR Interpreter", "JIT using IR"};
PopupMultiChoice *core = list->Add(new PopupMultiChoice(&g_Config.iCpuCore, sy->T("CPU Core"), cpuCores, 0, ARRAY_SIZE(cpuCores), I18NCat::SYSTEM, screenManager()));
@@ -1782,7 +1783,7 @@ void DeveloperToolsScreen::CreateViews() {
core->HideChoice(1);
core->HideChoice(3);
}
// TODO: Enable on more architectures.
// TODO: Enable "JIT using IR" on more architectures.
#if !PPSSPP_ARCH(X86) && !PPSSPP_ARCH(AMD64) && !PPSSPP_ARCH(ARM64)
core->HideChoice(3);
#endif
+3 -1
View File
@@ -1,9 +1,11 @@
# Build script for iOS app store
# Set the development team ID as a DEVTEAM env variable.
mkdir build-ios
pushd build-ios
cmake .. -DIOS_APP_STORE=ON -DCMAKE_TOOLCHAIN_FILE=cmake/Toolchains/ios.cmake -DDEVELOPMENT_TEAM_ID=97NS59EENG -DIOS_PLATFORM=OS -GXcode
cmake .. -DIOS_APP_STORE=ON -DCMAKE_TOOLCHAIN_FILE=cmake/Toolchains/ios.cmake -DDEVELOPMENT_TEAM_ID=$(DEVTEAM) -DIOS_PLATFORM=OS -GXcode
# TODO: Get a MoltenVK somewhere.
#cp ../MoltenVK/iOS/Frameworks/libMoltenVK.dylib PPSSPP.app/Frameworks
popd
+20 -13
View File
@@ -29,6 +29,9 @@
#include "Common/Log.h"
#include "UI/DarwinFileSystemServices.h"
// Compile out all the hackery in app store builds.
#if !PPSSPP_PLATFORM(IOS_APP_STORE)
struct cs_blob_index {
uint32_t type;
uint32_t offset;
@@ -269,6 +272,7 @@ bool jb_enable_ptrace_hack(void) {
return true;
}
#endif
float g_safeInsetLeft = 0.0;
float g_safeInsetRight = 0.0;
@@ -473,23 +477,21 @@ void System_Vibrate(int mode) {
int main(int argc, char *argv[])
{
// Hacky hacks to try to enable JIT by pretending to be a debugger.
csops = reinterpret_cast<decltype(csops)>(dlsym(dlopen(nullptr, RTLD_LAZY), "csops"));
exc_server = reinterpret_cast<decltype(exc_server)>(dlsym(dlopen(NULL, RTLD_LAZY), "exc_server"));
ptrace = reinterpret_cast<decltype(ptrace)>(dlsym(dlopen(NULL, RTLD_LAZY), "ptrace"));
// see https://github.com/hrydgard/ppsspp/issues/11905
// Tried checking for JIT support here with AllocateExecutableMemory and ProtectMemoryPages,
// but it just succeeds, and then fails when you try to execute from it.
// So, we'll just resort to a version check.
version = [[[UIDevice currentDevice] systemVersion] UTF8String];
if (2 != sscanf(version.c_str(), "%d", &g_iosVersionMajor)) {
// Just set it to 14.0 if the parsing fails for whatever reason.
g_iosVersionMajor = 14;
}
#if PPSSPP_PLATFORM(IOS_APP_STORE)
g_jitAvailable = false;
#else
// Hacky hacks to try to enable JIT by pretending to be a debugger.
csops = reinterpret_cast<decltype(csops)>(dlsym(dlopen(nullptr, RTLD_LAZY), "csops"));
exc_server = reinterpret_cast<decltype(exc_server)>(dlsym(dlopen(NULL, RTLD_LAZY), "exc_server"));
ptrace = reinterpret_cast<decltype(ptrace)>(dlsym(dlopen(NULL, RTLD_LAZY), "ptrace"));
// see https://github.com/hrydgard/ppsspp/issues/11905
if (jb_spawn_ptrace_child(argc, argv)) {
INFO_LOG(SYSTEM, "JIT: ptrace() child spawn trick\n");
} else if (jb_has_jit_entitlement()) {
@@ -505,6 +507,11 @@ int main(int argc, char *argv[])
g_jitAvailable = false;
}
// Tried checking for JIT support here with AllocateExecutableMemory and ProtectMemoryPages,
// but it just succeeds, and then fails when you try to execute from it.
// So, we'll just resort to a version check.
// TODO: This seems outdated.
/*
if (g_iosVersionMajor > 14 || (g_iosVersionMajor == 14 && g_iosVersionMinor >= 4)) {
g_jitAvailable = false;
@@ -512,13 +519,13 @@ int main(int argc, char *argv[])
g_jitAvailable = true;
}
*/
PROFILE_INIT();
#endif
// Ignore sigpipe.
if (signal(SIGPIPE, SIG_IGN) == SIG_ERR) {
perror("Unable to ignore SIGPIPE");
}
PROFILE_INIT();
@autoreleasepool {
return UIApplicationMain(argc, argv, NSStringFromClass([PPSSPPUIApplication class]), NSStringFromClass([AppDelegate class]));