Skip to content
 
 

Latest commit

 

History

70 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

RosettaHack x87

Overview

This is an experimental project that modifies Apple's Rosetta technology to use less precise but significantly faster x87 instruction handlers.

⚠️ Warning: This is not ready for end-users. Use at your own risk.

This fork: recent-macOS detach fix

On recent macOS, the upstream loader crashed the Rosetta'd target with SIGTRAP the instant it detached, so acceleration never ran (worked on older releases). The cause is that PT_DETACH from a breakpoint stop redelivers the stop's pending SIGTRAP to the now-untraced child. This fork changes detach() to first turn the stop into a clean SIGSTOP group-stop (consume the SIGTRAP with PT_CONTINUE, kill(SIGSTOP), PT_DETACH, kill(SIGCONT)), so there is no pending signal to redeliver. Verified: ~10x on the x87 benchmark, correct results, and a 50-second program runs fully detached to completion. See loader/main.cpp detach().

Note: this applies to the ptrace/fork/inject-exports architecture here. The original author's active successor, rosettax87_jit, injects in-process via dlopen and does not use PT_DETACH, so this bug does not apply there.

Prerequisites

  • macOS 14 or later
  • C compiler (clang)
  • CMake

Building

Main Project

cmake -B build
cmake --build build

Sample Test Program

clang -v -arch x86_64 -mno-sse -mfpmath=387 ./sample/math.c -o ./build/math

Running

Run the target program from the build folder:

./rosettax87 ./math

You will see a popup asking you to authorize debugging. Once approved, the process granted debug session. Reference: Debugging tool entitlement

Alternatively (Not Recommended), you can disable Debugging Restrictions part of System Integrity Protection (SIP) by running csrutil enable --without debug in macOS Recovery.

Warning: This reduces system security. NOT recommended.

Technical Details

Windows Applications Through Wine

You can use the brew wine@devel cask with RosettaHack x87. It supports launching Windows applications through Wine with an environment variable ROSETTA_X87_PATH.

  1. Install wine@devel using Homebrew
brew install --cask wine@devel
  1. To permanently set the environment variable, add the following to your ~/.bashrc or ~/.zshrc file:
export ROSETTA_X87_PATH=/Path/To/rosettax87
  1. Run the Windows application
wine PATH_TO_BINARY.exe

License

This project is licensed under MIT.

About

rosettax87 with a fix for the PT_DETACH regression on recent macOS (target no longer killed on detach). Restores x87 acceleration for WoW-on-Apple-Silicon.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages