master branch broken on Windows and macOS
mscdex opened this issue · 4 comments
mscdex commented
As of cf589a2 view()
is used on all platforms in src/cpuinfo_x86.c
, which causes compilation to fail on Windows on macOS since view()
is defined in internal/string_view.h
, but that header is not included on those platforms.
/cc @gchatelet
mscdex commented
Additionally macOS appears to also choke on this other line that was added in the same commit with:
src/cpuinfo_x86.c:1703:18: error: static_assert expression is not an integral constant expression
_Static_assert(leaves_size == 48, "Leaves must be packed");
^~~~~~~~~~~~~~~~~
mscdex commented
FWIW I'm using the following patches and it seems to fix the aforementioned problems:
diff --git a/deps/cpu_features/src/cpuinfo_x86.c b/deps/cpu_features/src/cpuinfo_x86.c
index 18e88c1..e54edd6 100644
--- a/deps/cpu_features/src/cpuinfo_x86.c
+++ b/deps/cpu_features/src/cpuinfo_x86.c
@@ -102,7 +102,6 @@
defined(CPU_FEATURES_OS_FREEBSD)
#include "internal/filesystem.h" // Needed to parse /proc/cpuinfo
#include "internal/stack_line_reader.h" // Needed to parse /proc/cpuinfo
-#include "internal/string_view.h" // Needed to parse /proc/cpuinfo
#elif defined(CPU_FEATURES_OS_DARWIN)
#if !defined(HAVE_SYSCTLBYNAME)
#error "Darwin needs support for sysctlbyname"
@@ -111,6 +110,7 @@
#else
#error "Unsupported OS"
#endif // CPU_FEATURES_OS
+#include "internal/string_view.h"
////////////////////////////////////////////////////////////////////////////////
// Definitions for CpuId and GetXCR0Eax.
diff --git a/deps/cpu_features/src/cpuinfo_x86.c b/deps/cpu_features/src/cpuinfo_x86.c
index e54edd6..342d62e 100644
--- a/deps/cpu_features/src/cpuinfo_x86.c
+++ b/deps/cpu_features/src/cpuinfo_x86.c
@@ -1700,7 +1700,7 @@ void FillX86BrandString(char brand_string[49]) {
};
const size_t leaves_size = sizeof(leaves);
#if __STDC_VERSION__ >= 201112L
- _Static_assert(leaves_size == 48, "Leaves must be packed");
+ _Static_assert(sizeof(leaves) == 48, "Leaves must be packed");
#endif
CpuFeatures_StringView_CopyString(view((const char*)leaves, leaves_size),
brand_string, 49);