[PATCH v8 2/4] tools feature: add support for detecting libpfm4

From: Ian Rogers
Date: Sat Apr 11 2020 - 03:47:05 EST


From: Stephane Eranian <eranian@xxxxxxxxxx>

libpfm4 provides an alternate command line encoding of perf events.

Signed-off-by: Stephane Eranian <eranian@xxxxxxxxxx>
Reviewed-by: Ian Rogers <irogers@xxxxxxxxxx>
---
tools/build/Makefile.feature | 6 ++++--
tools/build/feature/Makefile | 6 +++++-
tools/build/feature/test-libpfm4.c | 9 +++++++++
3 files changed, 18 insertions(+), 3 deletions(-)
create mode 100644 tools/build/feature/test-libpfm4.c

diff --git a/tools/build/Makefile.feature b/tools/build/Makefile.feature
index 3e0c019ef297..0b651171476f 100644
--- a/tools/build/Makefile.feature
+++ b/tools/build/Makefile.feature
@@ -73,7 +73,8 @@ FEATURE_TESTS_BASIC := \
libaio \
libzstd \
disassembler-four-args \
- file-handle
+ file-handle \
+ libpfm4

# FEATURE_TESTS_BASIC + FEATURE_TESTS_EXTRA is the complete list
# of all feature tests
@@ -128,7 +129,8 @@ FEATURE_DISPLAY ?= \
bpf \
libaio \
libzstd \
- disassembler-four-args
+ disassembler-four-args \
+ libpfm4

# Set FEATURE_CHECK_(C|LD)FLAGS-all for all FEATURE_TESTS features.
# If in the future we need per-feature checks/flags for features not
diff --git a/tools/build/feature/Makefile b/tools/build/feature/Makefile
index 621f528f7822..a6eded94a36b 100644
--- a/tools/build/feature/Makefile
+++ b/tools/build/feature/Makefile
@@ -68,7 +68,8 @@ FILES= \
test-llvm-version.bin \
test-libaio.bin \
test-libzstd.bin \
- test-file-handle.bin
+ test-file-handle.bin \
+ test-libpfm4.bin

FILES := $(addprefix $(OUTPUT),$(FILES))

@@ -325,6 +326,9 @@ $(OUTPUT)test-libzstd.bin:
$(OUTPUT)test-file-handle.bin:
$(BUILD)

+$(OUTPUT)test-libpfm4.bin:
+ $(BUILD) -lpfm
+
###############################

clean:
diff --git a/tools/build/feature/test-libpfm4.c b/tools/build/feature/test-libpfm4.c
new file mode 100644
index 000000000000..af49b259459e
--- /dev/null
+++ b/tools/build/feature/test-libpfm4.c
@@ -0,0 +1,9 @@
+// SPDX-License-Identifier: GPL-2.0
+#include <sys/types.h>
+#include <perfmon/pfmlib.h>
+
+int main(void)
+{
+ pfm_initialize();
+ return 0;
+}
--
2.26.0.110.g2183baf09c-goog