Skip to contentSkip to conversation

perf: use PACKAGECONFIG instead of hand-rolled logic

PATCH In review Ross Burton 2 participants 4 messages Jan 16, 2017

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 perf: use PACKAGECONFIG instead of hand-rolled logic

PERF_FEATURES_ENABLE and perf_feature_enabled() was basically a poor man's clone of PACKAGECONFIG, without the automatic handling of dependencies and configure options.

As part of the port to PACKAGECONFIG the options have been changed to remove the perf- prefix, but are otherwise unchanged.

Also remove BUILDPERF_libc_uclibc assignment as nothing in the metadata uses a BUILDPERF variable.

---
 meta/recipes-kernel/perf/perf-features.inc | 22 ----------------------
 meta/recipes-kernel/perf/perf.bb           | 26 +++++++++-----------------
 2 files changed, 9 insertions(+), 39 deletions(-)
 delete mode 100644 meta/recipes-kernel/perf/perf-features.inc
meta/recipes-kernel/perf/perf-features.inc deleted +0 -22
deleted file mode 100644
index a4402cc..0000000
@@ -1,22 +0,0 @@
-PERF_FEATURES_ENABLE ?= "perf-scripting perf-tui"
-
-def perf_feature_enabled(feature, trueval, falseval, d):
-    """
-    Check which perf features are enabled.
-
-    The PERF_FEATURES_ENABLE variable lists the perf features to
-    enable.  Override it if you want something different from what's
-    listed above, which is the default.  If empty, the build won't
-    enable any features (which may be exactly what you want, just a
-    barebones perf without any extra baggage, what you get if you
-    specify an empty feature list).
-
-    Available perf features:
-      perf-scripting: enable support for Perl and Python bindings
-      perf-tui: enable support for the perf TUI (via libnewt)
-
-    """
-    enabled_features = d.getVar("PERF_FEATURES_ENABLE") or ""
-    if feature in enabled_features:
-        return trueval
-    return falseval
meta/recipes-kernel/perf/perf.bb +9 -17
index cfbe628..8b5028e 100644
@@ -10,24 +10,21 @@ LICENSE = "GPLv2"
 
 PR = "r9"
 
-require perf-features.inc
-
 BUILDPERF_libc-uclibc = "no"
 
+PACKAGECONFIG ??= "scripting tui"
+PACKAGECONFIG[scripting] = ",NO_LIBPERL=1 NO_LIBPYTHON=1,perl python"
 # gui support was added with kernel 3.6.35
 # since 3.10 libnewt was replaced by slang
 # to cover a wide range of kernel we add both dependencies
-TUI_DEPENDS = "${@perf_feature_enabled('perf-tui', 'libnewt slang', '',d)}"
-SCRIPTING_DEPENDS = "${@perf_feature_enabled('perf-scripting', 'perl python', '',d)}"
-LIBUNWIND_DEPENDS = "${@perf_feature_enabled('perf-libunwind', 'libunwind', '',d)}"
+PACKAGECONFIG[tui] = ",NO_NEWT=1,libnewt slang"
+PACKAGECONFIG[libunwind] = ",NO_LIBUNWIND=1 NO_LIBDW_DWARF_UNWIND=1,libunwind"
+PACKAGECONFIG[libnuma] = ",NO_LIBNUMA=1"
 
 DEPENDS = " \
     virtual/${MLPREFIX}libc \
     ${MLPREFIX}elfutils \
     ${MLPREFIX}binutils \
-    ${TUI_DEPENDS} \
-    ${SCRIPTING_DEPENDS} \
-    ${LIBUNWIND_DEPENDS} \
     bison flex xz \
     xmlto-native \
     asciidoc-native \
@@ -61,11 +58,6 @@ inherit kernelsrc
 B = "${WORKDIR}/${BPN}-${PV}"
 SPDX_S = "${S}/tools/perf"
 
