2009-10-13 21:11:12

by Randy Dunlap

[permalink] [raw]
Subject: Re: [tip:perf/urgent] perf tools: Fix the NO_64BIT build on pure 64-bit systems

On Mon, 12 Oct 2009 08:34:16 GMT tip-bot for Ingo Molnar wrote:

> Commit-ID: 55621ccf2b7a8afe39df8c80f55b28424fd07d13
> Gitweb: http://git.kernel.org/tip/55621ccf2b7a8afe39df8c80f55b28424fd07d13
> Author: Ingo Molnar <[email protected]>
> AuthorDate: Mon, 12 Oct 2009 09:57:25 +0200
> Committer: Ingo Molnar <[email protected]>
> CommitDate: Mon, 12 Oct 2009 10:00:27 +0200
>
> perf tools: Fix the NO_64BIT build on pure 64-bit systems
>
> Randy Dunlap reported that 'make NO_64BIT=1' fails to build
> a pure 32-b it binary on 64-bit/64-bit x86 systems.
>
> The reason is that we dont pass in the -m32 and GCC defaults
> to -m64.
>
> So pass it in - and also extend the warning message about libelf
> dependencies - glibc-dev[el] is needed as well beyond the libelf
> library.

Ingo, thanks, I finally got this working, after installing more 32-bit
libs etc., like Kyle said that I would need to do.

The error message is still a little misleading/confusing:
Makefile:426: *** No libelf.h/libelf found, please install libelf-dev/elfutils-libelf-devel and glibc-dev[el]. Stop.

when elfutils-libelf-devel.i586 is installed but glibc-devel.i[56]86 is not
installed. gcc failed with:
In file included from /usr/include/features.h:376,
from /usr/include/sys/types.h:27,
from /usr/include/libelf.h:53,
from elfdeveltest.c:1:
/usr/include/gnu/stubs.h:7:27: error: gnu/stubs-32.h: No such file or directory


> Reported-by: Randy Dunlap <[email protected]>
> Cc: Peter Zijlstra <[email protected]>
> Cc: Frederic Weisbecker <[email protected]>
> Cc: Mike Galbraith <[email protected]>
> Cc: Paul Mackerras <[email protected]>
> Cc: Arnaldo Carvalho de Melo <[email protected]>
> LKML-Reference: Message-Id: <[email protected]>
> Signed-off-by: Ingo Molnar <[email protected]>
> ---
> tools/perf/Makefile | 21 ++++++++++++++-------
> 1 files changed, 14 insertions(+), 7 deletions(-)
>
> diff --git a/tools/perf/Makefile b/tools/perf/Makefile
> index 5881943..742a32e 100644
> --- a/tools/perf/Makefile
> +++ b/tools/perf/Makefile
> @@ -157,11 +157,18 @@ uname_R := $(shell sh -c 'uname -r 2>/dev/null || echo not')
> uname_P := $(shell sh -c 'uname -p 2>/dev/null || echo not')
> uname_V := $(shell sh -c 'uname -v 2>/dev/null || echo not')
>
> -# If we're on a 64-bit kernel, use -m64
> -ifndef NO_64BIT
> - ifneq ($(patsubst %64,%,$(uname_M)),$(uname_M))
> - M64 := -m64
> - endif
> +#
> +# Add -m32 for cross-builds:
> +#
> +ifdef NO_64BIT
> + MBITS := -m32
> +else
> + #
> + # If we're on a 64-bit kernel, use -m64:
> + #
> + ifneq ($(patsubst %64,%,$(uname_M)),$(uname_M))
> + MBITS := -m64
> + endif
> endif
>
> # CFLAGS and LDFLAGS are for the users to override from the command line.
> @@ -194,7 +201,7 @@ EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wold-style-definition
> EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wstrict-prototypes
> EXTRA_WARNINGS := $(EXTRA_WARNINGS) -Wdeclaration-after-statement
>
> -CFLAGS = $(M64) -ggdb3 -Wall -Wextra -std=gnu99 -Werror -O6 -fstack-protector-all -D_FORTIFY_SOURCE=2 $(EXTRA_WARNINGS)
> +CFLAGS = $(MBITS) -ggdb3 -Wall -Wextra -std=gnu99 -Werror -O6 -fstack-protector-all -D_FORTIFY_SOURCE=2 $(EXTRA_WARNINGS)
> LDFLAGS = -lpthread -lrt -lelf -lm
> ALL_CFLAGS = $(CFLAGS)
> ALL_LDFLAGS = $(LDFLAGS)
> @@ -416,7 +423,7 @@ ifeq ($(uname_S),Darwin)
> endif
>
> ifneq ($(shell sh -c "(echo '\#include <libelf.h>'; echo 'int main(void) { Elf * elf = elf_begin(0, ELF_C_READ_MMAP, 0); return (long)elf; }') | $(CC) -x c - $(ALL_CFLAGS) -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -o /dev/null $(ALL_LDFLAGS) > /dev/null 2>&1 && echo y"), y)
> - msg := $(error No libelf.h/libelf found, please install libelf-dev/elfutils-libelf-devel);
> + msg := $(error No libelf.h/libelf found, please install libelf-dev/elfutils-libelf-devel and glibc-dev[el]);
> endif
>
> ifdef NO_DEMANGLE


