Improve Rosetta detection

Turns out that one of those *.plist files can exist even if Rosetta is
not installed. So let's just try to run an x86_64-darwin binary
directly.
This commit is contained in:
Eelco Dolstra 2022-10-13 11:45:30 -07:00
parent 59a304a9a8
commit 96eb5ef156
1 changed files with 5 additions and 5 deletions

View File

@ -154,12 +154,12 @@ StringSet Settings::getDefaultExtraPlatforms()
// machines. Note that we cant force processes from executing
// x86_64 in aarch64 environments or vice versa since they can
// always exec with their own binary preferences.
if (pathExists("/Library/Apple/System/Library/LaunchDaemons/com.apple.oahd.plist") ||
pathExists("/System/Library/LaunchDaemons/com.apple.oahd.plist")) {
if (std::string{SYSTEM} == "x86_64-darwin")
extraPlatforms.insert("aarch64-darwin");
else if (std::string{SYSTEM} == "aarch64-darwin")
if (std::string{SYSTEM} == "aarch64-darwin") {
if (runProgram(RunOptions {.program = "arch", .args = {"-arch", "x86_64", "/bin/pwd"}, .mergeStderrToStdout = true}).first == 0) {
debug("Rosetta detected");
extraPlatforms.insert("x86_64-darwin");
} else
debug("Rosetta not detected");
}
#endif