-SCRIPTING_DEFINES = "${@perf_feature_enabled('perf-scripting', '', 'NO_LIBPERL=1 NO_LIBPYTHON=1',d)}"
-TUI_DEFINES = "${@perf_feature_enabled('perf-tui', '', 'NO_NEWT=1',d)}"
-LIBUNWIND_DEFINES = "${@perf_feature_enabled('perf-libunwind', '', 'NO_LIBUNWIND=1 NO_LIBDW_DWARF_UNWIND=1',d)}"
-LIBNUMA_DEFINES = "${@perf_feature_enabled('perf-libnuma', '', 'NO_LIBNUMA=1',d)}"
-
 # The LDFLAGS is required or some old kernels fails due missing
 # symbols and this is preferred than requiring patches to every old
 # supported kernel.
@@ -82,8 +74,8 @@ EXTRA_OEMAKE = '\
     EXTRA_CFLAGS="-ldw" \
     EXTRA_LDFLAGS="${PERF_EXTRA_LDFLAGS}" \
     perfexecdir=${libexecdir} \
-    NO_GTK2=1 ${TUI_DEFINES} NO_DWARF=1 ${LIBUNWIND_DEFINES} \
-    ${SCRIPTING_DEFINES} ${LIBNUMA_DEFINES} \
+    NO_GTK2=1 NO_DWARF=1 \
+    ${PACKAGECONFIG_CONFARGS} \
 '
 
 EXTRA_OEMAKE += "\
@@ -116,7 +108,7 @@ do_install() {
 	unset CFLAGS
 	oe_runmake install
 	# we are checking for this make target to be compatible with older perf versions
-	if [ "${@perf_feature_enabled('perf-scripting', 1, 0, d)}" = "1" ] && grep -q install-python_ext ${S}/tools/perf/Makefile*; then
+	if ${@bb.utils.contains('PACKAGECONFIG', 'scripting', 'true', 'false', d)} && grep -q install-python_ext ${S}/tools/perf/Makefile*; then
 		oe_runmake DESTDIR=${D} install-python_ext
 	fi
 }
@@ -225,7 +217,7 @@ RDEPENDS_${PN}-python =+ "bash python python-modules"
 RDEPENDS_${PN}-perl =+ "bash perl perl-modules"
 RDEPENDS_${PN}-tests =+ "python"
 
-RSUGGESTS_SCRIPTING = "${@perf_feature_enabled('perf-scripting', '${PN}-perl ${PN}-python', '',d)}"
+RSUGGESTS_SCRIPTING = "${@bb.utils.contains('PACKAGECONFIG', 'scripting', '${PN}-perl ${PN}-python', '',d)}"
 RSUGGESTS_${PN} += "${PN}-archive ${PN}-tests ${RSUGGESTS_SCRIPTING}"
 
 #FILES_${PN} += "${libexecdir}/perf-core ${exec_prefix}/libexec/perf-core /usr/lib64/traceevent ${libdir}/traceevent"
Signature · 1 line
2.8.1
#1 lore raw

PATCH 2/2 perf: add PACKAGECONFIG for systemtap

Otherwise it's possible to race with systemtap headers being present during the autodetection and disappearing during the build:

tests/sdt.c:14:21: fatal error: sys/sdt.h: No such file or directory

 #include <sys/sdt.h>
                     ^
---
 meta/recipes-kernel/perf/perf.bb | 1 +
 1 file changed, 1 insertion(+)
meta/recipes-kernel/perf/perf.bb +1 -0
index 8b5028e..acbb1d9 100644
@@ -20,6 +20,7 @@ PACKAGECONFIG[scripting] = ",NO_LIBPERL=1 NO_LIBPYTHON=1,perl python"
 PACKAGECONFIG[tui] = ",NO_NEWT=1,libnewt slang"
 PACKAGECONFIG[libunwind] = ",NO_LIBUNWIND=1 NO_LIBDW_DWARF_UNWIND=1,libunwind"
 PACKAGECONFIG[libnuma] = ",NO_LIBNUMA=1"
+PACKAGECONFIG[systemtap] = ",NO_SDT=1,systemtap"
 
 DEPENDS = " \
     virtual/${MLPREFIX}libc \
Signature · 1 line
2.8.1
Acked-by on v1 1/2
#3 lore raw
In reply to Ross Burton
Quoted 3 lines · Ross Burton