---
~Randy


2009-10-14 06:21:49

by Ingo Molnar

[permalink] [raw]
Subject: Re: [tip:perf/urgent] perf tools: Fix the NO_64BIT build on pure 64-bit systems


* Randy Dunlap <[email protected]> wrote:

> On Mon, 12 Oct 2009 08:34:16 GMT tip-bot for Ingo Molnar wrote:
>
> > Commit-ID: 55621ccf2b7a8afe39df8c80f55b28424fd07d13
> > Gitweb: http://git.kernel.org/tip/55621ccf2b7a8afe39df8c80f55b28424fd07d13
> > Author: Ingo Molnar <[email protected]>
> > AuthorDate: Mon, 12 Oct 2009 09:57:25 +0200
> > Committer: Ingo Molnar <[email protected]>
> > CommitDate: Mon, 12 Oct 2009 10:00:27 +0200
> >
> > perf tools: Fix the NO_64BIT build on pure 64-bit systems
> >
> > Randy Dunlap reported that 'make NO_64BIT=1' fails to build
> > a pure 32-b it binary on 64-bit/64-bit x86 systems.
> >
> > The reason is that we dont pass in the -m32 and GCC defaults
> > to -m64.
> >
> > So pass it in - and also extend the warning message about libelf
> > dependencies - glibc-dev[el] is needed as well beyond the libelf
> > library.
>
> Ingo, thanks, I finally got this working, after installing more 32-bit
> libs etc., like Kyle said that I would need to do.
>
> The error message is still a little misleading/confusing:
> Makefile:426: *** No libelf.h/libelf found, please install libelf-dev/elfutils-libelf-devel and glibc-dev[el]. Stop.
>
> when elfutils-libelf-devel.i586 is installed but glibc-devel.i[56]86 is not
> installed. gcc failed with:
> In file included from /usr/include/features.h:376,
> from /usr/include/sys/types.h:27,
> from /usr/include/libelf.h:53,
> from elfdeveltest.c:1:
> /usr/include/gnu/stubs.h:7:27: error: gnu/stubs-32.h: No such file or directory

Why is it misleading? It says it very clearly that you need to install
both:

please install libelf-dev/elfutils-libelf-devel and glibc-dev[el]. Stop.

Ingo

2009-10-14 14:46:58

by Randy Dunlap

[permalink] [raw]
Subject: Re: [tip:perf/urgent] perf tools: Fix the NO_64BIT build on pure 64-bit systems

On Wed, 14 Oct 2009 08:20:52 +0200 Ingo Molnar wrote:

