[PATCH] D84076: [llvm-exegesis] Unset HAVE_LIBPFM if the kernel is too old.

Vy Nguyen via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Jul 17 16:10:28 PDT 2020


oontvoo created this revision.
oontvoo added reviewers: ondrasej, courbet.
Herald added subscribers: llvm-commits, mstojanovic, mgorny.
Herald added a project: LLVM.

Follow up to breakages reported in D77422 <https://reviews.llvm.org/D77422>


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D84076

Files:
  llvm/cmake/modules/FindLibpfm.cmake
  llvm/cmake/modules/check_kernel


Index: llvm/cmake/modules/check_kernel
===================================================================
--- /dev/null
+++ llvm/cmake/modules/check_kernel
@@ -0,0 +1,25 @@
+#! /bin/sh
+# Check whether the local kernel's version is at least a specified version.
+# This is used by llvm/cmake/modules/FindLibpfm.cmake  to check the format
+# of perf_branch_entry struct.
+
+if [[ $# -ne 1 ]] ; then
+   echo "Usage: check_kernel <Version_String>"
+   exit -1
+fi
+
+UNAME_R=`(uname -r) 2>/dev/null` || UNAME_R=unknown
+if [[ $UNAME_R == "unknown" ]]; then
+   exit 1
+fi
+
+VER=`echo $UNAME_R |  awk -F '.'  '{print $1}'`
+MAJOR_VER=`echo $UNAME_R |  awk -F '.'  '{print $2}'`
+
+EXPECTED_VER=`echo $1 | awk -F '.' '{print $1}'`
+EXPECTED_MAJOR_VER=`echo $1 | awk -F '.' '{print $2}'`
+
+if [[ ( "$VER" > "$EXPECTED_VER" ) || ( ( "$VER" == "$EXPECTED_VER" ) && !( "$EXPECTED_MAJOR_VER" > "$MAJOR_VER" ) ) ]]; then
+  exit 0
+fi
+exit 2
Index: llvm/cmake/modules/FindLibpfm.cmake
===================================================================
--- llvm/cmake/modules/FindLibpfm.cmake
+++ llvm/cmake/modules/FindLibpfm.cmake
@@ -16,6 +16,16 @@
     check_include_file(perfmon/pfmlib_perf_event.h HAVE_PERFMON_PFMLIB_PERF_EVENT_H)
     if(HAVE_PERFMON_PERF_EVENT_H AND HAVE_PERFMON_PFMLIB_H AND HAVE_PERFMON_PFMLIB_PERF_EVENT_H)
       set(HAVE_LIBPFM 1)
+      # If the kernel is too old, we can't use it.
+      # 4.3 is the earliest version that has the perf_branch_entry format we need.
+      set(check_kernel ${LLVM_MAIN_SRC_DIR}/cmake/modules/check_kernel)
+      execute_process(COMMAND sh ${check_kernel} 4.3
+        RESULT_VARIABLE TT_RV
+        OUTPUT_VARIABLE TT_OUT
+        OUTPUT_STRIP_TRAILING_WHITESPACE)
+      if( NOT TT_RV EQUAL 0)
+        set(HAVE_LIBPFM 0)
+      endif( NOT TT_RV EQUAL 0)
     endif()
   endif()
 endif()


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D84076.278926.patch
Type: text/x-patch
Size: 1849 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200717/70960adc/attachment.bin>


More information about the llvm-commits mailing list