Skip to content

Commit cda4bea

Browse files
committed
kram - provide hint about installing macOS 15 for avx2 emulation
macOS build apps that can't be updated to universal or arm64 only run x64 emulated portions (even of universal apps). So important to drop x64 everywhere.
1 parent ddad6da commit cda4bea

1 file changed

Lines changed: 23 additions & 4 deletions

File tree

kramc/KramMain.cpp

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
using namespace STL_NAMESPACE;
1212

13+
// These aren't avx2 specific, but just don't want unused func warning
1314
#if SIMD_AVX2
1415
#if KRAM_MAC
1516

@@ -24,6 +25,21 @@ inline const char* getMacOSVersion() {
2425
return str;
2526
}
2627

28+
inline bool isRunningUnderRosetta() {
29+
int ret = 0;
30+
size_t size = sizeof(ret);
31+
if (sysctlbyname("sysctl.proc_translated", &ret, &size, NULL, 0) == -1) {
32+
if (errno == ENOENT) {
33+
// sysctl doesn't exist - not running under Rosetta
34+
return false;
35+
}
36+
// Other error occurred
37+
return false;
38+
}
39+
return ret > 0;
40+
}
41+
42+
2743
inline uint32_t getMacOSMajorVersion() {
2844
// 15.4
2945
static uint32_t majorVersion = 0;
@@ -45,10 +61,10 @@ void checkSimdSupport()
4561

4662
#if SIMD_AVX2
4763
#if KRAM_MAC
48-
// Apple added AVX2 support to Rosetta in macOS 15 with no way
64+
// Apple added AVX2 and F16C? support to Rosetta in macOS 15 with no way
4965
// to detect it. Really awesome, so skip the test. There are
5066
// no supporting Intel hw devices on macOS 15 that don't have AVX2.
51-
//const char* macOSVersion = getMacOSVersion();
67+
// const char* macOSVersion = getMacOSVersion();
5268
// KLOGI("kram", "%s", macOSVersion);
5369
uint32_t majorOSVersions = getMacOSMajorVersion();
5470
if (majorOSVersions >= 15) {
@@ -147,9 +163,12 @@ void checkSimdSupport()
147163
}
148164

149165
if (!hasSimdSupport) {
150-
KLOGE("Main", "Missing simd support for %s%s%s%son %s",
166+
bool isEmulated = isRunningUnderRosetta() && (majorVersion < 15);
167+
const char* emulatedHint = isEmulated ? " install macOS 15.0+" : "";
168+
169+
KLOGE("Main", "Missing simd support for %s%s%s%son %s%s",
151170
missingFeatures[0], missingFeatures[1], missingFeatures[2], missingFeatures[3],
152-
cpuName.data());
171+
cpuName.data(), emulatedHint);
153172
exit(1);
154173
}
155174

0 commit comments

Comments
 (0)