>
> * Randy Dunlap <[email protected]> wrote:
>
> > On Mon, 12 Oct 2009 08:34:16 GMT tip-bot for Ingo Molnar wrote:
> >
> > > Commit-ID: 55621ccf2b7a8afe39df8c80f55b28424fd07d13
> > > Gitweb: http://git.kernel.org/tip/55621ccf2b7a8afe39df8c80f55b28424fd07d13
> > > Author: Ingo Molnar <[email protected]>
> > > AuthorDate: Mon, 12 Oct 2009 09:57:25 +0200
> > > Committer: Ingo Molnar <[email protected]>
> > > CommitDate: Mon, 12 Oct 2009 10:00:27 +0200
> > >
> > > perf tools: Fix the NO_64BIT build on pure 64-bit systems
> > >
> > > Randy Dunlap reported that 'make NO_64BIT=1' fails to build
> > > a pure 32-b it binary on 64-bit/64-bit x86 systems.
> > >
> > > The reason is that we dont pass in the -m32 and GCC defaults
> > > to -m64.
> > >
> > > So pass it in - and also extend the warning message about libelf
> > > dependencies - glibc-dev[el] is needed as well beyond the libelf
> > > library.
> >
> > Ingo, thanks, I finally got this working, after installing more 32-bit
> > libs etc., like Kyle said that I would need to do.
> >
> > The error message is still a little misleading/confusing:
> > Makefile:426: *** No libelf.h/libelf found, please install libelf-dev/elfutils-libelf-devel and glibc-dev[el]. Stop.
> >
> > when elfutils-libelf-devel.i586 is installed but glibc-devel.i[56]86 is not
> > installed. gcc failed with:
> > In file included from /usr/include/features.h:376,
> > from /usr/include/sys/types.h:27,
> > from /usr/include/libelf.h:53,
> > from elfdeveltest.c:1:
> > /usr/include/gnu/stubs.h:7:27: error: gnu/stubs-32.h: No such file or directory
>
> Why is it misleading? It says it very clearly that you need to install
> both:
>
> please install libelf-dev/elfutils-libelf-devel and glibc-dev[el]. Stop.

It also says very clearly:

Makefile:426: *** No libelf.h/libelf found

which is not correct.

---
~Randy

2009-10-14 16:00:03

by Arnaldo Carvalho de Melo

[permalink] [raw]
Subject: Re: [tip:perf/urgent] perf tools: Fix the NO_64BIT build on pure 64-bit systems

Em Wed, Oct 14, 2009 at 07:44:04AM -0700, Randy Dunlap escreveu:
> On Wed, 14 Oct 2009 08:20:52 +0200 Ingo Molnar wrote:
>
> >
> > * Randy Dunlap <[email protected]> wrote:
> >
> > > On Mon, 12 Oct 2009 08:34:16 GMT tip-bot for Ingo Molnar wrote:
> > >
> > > > Commit-ID: 55621ccf2b7a8afe39df8c80f55b28424fd07d13
> > > > Gitweb: http://git.kernel.org/tip/55621ccf2b7a8afe39df8c80f55b28424fd07d13
> > > > Author: Ingo Molnar <[email protected]>
> > > > AuthorDate: Mon, 12 Oct 2009 09:57:25 +0200
> > > > Committer: Ingo Molnar <[email protected]>
> > > > CommitDate: Mon, 12 Oct 2009 10:00:27 +0200
> > > >
> > > > perf tools: Fix the NO_64BIT build on pure 64-bit systems
> > > >
> > > > Randy Dunlap reported that 'make NO_64BIT=1' fails to build
> > > > a pure 32-b it binary on 64-bit/64-bit x86 systems.
> > > >
> > > > The reason is that we dont pass in the -m32 and GCC defaults
> > > > to -m64.
> > > >
> > > > So pass it in - and also extend the warning message about libelf
> > > > dependencies - glibc-dev[el] is needed as well beyond the libelf
> > > > library.
> > >
> > > Ingo, thanks, I finally got this working, after installing more 32-bit
> > > libs etc., like Kyle said that I would need to do.
> > >
> > > The error message is still a little misleading/confusing:
> > > Makefile:426: *** No libelf.h/libelf found, please install libelf-dev/elfutils-libelf-devel and glibc-dev[el]. Stop.
> > >
> > > when elfutils-libelf-devel.i586 is installed but glibc-devel.i[56]86 is not
> > > installed. gcc failed with:
> > > In file included from /usr/include/features.h:376,
> > > from /usr/include/sys/types.h:27,
> > > from /usr/include/libelf.h:53,
> > > from elfdeveltest.c:1:
> > > /usr/include/gnu/stubs.h:7:27: error: gnu/stubs-32.h: No such file or directory
> >
> > Why is it misleading? It says it very clearly that you need to install
> > both:
> >
> > please install libelf-dev/elfutils-libelf-devel and glibc-dev[el]. Stop.
>
> It also says very clearly:
>
> Makefile:426: *** No libelf.h/libelf found
>
> which is not correct.

