From 23db1744f11677370d51f04d938b7d19d4daade7 Mon Sep 17 00:00:00 2001 From: Clement Courbet Date: Wed, 11 Apr 2018 07:32:43 +0000 Subject: [PATCH] [llvm-exegesis] Add a flag to disable libpfm even if present. Summary: Fixes PR37053. Reviewers: uabelho, gchatelet Subscribers: mgorny, tschuett, llvm-commits Differential Revision: https://reviews.llvm.org/D45436 llvm-svn: 329781 --- llvm/CMakeLists.txt | 2 ++ llvm/cmake/config-ix.cmake | 16 +++++++++------- llvm/docs/CMake.rst | 5 +++++ llvm/tools/llvm-exegesis/CMakeLists.txt | 3 +-- llvm/unittests/tools/llvm-exegesis/CMakeLists.txt | 3 +-- 5 files changed, 18 insertions(+), 11 deletions(-) diff --git a/llvm/CMakeLists.txt b/llvm/CMakeLists.txt index 087a563..48915c7 100644 --- a/llvm/CMakeLists.txt +++ b/llvm/CMakeLists.txt @@ -366,6 +366,8 @@ set(LLVM_ENABLE_LIBXML2 "ON" CACHE STRING "Use libxml2 if available. Can be ON, option(LLVM_ENABLE_LIBEDIT "Use libedit if available." ON) +option(LLVM_ENABLE_LIBPFM "Use libpfm for performance counters if available." ON) + option(LLVM_ENABLE_THREADS "Use threads if available." ON) option(LLVM_ENABLE_ZLIB "Use zlib for compression/decompression if available." ON) diff --git a/llvm/cmake/config-ix.cmake b/llvm/cmake/config-ix.cmake index ff71ad3..d717d5f 100644 --- a/llvm/cmake/config-ix.cmake +++ b/llvm/cmake/config-ix.cmake @@ -90,13 +90,15 @@ if( NOT PURE_WINDOWS ) endif() # Check for libpfm. -check_library_exists(pfm pfm_initialize "" HAVE_LIBPFM_INITIALIZE) -if(HAVE_LIBPFM_INITIALIZE) - check_include_file(perfmon/perf_event.h HAVE_PERFMON_PERF_EVENT_H) - check_include_file(perfmon/pfmlib.h HAVE_PERFMON_PFMLIB_H) - 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 (LLVM_ENABLE_LIBPFM) + check_library_exists(pfm pfm_initialize "" HAVE_LIBPFM_INITIALIZE) + if(HAVE_LIBPFM_INITIALIZE) + check_include_file(perfmon/perf_event.h HAVE_PERFMON_PERF_EVENT_H) + check_include_file(perfmon/pfmlib.h HAVE_PERFMON_PFMLIB_H) + 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) + endif() endif() endif() diff --git a/llvm/docs/CMake.rst b/llvm/docs/CMake.rst index b3fa4b4..e4da0a67 100644 --- a/llvm/docs/CMake.rst +++ b/llvm/docs/CMake.rst @@ -374,6 +374,11 @@ LLVM-specific variables **LLVM_USE_INTEL_JITEVENTS**:BOOL Enable building support for Intel JIT Events API. Defaults to OFF. +**LLVM_ENABLE_LIBPFM**:BOOL + Enable building with libpfm to support hardware counter measurements in LLVM + tools. + Defaults to ON. + **LLVM_ENABLE_ZLIB**:BOOL Enable building with zlib to support compression/uncompression in LLVM tools. Defaults to ON. diff --git a/llvm/tools/llvm-exegesis/CMakeLists.txt b/llvm/tools/llvm-exegesis/CMakeLists.txt index 9d6b0c3..def182b 100644 --- a/llvm/tools/llvm-exegesis/CMakeLists.txt +++ b/llvm/tools/llvm-exegesis/CMakeLists.txt @@ -10,7 +10,6 @@ add_llvm_tool(llvm-exegesis add_subdirectory(lib) target_link_libraries(llvm-exegesis PRIVATE LLVMExegesis) -if(HAVE_LIBPFM) +if(LLVM_ENABLE_LIBPFM AND HAVE_LIBPFM) target_link_libraries(llvm-exegesis PRIVATE pfm) endif() - diff --git a/llvm/unittests/tools/llvm-exegesis/CMakeLists.txt b/llvm/unittests/tools/llvm-exegesis/CMakeLists.txt index bc376e0..a6b1d87 100644 --- a/llvm/unittests/tools/llvm-exegesis/CMakeLists.txt +++ b/llvm/unittests/tools/llvm-exegesis/CMakeLists.txt @@ -22,7 +22,6 @@ add_llvm_unittest(LLVMExegesisTests ) target_link_libraries(LLVMExegesisTests PRIVATE LLVMExegesis) -if(HAVE_LIBPFM) +if(LLVM_ENABLE_LIBPFM AND HAVE_LIBPFM) target_link_libraries(LLVMExegesisTests PRIVATE pfm) endif() - -- 2.7.4