PERF_FEATURES_ENABLE and perf_feature_enabled() was basically a poor man's clone of PACKAGECONFIG, without the automatic handling of dependencies and configure options.

I think some of the parts pre-dated packageconfig capabilities, but yah, something that needed to get tossed in the bin.

Quoted 6 lines

As part of the port to PACKAGECONFIG the options have been changed to remove the perf- prefix, but are otherwise unchanged.

Also remove BUILDPERF_libc_uclibc assignment as nothing in the metadata uses a BUILDPERF variable.

I applied the patches here, and was able to build a perf in my standard config.

Bruce

Quoted 112 lines
---
 meta/recipes-kernel/perf/perf-features.inc | 22 ----------------------
 meta/recipes-kernel/perf/perf.bb           | 26 +++++++++-----------------
 2 files changed, 9 insertions(+), 39 deletions(-)
 delete mode 100644 meta/recipes-kernel/perf/perf-features.inc
meta/recipes-kernel/perf/perf-features.inc deleted +0 -22
deleted file mode 100644
index a4402cc..0000000
@@ -1,22 +0,0 @@
-PERF_FEATURES_ENABLE ?= "perf-scripting perf-tui"
-
-def perf_feature_enabled(feature, trueval, falseval, d):
-    """
-    Check which perf features are enabled.
-
-    The PERF_FEATURES_ENABLE variable lists the perf features to
-    enable.  Override it if you want something different from what's
-    listed above, which is the default.  If empty, the build won't
-    enable any features (which may be exactly what you want, just a
-    barebones perf without any extra baggage, what you get if you
-    specify an empty feature list).
-
-    Available perf features:
-      perf-scripting: enable support for Perl and Python bindings
-      perf-tui: enable support for the perf TUI (via libnewt)
-
-    """
-    enabled_features = d.getVar("PERF_FEATURES_ENABLE") or ""
-    if feature in enabled_features:
-        return trueval
-    return falseval
meta/recipes-kernel/perf/perf.bb +9 -17
index cfbe628..8b5028e 100644
@@ -10,24 +10,21 @@ LICENSE = "GPLv2"
 
 PR = "r9"
 
-require perf-features.inc
-
 BUILDPERF_libc-uclibc = "no"
 
+PACKAGECONFIG ??= "scripting tui"
+PACKAGECONFIG[scripting] = ",NO_LIBPERL=1 NO_LIBPYTHON=1,perl python"
 # gui support was added with kernel 3.6.35
 # since 3.10 libnewt was replaced by slang
 # to cover a wide range of kernel we add both dependencies
-TUI_DEPENDS = "${@perf_feature_enabled('perf-tui', 'libnewt slang', '',d)}"
-SCRIPTING_DEPENDS = "${@perf_feature_enabled('perf-scripting', 'perl python', '',d)}"
-LIBUNWIND_DEPENDS = "${@perf_feature_enabled('perf-libunwind', 'libunwind', '',d)}"
+PACKAGECONFIG[tui] = ",NO_NEWT=1,libnewt slang"
+PACKAGECONFIG[libunwind] = ",NO_LIBUNWIND=1 NO_LIBDW_DWARF_UNWIND=1,libunwind"
+PACKAGECONFIG[libnuma] = ",NO_LIBNUMA=1"
 
 DEPENDS = " \
     virtual/${MLPREFIX}libc \
     ${MLPREFIX}elfutils \
     ${MLPREFIX}binutils \
-    ${TUI_DEPENDS} \
-    ${SCRIPTING_DEPENDS} \
-    ${LIBUNWIND_DEPENDS} \
     bison flex xz \
     xmlto-native \
     asciidoc-native \
@@ -61,11 +58,6 @@ inherit kernelsrc
 B = "${WORKDIR}/${BPN}-${PV}"
 SPDX_S = "${S}/tools/perf"
 
