All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCHv2 1/3] perf: unwind: pass symbol source to libunwind
@ 2015-10-29  7:49 Rabin Vincent
  2015-10-29  7:49 ` [PATCHv2 2/3] tools: build: fix libiberty feature detection Rabin Vincent
                   ` (2 more replies)
  0 siblings, 3 replies; 9+ messages in thread
From: Rabin Vincent @ 2015-10-29  7:49 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: jolsa, namhyung, Ingo Molnar, Peter Zijlstra, linux-kernel,
	Rabin Vincent

Even if --symfs is used to point to the debug binaries, we send in the
non-debug filenames to libunwind, which leads to libunwind not finding
the debug frame.  Fix this by preferring the file in --symfs, if it is
available.

Signed-off-by: Rabin Vincent <rabin.vincent@axis.com>
---
v2: fall back to ->name if ->symsrc_filename is NULL

 tools/perf/util/unwind-libunwind.c |    5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/tools/perf/util/unwind-libunwind.c b/tools/perf/util/unwind-libunwind.c
index f729f9e..c83832b 100644
--- a/tools/perf/util/unwind-libunwind.c
+++ b/tools/perf/util/unwind-libunwind.c
@@ -360,12 +360,15 @@ find_proc_info(unw_addr_space_t as, unw_word_t ip, unw_proc_info_t *pi,
 		int fd = dso__data_get_fd(map->dso, ui->machine);
 		int is_exec = elf_is_exec(fd, map->dso->name);
 		unw_word_t base = is_exec ? 0 : map->start;
+		const char *symfile;
 
 		if (fd >= 0)
 			dso__data_put_fd(map->dso);
 
+		symfile = map->dso->symsrc_filename ?: map->dso->name;
+
 		memset(&di, 0, sizeof(di));
-		if (dwarf_find_debug_frame(0, &di, ip, base, map->dso->name,
+		if (dwarf_find_debug_frame(0, &di, ip, base, symfile,
 					   map->start, map->end))
 			return dwarf_search_unwind_table(as, ip, &di, pi,
 							 need_unwind_info, arg);
-- 
1.7.10.4


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCHv2 2/3] tools: build: fix libiberty feature detection
  2015-10-29  7:49 [PATCHv2 1/3] perf: unwind: pass symbol source to libunwind Rabin Vincent
@ 2015-10-29  7:49 ` Rabin Vincent
  2015-10-29 20:45   ` Jiri Olsa
  2015-10-30  9:14   ` [tip:perf/core] tools build: Fix " tip-bot for Rabin Vincent
  2015-10-29  7:49 ` [PATCHv2 3/3] perf: add helper makefile for cross compiling libs Rabin Vincent
  2015-10-30  9:15 ` [tip:perf/core] perf unwind: Pass symbol source to libunwind tip-bot for Rabin Vincent
  2 siblings, 2 replies; 9+ messages in thread
From: Rabin Vincent @ 2015-10-29  7:49 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: jolsa, namhyung, Ingo Molnar, Peter Zijlstra, linux-kernel,
	Rabin Vincent

Any CFLAGS or LDFLAGS set by the user need to be passed to the feature build
command.  This many include for example -I or -L to point to libraries and
include files in custom paths.

In most of the test-*.bin rules in build/feature/Makefile, we use the BUILD
macro which always sends in CFLAGS and LDFLAGS.  The libiberty build line
however doesn't use the BUILD macro and thus needs to send in CFLAGS and
LDFLAGS explicitly.  Without this, when using custom CFLAGS/LDFLAGS, libiberty
fails to be detected and the perf link fails with something like:

  LINK     perf
 libbfd.a(bfd.o): In function `bfd_errmsg':
 bfd.c:(.text+0x168): undefined reference to `xstrerror'
 bbfd.a(opncls.o): In function `_bfd_new_bfd':
 opncls.c:(.text+0xe8): undefined reference to `objalloc_create'
 ...

Signed-off-by: Rabin Vincent <rabin.vincent@axis.com>
---
v2: rewrite commit message

 tools/build/feature/Makefile |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/tools/build/feature/Makefile b/tools/build/feature/Makefile
index e43a297..cea04ce9 100644
--- a/tools/build/feature/Makefile
+++ b/tools/build/feature/Makefile
@@ -132,10 +132,10 @@ test-libbfd.bin:
 	$(BUILD) -DPACKAGE='"perf"' -lbfd -lz -liberty -ldl
 
 test-liberty.bin:
-	$(CC) -Wall -Werror -o $(OUTPUT)$@ test-libbfd.c -DPACKAGE='"perf"' -lbfd -ldl -liberty
+	$(CC) $(CFLAGS) -Wall -Werror -o $(OUTPUT)$@ test-libbfd.c -DPACKAGE='"perf"' $(LDFLAGS) -lbfd -ldl -liberty
 
 test-liberty-z.bin:
-	$(CC) -Wall -Werror -o $(OUTPUT)$@ test-libbfd.c -DPACKAGE='"perf"' -lbfd -ldl -liberty -lz
+	$(CC) $(CFLAGS) -Wall -Werror -o $(OUTPUT)$@ test-libbfd.c -DPACKAGE='"perf"' $(LDFLAGS) -lbfd -ldl -liberty -lz
 
 test-cplus-demangle.bin:
 	$(BUILD) -liberty
-- 
1.7.10.4


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCHv2 3/3] perf: add helper makefile for cross compiling libs
  2015-10-29  7:49 [PATCHv2 1/3] perf: unwind: pass symbol source to libunwind Rabin Vincent
  2015-10-29  7:49 ` [PATCHv2 2/3] tools: build: fix libiberty feature detection Rabin Vincent
@ 2015-10-29  7:49 ` Rabin Vincent
  2015-10-29  9:46   ` Ingo Molnar
  2015-10-30  9:15 ` [tip:perf/core] perf unwind: Pass symbol source to libunwind tip-bot for Rabin Vincent
  2 siblings, 1 reply; 9+ messages in thread
From: Rabin Vincent @ 2015-10-29  7:49 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: jolsa, namhyung, Ingo Molnar, Peter Zijlstra, linux-kernel,
	Rabin Vincent

It's easy to cross-compile a minimal perf binary without any external
libraries (other than a C library of course).  But many useful features
depend on external libraries, so to get them one needs to either
cross-compile a bunch of libraries manually and send in the correct
paths or integrate the perf build into some external build system.

In order to make it easier for people to qucikly get up and running with
a fairly full featured cross-compiled mainline perf, provide a helper makefile
which can be used to download and build the required libraries, which can then
be used in a static build of perf.

For example, assuming an arm-linux-gcc cross-compiler is present in the
PATH, the following is what one seens if one tries to build a static
perf for ARM:

 $ make ARCH=arm CROSS_COMPILE=arm-linux- LDFLAGS="-static"

 Auto-detecting system features:
 ...                         dwarf: [ OFF ]
 ...                         glibc: [ on  ]
 ...                          gtk2: [ OFF ]
 ...                      libaudit: [ OFF ]
 ...                        libbfd: [ OFF ]
 ...                        libelf: [ OFF ]
 ...                       libnuma: [ OFF ]
 ...        numa_num_possible_cpus: [ OFF ]
 ...                       libperl: [ OFF ]
 ...                     libpython: [ OFF ]
 ...                      libslang: [ OFF ]
 ...                     libunwind: [ OFF ]
 ...            libdw-dwarf-unwind: [ OFF ]
 ...                          zlib: [ OFF ]
 ...                          lzma: [ OFF ]
 ...                     get_cpuid: [ OFF ]

By using the new Makefile.cross first, we get many important features:

 $ make ARCH=arm CROSS_COMPILE=arm-linux- -f Makefile.cross
 $ make ARCH=arm CROSS_COMPILE=arm-linux- LDFLAGS="-static"

  Auto-detecting system features:
  ...                         dwarf: [ on  ]
  ...                         glibc: [ on  ]
  ...                          gtk2: [ OFF ]
  ...                      libaudit: [ on  ]
  ...                        libbfd: [ on  ]
  ...                        libelf: [ on  ]
  ...                       libnuma: [ OFF ]
  ...        numa_num_possible_cpus: [ OFF ]
  ...                       libperl: [ OFF ]
  ...                     libpython: [ OFF ]
  ...                      libslang: [ on  ]
  ...                     libunwind: [ on  ]
  ...            libdw-dwarf-unwind: [ OFF ]
  ...                          zlib: [ on  ]
  ...                          lzma: [ on  ]
  ...                     get_cpuid: [ OFF ]

Signed-off-by: Rabin Vincent <rabin.vincent@axis.com>
---
v2: expand commit message, add comments in Makefile, rename to Makefile.cross

 tools/perf/Makefile.cross |  154 +++++++++++++++++++++++++++++++++++++++++++++
 tools/perf/Makefile.perf  |    7 +++
 2 files changed, 161 insertions(+)
 create mode 100644 tools/perf/Makefile.cross

diff --git a/tools/perf/Makefile.cross b/tools/perf/Makefile.cross
new file mode 100644
index 0000000..95dd28a
--- /dev/null
+++ b/tools/perf/Makefile.cross
@@ -0,0 +1,154 @@
+#
+# This is a helper Makefile that downloads and builds many of the optional
+# libraries that perf can use.  This libraries built by this Makefile can be
+# subsequently used in a static build of perf.  The intented use is when cross
+# compiling perf.
+#
+# For example, assuming you have the arm-linux-gcc cross compiler in your PATH,
+# running the following two commands will result in a static ARM build of perf
+# with various features that require external libraries:
+#
+# $ make ARCH=arm CROSS_COMPILE=arm-linux- -f Makefile.cross
+# $ make ARCH=arm CROSS_COMPILE=arm-linux- LDFLAGS="-static"
+#
+
+LIBS += audit
+audit_BASENAME=audit-2.4.4
+audit_ARCHIVE=$(audit_BASENAME).tar.gz
+audit_URL=https://people.redhat.com/sgrubb/audit/$(audit_ARCHIVE)
+
+LIBS += bfd
+bfd_BASENAME=binutils-2.25.1
+bfd_ARCHIVE=$(bfd_BASENAME).tar.bz2
+bfd_URL=http://ftp.gnu.org/gnu/binutils/$(bfd_ARCHIVE)
+
+LIBS += bzip2
+bzip2_BASENAME=bzip2-1.0.6
+bzip2_ARCHIVE=$(bzip2_BASENAME).tar.gz
+bzip2_URL=http://www.bzip.org/1.0.6/$(bzip2_ARCHIVE)
+
+LIBS += elfutils
+elfutils_BASENAME=elfutils-0.163
+elfutils_ARCHIVE=$(elfutils_BASENAME).tar.bz2
+elfutils_URL=https://fedorahosted.org/releases/e/l/elfutils/0.163/$(elfutils_ARCHIVE)
+
+LIBS += lzma
+lzma_BASENAME=xz-5.2.1
+lzma_ARCHIVE=$(lzma_BASENAME).tar.gz
+lzma_URL=http://tukaani.org/xz/$(lzma_ARCHIVE)
+
+LIBS += slang
+slang_BASENAME=slang-2.1.4
+slang_ARCHIVE=$(slang_BASENAME).tar.bz2
+slang_URL=http://ftp.ntua.gr/pub/lang/slang/slang/v2.1/$(slang_ARCHIVE)
+
+LIBS += unwind
+unwind_BASENAME=libunwind-1.1
+unwind_ARCHIVE=$(unwind_BASENAME).tar.gz
+unwind_URL=http://download.savannah.gnu.org/releases/libunwind/$(unwind_ARCHIVE)
+
+LIBS += zlib
+zlib_BASENAME=zlib-1.2.8
+zlib_ARCHIVE=$(zlib_BASENAME).tar.gz
+zlib_URL=http://zlib.net/$(zlib_ARCHIVE)
+
+DLDIR=dl
+DEPSDIR=deps-$(ARCH)
+BUILDDIR=build-$(ARCH)
+HOST=$(shell echo $(CROSS_COMPILE) | sed 's/.$$//')
+PREFIX=$(realpath $(shell pwd))/$(DEPSDIR)
+MAKE1=$(MAKE) -j1
+
+CC=$(CROSS_COMPILE)gcc
+
+export CC
+
+.PHONY: all clean $(LIBS)
+
+all: $(LIBS)
+
+define LIB_template
+$1_DIR=$$(BUILDDIR)/$$($1_BASENAME)
+$1_EXTRACT=$$($1_DIR)/.extract
+$1_INSTALL=$$(DEPSDIR)/lib/.$1.install
+
+$$(DLDIR)/$$($1_ARCHIVE):
+	mkdir -p $$(DLDIR) && cd $$(DLDIR) && wget -N $$($1_URL)
+
+$$($1_EXTRACT): $$(DLDIR)/$$($1_ARCHIVE)
+	mkdir -p $$(BUILDDIR) && tar xf $$< -C $$(BUILDDIR)
+	touch $$@
+
+$1: $$($1_INSTALL)
+
+$1-clean:
+	rm -rf $$($1_DIR)
+endef
+
+$(foreach lib,$(LIBS),$(eval $(call LIB_template,$(lib))))
+
+$(audit_INSTALL): $(audit_EXTRACT)
+	cd $(audit_DIR) && ./configure --host=$(HOST) --prefix=$(PREFIX)
+	$(MAKE) -C $(audit_DIR)/lib
+	$(MAKE) -C $(audit_DIR)/lib install
+	touch $@
+
+CFLAGS=-I$(PREFIX)/include
+LDFLAGS=-L$(PREFIX)/lib
+
+$(bfd_INSTALL): $(zlib_INSTALL) $(bfd_EXTRACT)
+	cd $(bfd_DIR)/libiberty && ./configure --host=$(HOST) --prefix=$(PREFIX) --enable-install-libiberty
+	$(MAKE) -C $(bfd_DIR)/libiberty
+	$(MAKE) -C $(bfd_DIR)/libiberty install
+	cd $(bfd_DIR)/bfd && CFLAGS="$(CFLAGS)" LDFLAGS="$(LDFLAGS)" ./configure --host=$(HOST) --prefix=$(PREFIX) --with-zlib
+	$(MAKE) -C $(bfd_DIR)/bfd
+	$(MAKE) -C $(bfd_DIR)/bfd install
+	touch $@
+
+$(bzip2_INSTALL): $(bzip2_EXTRACT)
+	$(MAKE) -C $(bzip2_DIR) clean
+	$(MAKE) CC="$(CC)" PREFIX=$(PREFIX) -C $(bzip2_DIR) -f Makefile-libbz2_so
+	mkdir -p $(DEPSDIR)/lib
+	cp -a $(bzip2_DIR)/libbz2.so* $(DEPSDIR)/lib/
+	@rm -f $(DEPSDIR)/lib/libbz2.so
+	# The dynamic library is required to prevent errors while building elfutils
+	cd $(DEPSDIR)/lib && ln -s libbz2.so.1.0 libbz2.so
+	$(MAKE) -C $(bzip2_DIR) clean
+	$(MAKE) CC="$(CC)" PREFIX=$(PREFIX) -C $(bzip2_DIR) install
+	touch $@
+
+elfutils_LDFLAGS=$(LDFLAGS) -Wl,-rpath-link $(PREFIX)/lib
+
+$(elfutils_INSTALL): $(zlib_INSTALL) $(lzma_INSTALL) $(bzip2_INSTALL) $(elfutils_EXTRACT)
+	cd $(elfutils_DIR) && CFLAGS="$(CFLAGS)" LDFLAGS="$(elfutils_LDFLAGS)" ./configure --host=$(HOST) --prefix=$(PREFIX) --with-zlib --with-bzlib --with-lzma
+	$(MAKE) -C $(elfutils_DIR)
+	$(MAKE) -C $(elfutils_DIR) install
+	touch $@
+
+$(lzma_INSTALL): $(lzma_EXTRACT)
+	cd $(lzma_DIR) && ./configure --host=$(HOST) --prefix=$(PREFIX)
+	$(MAKE) -C $(lzma_DIR)
+	$(MAKE) -C $(lzma_DIR) install
+	touch $@
+
+$(slang_INSTALL): $(slang_EXTRACT)
+	cd $(slang_DIR) && ./configure --host=$(HOST) --prefix=$(PREFIX)
+	$(MAKE1) -C $(slang_DIR)
+	$(MAKE1) -C $(slang_DIR) install-all
+	touch $@
+
+$(zlib_INSTALL): $(zlib_EXTRACT)
+	cd $(zlib_DIR) && ./configure --prefix=$(PREFIX)
+	$(MAKE) -C $(zlib_DIR)
+	$(MAKE) -C $(zlib_DIR) install
+	touch $@
+
+$(unwind_INSTALL): $(unwind_EXTRACT)
+	cd $(unwind_DIR) && ./configure --host=$(HOST) --prefix=$(PREFIX) --enable-debug --enable-debug-frame
+	cd $(unwind_DIR) && $(MAKE)
+	cd $(unwind_DIR) && $(MAKE) install
+	touch $@
+
+clean:
+	rm -rf $(BUILDDIR)
+	rm -rf $(DEPSDIR)
diff --git a/tools/perf/Makefile.perf b/tools/perf/Makefile.perf
index 56517d3..5920782 100644
--- a/tools/perf/Makefile.perf
+++ b/tools/perf/Makefile.perf
@@ -92,6 +92,13 @@ ifneq ($(objtree),)
 #$(info Determined 'objtree' to be $(objtree))
 endif
 
+ifeq ($(findstring -static,${LDFLAGS}),-static)
+  ifneq ($(wildcard deps-$(ARCH)/*),)
+    LDFLAGS += -L $(PWD)/deps-$(ARCH)/lib
+    EXTRA_CFLAGS += -isystem $(PWD)/deps-$(ARCH)/include
+  endif
+endif
+
 ifneq ($(OUTPUT),)
 #$(info Determined 'OUTPUT' to be $(OUTPUT))
 # Adding $(OUTPUT) as a directory to look for source files,
-- 
1.7.10.4


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* Re: [PATCHv2 3/3] perf: add helper makefile for cross compiling libs
  2015-10-29  7:49 ` [PATCHv2 3/3] perf: add helper makefile for cross compiling libs Rabin Vincent
@ 2015-10-29  9:46   ` Ingo Molnar
  2015-11-06  8:09     ` Rabin Vincent
  0 siblings, 1 reply; 9+ messages in thread
From: Ingo Molnar @ 2015-10-29  9:46 UTC (permalink / raw)
  To: Rabin Vincent
  Cc: Arnaldo Carvalho de Melo, jolsa, namhyung, Ingo Molnar,
	Peter Zijlstra, linux-kernel, Rabin Vincent


* Rabin Vincent <rabin.vincent@axis.com> wrote:

> It's easy to cross-compile a minimal perf binary without any external
> libraries (other than a C library of course).  But many useful features
> depend on external libraries, so to get them one needs to either
> cross-compile a bunch of libraries manually and send in the correct
> paths or integrate the perf build into some external build system.
> 
> In order to make it easier for people to qucikly get up and running with
> a fairly full featured cross-compiled mainline perf, provide a helper makefile
> which can be used to download and build the required libraries, which can then
> be used in a static build of perf.
> 
> For example, assuming an arm-linux-gcc cross-compiler is present in the
> PATH, the following is what one seens if one tries to build a static
> perf for ARM:
> 
>  $ make ARCH=arm CROSS_COMPILE=arm-linux- LDFLAGS="-static"
> 
>  Auto-detecting system features:
>  ...                         dwarf: [ OFF ]
>  ...                         glibc: [ on  ]
>  ...                          gtk2: [ OFF ]
>  ...                      libaudit: [ OFF ]
>  ...                        libbfd: [ OFF ]
>  ...                        libelf: [ OFF ]
>  ...                       libnuma: [ OFF ]
>  ...        numa_num_possible_cpus: [ OFF ]
>  ...                       libperl: [ OFF ]
>  ...                     libpython: [ OFF ]
>  ...                      libslang: [ OFF ]
>  ...                     libunwind: [ OFF ]
>  ...            libdw-dwarf-unwind: [ OFF ]
>  ...                          zlib: [ OFF ]
>  ...                          lzma: [ OFF ]
>  ...                     get_cpuid: [ OFF ]
> 
> By using the new Makefile.cross first, we get many important features:
> 
>  $ make ARCH=arm CROSS_COMPILE=arm-linux- -f Makefile.cross
>  $ make ARCH=arm CROSS_COMPILE=arm-linux- LDFLAGS="-static"
> 
>   Auto-detecting system features:
>   ...                         dwarf: [ on  ]
>   ...                         glibc: [ on  ]
>   ...                          gtk2: [ OFF ]
>   ...                      libaudit: [ on  ]
>   ...                        libbfd: [ on  ]
>   ...                        libelf: [ on  ]
>   ...                       libnuma: [ OFF ]
>   ...        numa_num_possible_cpus: [ OFF ]
>   ...                       libperl: [ OFF ]
>   ...                     libpython: [ OFF ]
>   ...                      libslang: [ on  ]
>   ...                     libunwind: [ on  ]
>   ...            libdw-dwarf-unwind: [ OFF ]
>   ...                          zlib: [ on  ]
>   ...                          lzma: [ on  ]
>   ...                     get_cpuid: [ OFF ]

That's really nice!

Would it be possible to add a gcc and glibc building portion as well? That would 
make it entirely self-hosting.

Something like:

    make ARCH=arm BOOTSTRAP=1

... would magically fetch everything needed, and (given enough Internet bandwidth 
and a fast enough machine) build a whole cross-environment from scratch.

Personally I'd even use this to bootstrap kernel cross-builds.

It could also be used to cross-build to the host architecture as well: it would 
make it easier to test perf on the latest GCC and glibc versions. (Which the host 
distribution does not carry.)

Thanks,

	Ingo

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCHv2 2/3] tools: build: fix libiberty feature detection
  2015-10-29  7:49 ` [PATCHv2 2/3] tools: build: fix libiberty feature detection Rabin Vincent
@ 2015-10-29 20:45   ` Jiri Olsa
  2015-10-30  9:14   ` [tip:perf/core] tools build: Fix " tip-bot for Rabin Vincent
  1 sibling, 0 replies; 9+ messages in thread
From: Jiri Olsa @ 2015-10-29 20:45 UTC (permalink / raw)
  To: Rabin Vincent
  Cc: Arnaldo Carvalho de Melo, jolsa, namhyung, Ingo Molnar,
	Peter Zijlstra, linux-kernel, Rabin Vincent

On Thu, Oct 29, 2015 at 08:49:37AM +0100, Rabin Vincent wrote:
> Any CFLAGS or LDFLAGS set by the user need to be passed to the feature build
> command.  This many include for example -I or -L to point to libraries and
> include files in custom paths.
> 
> In most of the test-*.bin rules in build/feature/Makefile, we use the BUILD
> macro which always sends in CFLAGS and LDFLAGS.  The libiberty build line
> however doesn't use the BUILD macro and thus needs to send in CFLAGS and
> LDFLAGS explicitly.  Without this, when using custom CFLAGS/LDFLAGS, libiberty
> fails to be detected and the perf link fails with something like:
> 
>   LINK     perf
>  libbfd.a(bfd.o): In function `bfd_errmsg':
>  bfd.c:(.text+0x168): undefined reference to `xstrerror'
>  bbfd.a(opncls.o): In function `_bfd_new_bfd':
>  opncls.c:(.text+0xe8): undefined reference to `objalloc_create'
>  ...
> 
> Signed-off-by: Rabin Vincent <rabin.vincent@axis.com>

Acked-by: Jiri Olsa <jolsa@kernel.org>

thanks,
jirka

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [tip:perf/core] tools build: Fix libiberty feature detection
  2015-10-29  7:49 ` [PATCHv2 2/3] tools: build: fix libiberty feature detection Rabin Vincent
  2015-10-29 20:45   ` Jiri Olsa
@ 2015-10-30  9:14   ` tip-bot for Rabin Vincent
  1 sibling, 0 replies; 9+ messages in thread
From: tip-bot for Rabin Vincent @ 2015-10-30  9:14 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: hpa, rabinv, a.p.zijlstra, jolsa, acme, linux-kernel, mingo,
	namhyung, tglx, rabin.vincent

Commit-ID:  3af6ed84eb43c587beb5f3252222e39e65d08c61
Gitweb:     http://git.kernel.org/tip/3af6ed84eb43c587beb5f3252222e39e65d08c61
Author:     Rabin Vincent <rabin.vincent@axis.com>
AuthorDate: Thu, 29 Oct 2015 08:49:37 +0100
Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Thu, 29 Oct 2015 17:46:35 -0300

tools build: Fix libiberty feature detection

Any CFLAGS or LDFLAGS set by the user need to be passed to the feature
build command.  This many include for example -I or -L to point to
libraries and include files in custom paths.

In most of the test-*.bin rules in build/feature/Makefile, we use the BUILD
macro which always sends in CFLAGS and LDFLAGS.  The libiberty build line
however doesn't use the BUILD macro and thus needs to send in CFLAGS and
LDFLAGS explicitly.  Without this, when using custom CFLAGS/LDFLAGS, libiberty
fails to be detected and the perf link fails with something like:

   LINK     perf
  libbfd.a(bfd.o): In function `bfd_errmsg':
  bfd.c:(.text+0x168): undefined reference to `xstrerror'
  bbfd.a(opncls.o): In function `_bfd_new_bfd':
  opncls.c:(.text+0xe8): undefined reference to `objalloc_create'
  ...

Signed-off-by: Rabin Vincent <rabin.vincent@axis.com>
Acked-by: Jiri Olsa <jolsa@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Rabin Vincent <rabinv@axis.com>
Link: http://lkml.kernel.org/r/1446104978-26429-2-git-send-email-rabin.vincent@axis.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/build/feature/Makefile | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/tools/build/feature/Makefile b/tools/build/feature/Makefile
index e43a297..cea04ce9 100644
--- a/tools/build/feature/Makefile
+++ b/tools/build/feature/Makefile
@@ -132,10 +132,10 @@ test-libbfd.bin:
 	$(BUILD) -DPACKAGE='"perf"' -lbfd -lz -liberty -ldl
 
 test-liberty.bin:
-	$(CC) -Wall -Werror -o $(OUTPUT)$@ test-libbfd.c -DPACKAGE='"perf"' -lbfd -ldl -liberty
+	$(CC) $(CFLAGS) -Wall -Werror -o $(OUTPUT)$@ test-libbfd.c -DPACKAGE='"perf"' $(LDFLAGS) -lbfd -ldl -liberty
 
 test-liberty-z.bin:
-	$(CC) -Wall -Werror -o $(OUTPUT)$@ test-libbfd.c -DPACKAGE='"perf"' -lbfd -ldl -liberty -lz
+	$(CC) $(CFLAGS) -Wall -Werror -o $(OUTPUT)$@ test-libbfd.c -DPACKAGE='"perf"' $(LDFLAGS) -lbfd -ldl -liberty -lz
 
 test-cplus-demangle.bin:
 	$(BUILD) -liberty

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [tip:perf/core] perf unwind: Pass symbol source to libunwind
  2015-10-29  7:49 [PATCHv2 1/3] perf: unwind: pass symbol source to libunwind Rabin Vincent
  2015-10-29  7:49 ` [PATCHv2 2/3] tools: build: fix libiberty feature detection Rabin Vincent
  2015-10-29  7:49 ` [PATCHv2 3/3] perf: add helper makefile for cross compiling libs Rabin Vincent
@ 2015-10-30  9:15 ` tip-bot for Rabin Vincent
  2 siblings, 0 replies; 9+ messages in thread
From: tip-bot for Rabin Vincent @ 2015-10-30  9:15 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: jolsa, a.p.zijlstra, tglx, acme, rabin.vincent, rabinv, mingo,
	linux-kernel, hpa, namhyung

Commit-ID:  7ed4915ad60788d6b846e2cd034f49ee15698143
Gitweb:     http://git.kernel.org/tip/7ed4915ad60788d6b846e2cd034f49ee15698143
Author:     Rabin Vincent <rabin.vincent@axis.com>
AuthorDate: Thu, 29 Oct 2015 08:49:36 +0100
Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Thu, 29 Oct 2015 17:48:38 -0300

perf unwind: Pass symbol source to libunwind

Even if --symfs is used to point to the debug binaries, we send in the
non-debug filenames to libunwind, which leads to libunwind not finding
the debug frame.  Fix this by preferring the file in --symfs, if it is
available.

Signed-off-by: Rabin Vincent <rabin.vincent@axis.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Rabin Vincent <rabinv@axis.com>
Link: http://lkml.kernel.org/r/1446104978-26429-1-git-send-email-rabin.vincent@axis.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/util/unwind-libunwind.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/tools/perf/util/unwind-libunwind.c b/tools/perf/util/unwind-libunwind.c
index f729f9e..c83832b 100644
--- a/tools/perf/util/unwind-libunwind.c
+++ b/tools/perf/util/unwind-libunwind.c
@@ -360,12 +360,15 @@ find_proc_info(unw_addr_space_t as, unw_word_t ip, unw_proc_info_t *pi,
 		int fd = dso__data_get_fd(map->dso, ui->machine);
 		int is_exec = elf_is_exec(fd, map->dso->name);
 		unw_word_t base = is_exec ? 0 : map->start;
+		const char *symfile;
 
 		if (fd >= 0)
 			dso__data_put_fd(map->dso);
 
+		symfile = map->dso->symsrc_filename ?: map->dso->name;
+
 		memset(&di, 0, sizeof(di));
-		if (dwarf_find_debug_frame(0, &di, ip, base, map->dso->name,
+		if (dwarf_find_debug_frame(0, &di, ip, base, symfile,
 					   map->start, map->end))
 			return dwarf_search_unwind_table(as, ip, &di, pi,
 							 need_unwind_info, arg);

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* Re: [PATCHv2 3/3] perf: add helper makefile for cross compiling libs
  2015-10-29  9:46   ` Ingo Molnar
@ 2015-11-06  8:09     ` Rabin Vincent
  2015-11-27 11:35       ` Ingo Molnar
  0 siblings, 1 reply; 9+ messages in thread
From: Rabin Vincent @ 2015-11-06  8:09 UTC (permalink / raw)
  To: Ingo Molnar
  Cc: Arnaldo Carvalho de Melo, jolsa, namhyung, Peter Zijlstra, linux-kernel

On Thu, Oct 29, 2015 at 10:46:49AM +0100, Ingo Molnar wrote:
> Would it be possible to add a gcc and glibc building portion as well? That would 
> make it entirely self-hosting.

Yes, but:

- Those that intend to run the built binary on a target would presumably
  already have a cross-compiler lying around which they use to build the
  rest of userspace.

- Those that don't have a cross-compiler or need a newer one can already
  very easily create one using other specialized tools such as
  crosstool-ng (see below).

> 
> Something like:
> 
>     make ARCH=arm BOOTSTRAP=1
> 
> ... would magically fetch everything needed, and (given enough Internet bandwidth 
> and a fast enough machine) build a whole cross-environment from scratch.

This is already possible using crosstool-ng.  Getting an ARM GCC 5.2
cross-compiler is as simple as:

 $ git clone git://crosstool-ng.org/crosstool-ng
 $ cd crosstool-ng
 $ ./bootstrap && ./configure --enable-local && make

 $ ./ct-ng arm-unknown-linux-gnueabi
 $ ./ct-ng build

 $ export PATH=$PATH:~/x-tools/arm-unknown-linux-gnueabi/bin/
 $ arm-unknown-linux-gnueabi-gcc --version
 arm-unknown-linux-gnueabi-gcc (crosstool-NG crosstool-ng-1.20.0-361-g85f9814) 5.2.0

> Personally I'd even use this to bootstrap kernel cross-builds.
> 
> It could also be used to cross-build to the host architecture as well: it would 
> make it easier to test perf on the latest GCC and glibc versions. (Which the host 
> distribution does not carry.)

This is also possible with crosstool-ng. You just need to build the
x86_64-unknown-linux-gnu config to get GCC 5.2 + glibc 2.22 toolchain
for an x86-64 host.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCHv2 3/3] perf: add helper makefile for cross compiling libs
  2015-11-06  8:09     ` Rabin Vincent
@ 2015-11-27 11:35       ` Ingo Molnar
  0 siblings, 0 replies; 9+ messages in thread
