Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 16 Sep 2021 16:07:35 GMT
From:      Steven Kreuzer <skreuzer@FreeBSD.org>
To:        ports-committers@FreeBSD.org, dev-commits-ports-all@FreeBSD.org, dev-commits-ports-main@FreeBSD.org
Subject:   git: a5fa38ea2086 - main - devel/cpu_features: Update to v0.6.0
Message-ID:  <202109161607.18GG7Z1h000704@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch main has been updated by skreuzer:

URL: https://cgit.FreeBSD.org/ports/commit/?id=a5fa38ea20864378fd8c3f3f3b6adfde78cf1d76

commit a5fa38ea20864378fd8c3f3f3b6adfde78cf1d76
Author:     Steven Kreuzer <skreuzer@FreeBSD.org>
AuthorDate: 2021-09-16 16:06:06 +0000
Commit:     Steven Kreuzer <skreuzer@FreeBSD.org>
CommitDate: 2021-09-16 16:07:17 +0000

    devel/cpu_features: Update to v0.6.0
    
    * Update port to v0.6.0
    * Add patches from upstream to:
      * Support FreeBSD on x86 (11994370)
      * Detect Zen 3 CPUs (7ed0b0e5)
---
 devel/cpu_features/Makefile                        |  2 +-
 devel/cpu_features/distinfo                        |  6 +-
 .../files/patch-include_cpu__features__macros.h    | 13 ++++
 .../files/patch-include_cpuinfo__x86.h             | 10 +++
 devel/cpu_features/files/patch-src_cpuinfo__x86.c  | 76 ++++++++++++++++++++++
 devel/cpu_features/pkg-plist                       |  1 -
 6 files changed, 103 insertions(+), 5 deletions(-)

diff --git a/devel/cpu_features/Makefile b/devel/cpu_features/Makefile
index 35a9d8666167..2c2ee5028668 100644
--- a/devel/cpu_features/Makefile
+++ b/devel/cpu_features/Makefile
@@ -1,5 +1,5 @@
 PORTNAME=	cpu_features
-PORTVERSION=	0.5.0
+PORTVERSION=	0.6.0
 DISTVERSIONPREFIX=	v
 CATEGORIES=	devel
 