So the correct way is to first look for the presence of glibc-devel,
barf if its not present, then after that, do what is done now and test
for the presence of libelf.h :-\

But if one just follows the suggestion, and installs the suggested
packages, it should work, no?

- Arnaldo

2009-10-14 16:02:24

by Ingo Molnar

[permalink] [raw]
Subject: Re: [tip:perf/urgent] perf tools: Fix the NO_64BIT build on pure 64-bit systems


* Arnaldo Carvalho de Melo <[email protected]> wrote:

> Em Wed, Oct 14, 2009 at 07:44:04AM -0700, Randy Dunlap escreveu:
> > On Wed, 14 Oct 2009 08:20:52 +0200 Ingo Molnar wrote:
> >
> > >
> > > * Randy Dunlap <[email protected]> wrote:
> > >
> > > > On Mon, 12 Oct 2009 08:34:16 GMT tip-bot for Ingo Molnar wrote:
> > > >
> > > > > Commit-ID: 55621ccf2b7a8afe39df8c80f55b28424fd07d13
> > > > > Gitweb: http://git.kernel.org/tip/55621ccf2b7a8afe39df8c80f55b28424fd07d13
> > > > > Author: Ingo Molnar <[email protected]>
> > > > > AuthorDate: Mon, 12 Oct 2009 09:57:25 +0200
> > > > > Committer: Ingo Molnar <[email protected]>
> > > > > CommitDate: Mon, 12 Oct 2009 10:00:27 +0200
> > > > >
> > > > > perf tools: Fix the NO_64BIT build on pure 64-bit systems
> > > > >
> > > > > Randy Dunlap reported that 'make NO_64BIT=1' fails to build
> > > > > a pure 32-b it binary on 64-bit/64-bit x86 systems.
> > > > >
> > > > > The reason is that we dont pass in the -m32 and GCC defaults
> > > > > to -m64.
> > > > >
> > > > > So pass it in - and also extend the warning message about libelf
> > > > > dependencies - glibc-dev[el] is needed as well beyond the libelf
> > > > > library.
> > > >
> > > > Ingo, thanks, I finally got this working, after installing more 32-bit
> > > > libs etc., like Kyle said that I would need to do.
> > > >
> > > > The error message is still a little misleading/confusing:
> > > > Makefile:426: *** No libelf.h/libelf found, please install libelf-dev/elfutils-libelf-devel and glibc-dev[el]. Stop.
> > > >
> > > > when elfutils-libelf-devel.i586 is installed but glibc-devel.i[56]86 is not
> > > > installed. gcc failed with:
> > > > In file included from /usr/include/features.h:376,
> > > > from /usr/include/sys/types.h:27,
> > > > from /usr/include/libelf.h:53,
> > > > from elfdeveltest.c:1:
> > > > /usr/include/gnu/stubs.h:7:27: error: gnu/stubs-32.h: No such file or directory
> > >
> > > Why is it misleading? It says it very clearly that you need to install
> > > both:
> > >
> > > please install libelf-dev/elfutils-libelf-devel and glibc-dev[el]. Stop.
> >
> > It also says very clearly:
> >
> > Makefile:426: *** No libelf.h/libelf found
> >
> > which is not correct.
>
> So the correct way is to first look for the presence of glibc-devel,
> barf if its not present, then after that, do what is done now and test
> for the presence of libelf.h :-\
>
> But if one just follows the suggestion, and installs the suggested
> packages, it should work, no?

