Skip to contentSkip to conversation

perf: Ensure we use CFLAGS and LDFLAGS settings from kernel build system

PATCH In review Otavio Salvador 2 participants 2 messages Sep 17, 2013

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 perf: Ensure we use CFLAGS and LDFLAGS settings from kernel build system

The kernel build system does the right thing here and we should stop overriding it. This code has been added based on a change from 'meta-metro' layer, revision 9d698004137c1a888d40d6a4808d94afa22387e7, without any information about what problem it fixes so I am reverting it.

Using the CFLAGS and LDFLAGS makes it impossible for kernel build system to append to it, thus making the build fail in various ways as:

|     CC /.../perf/1.0-r8/perf-1.0/perf.o
| In file included from builtin.h:4:0,
|                  from perf.c:9:
| util/util.h:74:24: fatal error: lk/debugfs.h: No such file or directory
|  #include <lk/debugfs.h>
|                         ^
| compilation terminated.

The unset is done in do_compile and do_install otherwise it /rebuild/ perf as it detects the compiler options has change.

---
Changes in v2:
- unset CFLAGS and LDFLAGS
- reword commit log

 meta/recipes-kernel/perf/perf.bb | 11 ++++-------
 1 file changed, 4 insertions(+), 7 deletions(-)
meta/recipes-kernel/perf/perf.bb +4 -7
index d2c1048..4a815ff 100644
@@ -60,7 +60,6 @@ B = "${WORKDIR}/${BPN}-${PV}"
 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)}"
 
-export LDFLAGS = "-ldl -lutil"
 EXTRA_OEMAKE = \
 		'-C ${S}/tools/perf \
 		O=${B} \
@@ -72,13 +71,7 @@ EXTRA_OEMAKE = \
 		NO_GTK2=1 ${TUI_DEFINES} NO_DWARF=1 ${SCRIPTING_DEFINES} \
 		'
 
-# We already pass the correct arguments to our compiler for the CFLAGS (if we
-# don't override it, it'll add -m32/-m64 itself). For LDFLAGS, it was failing
-# to find bfd symbols.
 EXTRA_OEMAKE += "\
-	'CFLAGS=${CFLAGS} -fPIC' \
-	'LDFLAGS=${LDFLAGS} -lpthread -lrt -lelf -lm -lbfd' \
-	\
 	'prefix=${prefix}' \
 	'bindir=${bindir}' \
 	'sharedir=${datadir}' \
@@ -94,10 +87,14 @@ EXTRA_OEMAKE += "\
 PARALLEL_MAKE = ""
 
 do_compile() {
+	# Linux kernel build system is expected to do the right thing
+	unset CFLAGS LDFLAGS
 	oe_runmake all
 }
 
 do_install() {
+	# Linux kernel build system is expected to do the right thing
+	unset CFLAGS LDFLAGS
 	oe_runmake DESTDIR=${D} 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" -a $(grep install-python_ext ${S}/tools/perf/Makefile) = "0"]; then
Signature · 1 line
1.8.4.rc3
Acked-by on v2 1/1
#1 lore raw
Quoted 17 lines · Otavio Salvador

The kernel build system does the right thing here and we should stop overriding it. This code has been added based on a change from 'meta-metro' layer, revision 9d698004137c1a888d40d6a4808d94afa22387e7, without any information about what problem it fixes so I am reverting it.

Using the CFLAGS and LDFLAGS makes it impossible for kernel build system to append to it, thus making the build fail in various ways as:

|     CC /.../perf/1.0-r8/perf-1.0/perf.o
| In file included from builtin.h:4:0,
|                  from perf.c:9:
| util/util.h:74:24: fatal error: lk/debugfs.h: No such file or directory
|  #include <lk/debugfs.h>
|                         ^
| compilation terminated.
Quoted 2 lines

The unset is done in do_compile and do_install otherwise it /rebuild/ perf as it detects the compiler options has change.

Confirmed. I was able to build perf for qemux8-64 with this change in place.

Quoted 52 lines

---
Changes in v2:
- unset CFLAGS and LDFLAGS
- reword commit log

  meta/recipes-kernel/perf/perf.bb | 11 ++++-------
  1 file changed, 4 insertions(+), 7 deletions(-)
meta/recipes-kernel/perf/perf.bb +4 -7
index d2c1048..4a815ff 100644
@@ -60,7 +60,6 @@ B = "${WORKDIR}/${BPN}-${PV}"
  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)}"
 
-export LDFLAGS = "-ldl -lutil"
  EXTRA_OEMAKE = \
  		'-C ${S}/tools/perf \
  		O=${B} \
@@ -72,13 +71,7 @@ EXTRA_OEMAKE = \
  		NO_GTK2=1 ${TUI_DEFINES} NO_DWARF=1 ${SCRIPTING_DEFINES} \
  		'
 
-# We already pass the correct arguments to our compiler for the CFLAGS (if we
-# don't override it, it'll add -m32/-m64 itself). For LDFLAGS, it was failing
-# to find bfd symbols.
  EXTRA_OEMAKE += "\
-	'CFLAGS=${CFLAGS} -fPIC' \
-	'LDFLAGS=${LDFLAGS} -lpthread -lrt -lelf -lm -lbfd' \
-	\
  	'prefix=${prefix}' \
  	'bindir=${bindir}' \
  	'sharedir=${datadir}' \
@@ -94,10 +87,14 @@ EXTRA_OEMAKE += "\
  PARALLEL_MAKE = ""
 
  do_compile() {
+	# Linux kernel build system is expected to do the right thing
+	unset CFLAGS LDFLAGS
  	oe_runmake all
  }
 
  do_install() {
+	# Linux kernel build system is expected to do the right thing
+	unset CFLAGS LDFLAGS
  	oe_runmake DESTDIR=${D} 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" -a $(grep install-python_ext ${S}/tools/perf/Makefile) = "0"]; then