From: Ingo Molnar @ 2015-11-27 11:35 UTC (permalink / raw)
  To: Rabin Vincent
  Cc: Arnaldo Carvalho de Melo, jolsa, namhyung, Peter Zijlstra, linux-kernel


* Rabin Vincent <rabin.vincent@axis.com> wrote:

> On Thu, Oct 29, 2015 at 10:46:49AM +0100, Ingo Molnar wrote:
> > Would it be possible to add a gcc and glibc building portion as well? That would 
> > make it entirely self-hosting.
> 
> Yes, but:
> 
> - Those that intend to run the built binary on a target would presumably
>   already have a cross-compiler lying around which they use to build the
>   rest of userspace.
> 
> - Those that don't have a cross-compiler or need a newer one can already
>   very easily create one using other specialized tools such as
>   crosstool-ng (see below).



> 
> > 
> > Something like:
> > 
> >     make ARCH=arm BOOTSTRAP=1
> > 
> > ... would magically fetch everything needed, and (given enough Internet bandwidth 
> > and a fast enough machine) build a whole cross-environment from scratch.
> 
> This is already possible using crosstool-ng.  Getting an ARM GCC 5.2
> cross-compiler is as simple as:
> 
>  $ git clone git://crosstool-ng.org/crosstool-ng
>  $ cd crosstool-ng
>  $ ./bootstrap && ./configure --enable-local && make
> 
>  $ ./ct-ng arm-unknown-linux-gnueabi
>  $ ./ct-ng build