well .. send me a patch that makes the message more ambigious, so that
we output something like:

> Makefile:426: *** No ELF support found, please install libelf-dev/elfutils-libelf-devel and glibc-dev[el]. Stop.

that should make it useful enough, without complicating the make rules.

Ingo

2009-10-14 16:04:14

by Randy Dunlap

[permalink] [raw]
Subject: Re: [tip:perf/urgent] perf tools: Fix the NO_64BIT build on pure 64-bit systems

On Wed, 14 Oct 2009 12:58:48 -0300 Arnaldo Carvalho de Melo wrote:

> Em Wed, Oct 14, 2009 at 07:44:04AM -0700, Randy Dunlap escreveu:
> > On Wed, 14 Oct 2009 08:20:52 +0200 Ingo Molnar wrote:
> >
> > >
> > > * Randy Dunlap <[email protected]> wrote:
> > >
> > > > On Mon, 12 Oct 2009 08:34:16 GMT tip-bot for Ingo Molnar wrote:
> > > >
> > > > > Commit-ID: 55621ccf2b7a8afe39df8c80f55b28424fd07d13
> > > > > Gitweb: http://git.kernel.org/tip/55621ccf2b7a8afe39df8c80f55b28424fd07d13
> > > > > Author: Ingo Molnar <[email protected]>
> > > > > AuthorDate: Mon, 12 Oct 2009 09:57:25 +0200
> > > > > Committer: Ingo Molnar <[email protected]>
> > > > > CommitDate: Mon, 12 Oct 2009 10:00:27 +0200
> > > > >
> > > > > perf tools: Fix the NO_64BIT build on pure 64-bit systems
> > > > >
> > > > > Randy Dunlap reported that 'make NO_64BIT=1' fails to build
> > > > > a pure 32-b it binary on 64-bit/64-bit x86 systems.
> > > > >
> > > > > The reason is that we dont pass in the -m32 and GCC defaults
> > > > > to -m64.
> > > > >
> > > > > So pass it in - and also extend the warning message about libelf
> > > > > dependencies - glibc-dev[el] is needed as well beyond the libelf
> > > > > library.
> > > >
> > > > Ingo, thanks, I finally got this working, after installing more 32-bit
> > > > libs etc., like Kyle said that I would need to do.
> > > >
> > > > The error message is still a little misleading/confusing:
> > > > Makefile:426: *** No libelf.h/libelf found, please install libelf-dev/elfutils-libelf-devel and glibc-dev[el]. Stop.
> > > >
> > > > when elfutils-libelf-devel.i586 is installed but glibc-devel.i[56]86 is not
> > > > installed. gcc failed with:
> > > > In file included from /usr/include/features.h:376,
> > > > from /usr/include/sys/types.h:27,
> > > > from /usr/include/libelf.h:53,
> > > > from elfdeveltest.c:1:
> > > > /usr/include/gnu/stubs.h:7:27: error: gnu/stubs-32.h: No such file or directory
> > >
> > > Why is it misleading? It says it very clearly that you need to install
> > > both:
> > >
> > > please install libelf-dev/elfutils-libelf-devel and glibc-dev[el]. Stop.
> >
> > It also says very clearly:
> >
> > Makefile:426: *** No libelf.h/libelf found
> >
> > which is not correct.
>
> So the correct way is to first look for the presence of glibc-devel,
> barf if its not present, then after that, do what is done now and test
> for the presence of libelf.h :-\
>
> But if one just follows the suggestion, and installs the suggested
> packages, it should work, no?

Yes, it's just the confusing message...


---
~Randy

2009-10-19 02:21:27

by Randy Dunlap

[permalink] [raw]
Subject: [PATCH] perf tools: better error messages on missing packages

From: Randy Dunlap <[email protected]>

