Apple Silicon: launch an arm64 process from a Rosetta/x86_64 process

It seems that when suing NSTask to launch an executable from a process running under Rosetta 2, the new process will always run under Rosetta as well, even if the target executable has an arm64 slice.

Is there a way to override/prevent this?

In my concrete case, I have a x86_64 process that is launching debugserver (from inside Xcode 12, which is a fat binary with both x86_64 and arm64 slices) to debug another (arm64) process. In my testing, the exact same command line for debugserver works fine when run from Terminal, but when my process launches it via NSTask, debugserver thinks its target binary is/should be x86_64, and thus fails...

Thoughts?
Use arch -arch arm64 debugserver
Apple Silicon: launch an arm64 process from a Rosetta/x86_64 process
 
 
Q