My point is, that's 5 non-trivial steps harder than just typing:

     make ARCH=arm BOOTSTRAP=1

> This is also possible with crosstool-ng. You just need to build the
> x86_64-unknown-linux-gnu config to get GCC 5.2 + glibc 2.22 toolchain
> for an x86-64 host.

It's also possibly by directly cloning the repos of those tools and building them 
- they are reasonably easy to build.

My point is that if we add automation, we might as well walk to whole mile.

Thanks,

	Ingo

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2015-11-27 11:36 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-10-29  7:49 [PATCHv2 1/3] perf: unwind: pass symbol source to libunwind Rabin Vincent
2015-10-29  7:49 ` [PATCHv2 2/3] tools: build: fix libiberty feature detection Rabin Vincent
2015-10-29 20:45   ` Jiri Olsa
2015-10-30  9:14   ` [tip:perf/core] tools build: Fix " tip-bot for Rabin Vincent
2015-10-29  7:49 ` [PATCHv2 3/3] perf: add helper makefile for cross compiling libs Rabin Vincent
2015-10-29  9:46   ` Ingo Molnar
2015-11-06  8:09     ` Rabin Vincent
2015-11-27 11:35       ` Ingo Molnar
2015-10-30  9:15 ` [tip:perf/core] perf unwind: Pass symbol source to libunwind tip-bot for Rabin Vincent

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.