diff --git a/devel/cpu_features/distinfo b/devel/cpu_features/distinfo
index cb917638c729..e40d46a8fd60 100644
--- a/devel/cpu_features/distinfo
+++ b/devel/cpu_features/distinfo
@@ -1,3 +1,3 @@
-TIMESTAMP = 1611873019
-SHA256 (google-cpu_features-v0.5.0_GH0.tar.gz) = b967811cecd68412e0dc65e4964756a6ae48755456fa2c2f42034f6271ac2c27
-SIZE (google-cpu_features-v0.5.0_GH0.tar.gz) = 61947
+TIMESTAMP = 1631796486
+SHA256 (google-cpu_features-v0.6.0_GH0.tar.gz) = 95a1cf6f24948031df114798a97eea2a71143bd38a4d07d9a758dda3924c1932
+SIZE (google-cpu_features-v0.6.0_GH0.tar.gz) = 63255
diff --git a/devel/cpu_features/files/patch-include_cpu__features__macros.h b/devel/cpu_features/files/patch-include_cpu__features__macros.h
new file mode 100644
index 000000000000..afb5fb2ea3c7
--- /dev/null
+++ b/devel/cpu_features/files/patch-include_cpu__features__macros.h
@@ -0,0 +1,13 @@
+--- include/cpu_features_macros.h.orig	2021-09-16 15:06:15 UTC
++++ include/cpu_features_macros.h
+@@ -83,6 +83,10 @@
+ #define CPU_FEATURES_OS_DARWIN
+ #endif
+ 
++#if (defined(__freebsd__) || defined(__FreeBSD__))
++#define CPU_FEATURES_OS_FREEBSD
++#endif
++
+ ////////////////////////////////////////////////////////////////////////////////
+ // Compilers
+ ////////////////////////////////////////////////////////////////////////////////
diff --git a/devel/cpu_features/files/patch-include_cpuinfo__x86.h b/devel/cpu_features/files/patch-include_cpuinfo__x86.h
new file mode 100644
index 000000000000..e59e56aecb31
--- /dev/null
+++ b/devel/cpu_features/files/patch-include_cpuinfo__x86.h
@@ -0,0 +1,10 @@
+--- include/cpuinfo_x86.h.orig	2021-09-16 15:51:24 UTC
++++ include/cpuinfo_x86.h
+@@ -137,6 +137,7 @@ typedef enum {
+   AMD_BULLDOZER,   // K15
+   AMD_JAGUAR,      // K16
+   AMD_ZEN,         // K17
++  AMD_ZEN3,        // K19
+ } X86Microarchitecture;
+ 
+ // Returns the underlying microarchitecture by looking at X86Info's vendor,
diff --git a/devel/cpu_features/files/patch-src_cpuinfo__x86.c b/devel/cpu_features/files/patch-src_cpuinfo__x86.c
new file mode 100644
index 000000000000..f88cee0a7325
--- /dev/null
+++ b/devel/cpu_features/files/patch-src_cpuinfo__x86.c
@@ -0,0 +1,76 @@
+--- src/cpuinfo_x86.c.orig	2020-10-15 09:09:51 UTC
++++ src/cpuinfo_x86.c
+@@ -97,7 +97,8 @@
+ // microarchitectures.
+ #if defined(CPU_FEATURES_OS_WINDOWS)
+ #include <windows.h>  // IsProcessorFeaturePresent
+-#elif defined(CPU_FEATURES_OS_LINUX_OR_ANDROID)
++#elif defined(CPU_FEATURES_OS_LINUX_OR_ANDROID) || \
++    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
+@@ -1239,6 +1240,45 @@ static void DetectSseViaOs(X86Features* features) {
+   features->ssse3 = GetDarwinSysCtlByName("hw.optional.supplementalsse3");
+   features->sse4_1 = GetDarwinSysCtlByName("hw.optional.sse4_1");
+   features->sse4_2 = GetDarwinSysCtlByName("hw.optional.sse4_2");
++#elif defined(CPU_FEATURES_OS_FREEBSD)
++    // Handling FreeBSD platform through parsing /var/run/dmesg.boot.
++    const int fd = CpuFeatures_OpenFile("/var/run/dmesg.boot");
++    if (fd >= 0) {
++      StackLineReader reader;
++      StackLineReader_Initialize(&reader, fd);
++      for (;;) {
++        const LineResult result = StackLineReader_NextLine(&reader);
++        const StringView line = result.line;
++        const bool is_feature =
++            CpuFeatures_StringView_StartsWith(line, str("  Features="));
++        const bool is_feature2 =
++            CpuFeatures_StringView_StartsWith(line, str("  Features2="));
++        if (is_feature || is_feature2) {
++          // Lines of interests are of the following form:
++          // "  Features=0x1783fbff<PSE36,MMX,FXSR,SSE,SSE2,HTT>"
++          // We replace '<', '>' and ',' with space so we can search by
++          // whitespace separated word.
++          // TODO: Fix CpuFeatures_StringView_HasWord to allow for different
++          // separators.
++          for (size_t i = 0; i < line.size; ++i) {
++            char* c = (char*)(&(line.ptr[i]));
++            if (*c == '<' || *c == '>' || *c == ',') *c = ' ';
++          }
++          if (is_feature) {
++            features->sse = CpuFeatures_StringView_HasWord(line, "SSE");
++            features->sse2 = CpuFeatures_StringView_HasWord(line, "SSE2");
++          }
++          if (is_feature2) {
++            features->sse3 = CpuFeatures_StringView_HasWord(line, "SSE3");
++            features->ssse3 = CpuFeatures_StringView_HasWord(line, "SSSE3");
++            features->sse4_1 = CpuFeatures_StringView_HasWord(line, "SSE4.1");
++            features->sse4_2 = CpuFeatures_StringView_HasWord(line, "SSE4.2");
++          }
++        }
++        if (result.eof) break;
++      }
++      CpuFeatures_CloseFile(fd);
++    }
+ #elif defined(CPU_FEATURES_OS_LINUX_OR_ANDROID)
+   // Handling Linux platform through /proc/cpuinfo.
+   const int fd = CpuFeatures_OpenFile("/proc/cpuinfo");
+@@ -1525,6 +1565,8 @@ X86Microarchitecture GetX86Microarchitecture(const X86
+         return AMD_JAGUAR;
+       case 0x17:
+         return AMD_ZEN;
++      case 0x19:
++        return AMD_ZEN3;
+       default:
+         return X86_UNKNOWN;
+     }
+@@ -1617,6 +1659,8 @@ const char* GetX86MicroarchitectureName(X86Microarchit
+       return "AMD_JAGUAR";
+     case AMD_ZEN:
+       return "AMD_ZEN";
++    case AMD_ZEN3:
++      return "AMD_ZEN3";
+   }
+   return "unknown microarchitecture";
+ }
diff --git a/devel/cpu_features/pkg-plist b/devel/cpu_features/pkg-plist
index 495a3c586cf7..e89c9e3391a6 100644
--- a/devel/cpu_features/pkg-plist
+++ b/devel/cpu_features/pkg-plist
@@ -12,5 +12,4 @@ include/internal/filesystem.h
 include/internal/hwcaps.h
 include/internal/stack_line_reader.h
 include/internal/string_view.h
-include/internal/unix_features_aggregator.h
 lib/libcpu_features.so



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202109161607.18GG7Z1h000704>