-SCRIPTING_DEFINES = "${@perf_feature_enabled('perf-scripting', '', 'NO_LIBPERL=1 NO_LIBPYTHON=1',d)}"
-TUI_DEFINES = "${@perf_feature_enabled('perf-tui', '', 'NO_NEWT=1',d)}"
-LIBUNWIND_DEFINES = "${@perf_feature_enabled('perf-libunwind', '', 'NO_LIBUNWIND=1 NO_LIBDW_DWARF_UNWIND=1',d)}"
-LIBNUMA_DEFINES = "${@perf_feature_enabled('perf-libnuma', '', 'NO_LIBNUMA=1',d)}"
-
 # The LDFLAGS is required or some old kernels fails due missing
 # symbols and this is preferred than requiring patches to every old
 # supported kernel.
@@ -82,8 +74,8 @@ EXTRA_OEMAKE = '\
     EXTRA_CFLAGS="-ldw" \
     EXTRA_LDFLAGS="${PERF_EXTRA_LDFLAGS}" \
     perfexecdir=${libexecdir} \
-    NO_GTK2=1 ${TUI_DEFINES} NO_DWARF=1 ${LIBUNWIND_DEFINES} \
-    ${SCRIPTING_DEFINES} ${LIBNUMA_DEFINES} \
+    NO_GTK2=1 NO_DWARF=1 \
+    ${PACKAGECONFIG_CONFARGS} \
 '
 
 EXTRA_OEMAKE += "\
@@ -116,7 +108,7 @@ do_install() {
 	unset CFLAGS
 	oe_runmake install
 	# we are checking for this make target to be compatible with older perf versions
-	if [ "${@perf_feature_enabled('perf-scripting', 1, 0, d)}" = "1" ] && grep -q install-python_ext ${S}/tools/perf/Makefile*; then
+	if ${@bb.utils.contains('PACKAGECONFIG', 'scripting', 'true', 'false', d)} && grep -q install-python_ext ${S}/tools/perf/Makefile*; then
 		oe_runmake DESTDIR=${D} install-python_ext
 	fi
 }
@@ -225,7 +217,7 @@ RDEPENDS_${PN}-python =+ "bash python python-modules"
 RDEPENDS_${PN}-perl =+ "bash perl perl-modules"
 RDEPENDS_${PN}-tests =+ "python"
 
-RSUGGESTS_SCRIPTING = "${@perf_feature_enabled('perf-scripting', '${PN}-perl ${PN}-python', '',d)}"
+RSUGGESTS_SCRIPTING = "${@bb.utils.contains('PACKAGECONFIG', 'scripting', '${PN}-perl ${PN}-python', '',d)}"
 RSUGGESTS_${PN} += "${PN}-archive ${PN}-tests ${RSUGGESTS_SCRIPTING}"
 
 #FILES_${PN} += "${libexecdir}/perf-core ${exec_prefix}/libexec/perf-core /usr/lib64/traceevent ${libdir}/traceevent"
#2 lore raw

Re: [PATCH 2/2] perf: add PACKAGECONFIG for systemtap

In reply to Ross Burton
Quoted 8 lines · Ross Burton

Otherwise it's possible to race with systemtap headers being present during the autodetection and disappearing during the build:

tests/sdt.c:14:21: fatal error: sys/sdt.h: No such file or directory

 #include <sys/sdt.h>
                     ^

A deja-vu signed-off-by!

Bruce

Quoted 17 lines
---
 meta/recipes-kernel/perf/perf.bb | 1 +
 1 file changed, 1 insertion(+)
meta/recipes-kernel/perf/perf.bb +1 -0
index 8b5028e..acbb1d9 100644
@@ -20,6 +20,7 @@ PACKAGECONFIG[scripting] = ",NO_LIBPERL=1 NO_LIBPYTHON=1,perl python"
 PACKAGECONFIG[tui] = ",NO_NEWT=1,libnewt slang"
 PACKAGECONFIG[libunwind] = ",NO_LIBUNWIND=1 NO_LIBDW_DWARF_UNWIND=1,libunwind"
 PACKAGECONFIG[libnuma] = ",NO_LIBNUMA=1"
+PACKAGECONFIG[systemtap] = ",NO_SDT=1,systemtap"
 
 DEPENDS = " \
     virtual/${MLPREFIX}libc \