Check for libelf headers and glibc headers separately so that
the error message correctly identifies which package
installation is missing/needed.

Signed-off-by: Randy Dunlap <[email protected]>
---
tools/perf/Makefile | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)

--- lnx-2632-rc5.orig/tools/perf/Makefile
+++ lnx-2632-rc5/tools/perf/Makefile
@@ -422,8 +422,12 @@ ifeq ($(uname_S),Darwin)
PTHREAD_LIBS =
endif

+ifneq ($(shell sh -c "(echo '\#include <gnu/libc-version.h>'; echo 'int main(void) { const char * version = gnu_get_libc_version(); return (long)version; }') | $(CC) -x c - $(ALL_CFLAGS) -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -o /dev/null $(ALL_LDFLAGS) > /dev/null 2>&1 && echo y"), y)
+ msg := $(error No gnu/libc-version.h found, please install glibc-dev[el]);
+endif
+
ifneq ($(shell sh -c "(echo '\#include <libelf.h>'; echo 'int main(void) { Elf * elf = elf_begin(0, ELF_C_READ_MMAP, 0); return (long)elf; }') | $(CC) -x c - $(ALL_CFLAGS) -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -o /dev/null $(ALL_LDFLAGS) > /dev/null 2>&1 && echo y"), y)
- msg := $(error No libelf.h/libelf found, please install libelf-dev/elfutils-libelf-devel and glibc-dev[el]);
+ msg := $(error No libelf.h/libelf found, please install libelf-dev/elfutils-libelf-devel);
endif

ifdef NO_DEMANGLE

2009-10-19 08:43:32

by Randy Dunlap

[permalink] [raw]
Subject: [tip:perf/core] perf tools: Display better error messages on missing packages

Commit-ID: 1abc7f5500fff8422f34826a006648d8741d83d3
Gitweb: http://git.kernel.org/tip/1abc7f5500fff8422f34826a006648d8741d83d3
Author: Randy Dunlap <[email protected]>
AuthorDate: Sun, 18 Oct 2009 19:20:24 -0700
Committer: Ingo Molnar <[email protected]>
CommitDate: Mon, 19 Oct 2009 10:06:37 +0200

perf tools: Display better error messages on missing packages

Check for libelf headers and glibc headers separately so that
the error message correctly identifies which package
installation is missing/needed.

Signed-off-by: Randy Dunlap <[email protected]>
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: Arnaldo Carvalho de Melo <[email protected]>
LKML-Reference: <[email protected]>
Signed-off-by: Ingo Molnar <[email protected]>
---
tools/perf/Makefile | 6 +++++-
1 files changed, 5 insertions(+), 1 deletions(-)

diff --git a/tools/perf/Makefile b/tools/perf/Makefile
index 2400e50..db89a6d 100644
--- a/tools/perf/Makefile
+++ b/tools/perf/Makefile
@@ -431,8 +431,12 @@ ifeq ($(uname_S),Darwin)
PTHREAD_LIBS =
endif

+ifneq ($(shell sh -c "(echo '\#include <gnu/libc-version.h>'; echo 'int main(void) { const char * version = gnu_get_libc_version(); return (long)version; }') | $(CC) -x c - $(ALL_CFLAGS) -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -o /dev/null $(ALL_LDFLAGS) > /dev/null 2>&1 && echo y"), y)
+ msg := $(error No gnu/libc-version.h found, please install glibc-dev[el]);
+endif
+
ifneq ($(shell sh -c "(echo '\#include <libelf.h>'; echo 'int main(void) { Elf * elf = elf_begin(0, ELF_C_READ_MMAP, 0); return (long)elf; }') | $(CC) -x c - $(ALL_CFLAGS) -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -o /dev/null $(ALL_LDFLAGS) > /dev/null 2>&1 && echo y"), y)
- msg := $(error No libelf.h/libelf found, please install libelf-dev/elfutils-libelf-devel and glibc-dev[el]);
+ msg := $(error No libelf.h/libelf found, please install libelf-dev/elfutils-libelf-devel);
endif

ifdef NO_DEMANGLE