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

View file

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