public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] perf: add test for strlcpy()
@ 2010-08-21  0:38 Kirill A. Shutemov
  2010-08-21  0:38 ` [PATCH 2/2] perf: fix build with -Wl,--as-needed Kirill A. Shutemov
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Kirill A. Shutemov @ 2010-08-21  0:38 UTC (permalink / raw)
  To: Peter Zijlstra, Paul Mackerras, Ingo Molnar,
	Arnaldo Carvalho de Melo
  Cc: linux-kernel, Kirill A. Shutemov

Some Linux distributions like ALT Linux provides patched glibc with
contains strlcpy(). It's confilcts with strlcpy() from perf.

Let's add check for strlcpy().

Signed-off-by: Kirill A. Shutemov <kirill@shutemov.name>
---
 tools/perf/Makefile          |    8 ++++++++
 tools/perf/feature-tests.mak |   11 +++++++++++
 tools/perf/util/cache.h      |    2 ++
 tools/perf/util/path.c       |    3 ++-
 4 files changed, 23 insertions(+), 1 deletions(-)

diff --git a/tools/perf/Makefile b/tools/perf/Makefile
index 4f1fa77..496a0d6 100644
--- a/tools/perf/Makefile
+++ b/tools/perf/Makefile
@@ -653,6 +653,14 @@ else
 	endif
 endif
 
+ifdef NO_STRLCPY
+	BASIC_CFLAGS += -DNO_STRLCPY
+else
+	ifneq ($(call try-cc,$(SOURCE_STRLCPY),),y)
+		BASIC_CFLAGS += -DNO_STRLCPY
+	endif
+endif
+
 ifndef CC_LD_DYNPATH
 	ifdef NO_R_TO_GCC_LINKER
 		# Some gcc does not accept and pass -R to the linker to specify
diff --git a/tools/perf/feature-tests.mak b/tools/perf/feature-tests.mak
index 7a7b608..b253db6 100644
--- a/tools/perf/feature-tests.mak
+++ b/tools/perf/feature-tests.mak
@@ -110,6 +110,17 @@ int main(void)
 }
 endef
 
+define SOURCE_STRLCPY
+#include <stdlib.h>
+extern size_t strlcpy(char *dest, const char *src, size_t size);
+
+int main(void)
+{
+	strlcpy(NULL, NULL, 0);
+	return 0;
+}
+endef
+
 # try-cc
 # Usage: option = $(call try-cc, source-to-build, cc-options)
 try-cc = $(shell sh -c						  \
diff --git a/tools/perf/util/cache.h b/tools/perf/util/cache.h
index 27e9ebe..a772979 100644
--- a/tools/perf/util/cache.h
+++ b/tools/perf/util/cache.h
@@ -82,6 +82,8 @@ extern char *perf_path(const char *fmt, ...) __attribute__((format (printf, 1, 2
 extern char *perf_pathdup(const char *fmt, ...)
 	__attribute__((format (printf, 1, 2)));
 
+#ifdef NO_STRLCPY
 extern size_t strlcpy(char *dest, const char *src, size_t size);
+#endif
 
 #endif /* __PERF_CACHE_H */
diff --git a/tools/perf/util/path.c b/tools/perf/util/path.c
index 58a470d..029661c 100644
--- a/tools/perf/util/path.c
+++ b/tools/perf/util/path.c
@@ -22,6 +22,7 @@ static const char *get_perf_dir(void)
 	return ".";
 }
 
+#ifdef STRLCPY
 size_t strlcpy(char *dest, const char *src, size_t size)
 {
 	size_t ret = strlen(src);
@@ -33,7 +34,7 @@ size_t strlcpy(char *dest, const char *src, size_t size)
 	}
 	return ret;
 }
-
+#endif
 
 static char *get_pathname(void)
 {
-- 
1.7.2.1


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

* [PATCH 2/2] perf: fix build with -Wl,--as-needed
  2010-08-21  0:38 [PATCH 1/2] perf: add test for strlcpy() Kirill A. Shutemov
@ 2010-08-21  0:38 ` Kirill A. Shutemov
  2010-08-21 17:25   ` Arnaldo Carvalho de Melo
  2010-08-21 17:15 ` [PATCH 1/2] perf: add test for strlcpy() Arnaldo Carvalho de Melo
  2010-08-21 20:19 ` [tip:perf/core] perf tools: " tip-bot for Kirill A. Shutemov
  2 siblings, 1 reply; 6+ messages in thread
From: Kirill A. Shutemov @ 2010-08-21  0:38 UTC (permalink / raw)
  To: Peter Zijlstra, Paul Mackerras, Ingo Molnar,
	Arnaldo Carvalho de Melo
  Cc: linux-kernel, Kirill A. Shutemov

We need to put all libraries at the end of linking command to be able to
use -Wl,--as-needed (default in some distributions).

python-config --ldconfig also prints -lpython*, but we need to put it
to EXTLIBS, not to ALL_LDFLAGS.

Let's add call of python-config --libs and put its output to EXTLIBS.

Signed-off-by: Kirill A. Shutemov <kirill@shutemov.name>
---
 tools/perf/Makefile |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/tools/perf/Makefile b/tools/perf/Makefile
index 496a0d6..a5972f6 100644
--- a/tools/perf/Makefile
+++ b/tools/perf/Makefile
@@ -605,12 +605,14 @@ ifdef NO_LIBPYTHON
 	BASIC_CFLAGS += -DNO_LIBPYTHON
 else
 	PYTHON_EMBED_LDOPTS = `python-config --ldflags 2>/dev/null`
+	PYTHON_EMBED_LIBS = `python-config --libs 2>/dev/null`
 	PYTHON_EMBED_CCOPTS = `python-config --cflags 2>/dev/null`
-	FLAGS_PYTHON_EMBED=$(PYTHON_EMBED_CCOPTS) $(PYTHON_EMBED_LDOPTS)
+	FLAGS_PYTHON_EMBED=$(PYTHON_EMBED_CCOPTS) $(PYTHON_EMBED_LDOPTS) $(PYTHON_EMBED_LIBS)
 	ifneq ($(call try-cc,$(SOURCE_PYTHON_EMBED),$(FLAGS_PYTHON_EMBED)),y)
 		BASIC_CFLAGS += -DNO_LIBPYTHON
 	else
 		ALL_LDFLAGS += $(PYTHON_EMBED_LDOPTS)
+		EXTLIBS += $(PYTHON_EMBED_LIBS)
 		LIB_OBJS += $(OUTPUT)util/scripting-engines/trace-event-python.o
 		LIB_OBJS += $(OUTPUT)scripts/python/Perf-Trace-Util/Context.o
 	endif
-- 
1.7.2.1


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

* Re: [PATCH 1/2] perf: add test for strlcpy()
  2010-08-21  0:38 [PATCH 1/2] perf: add test for strlcpy() Kirill A. Shutemov
  2010-08-21  0:38 ` [PATCH 2/2] perf: fix build with -Wl,--as-needed Kirill A. Shutemov
@ 2010-08-21 17:15 ` Arnaldo Carvalho de Melo
  2010-08-21 17:24   ` Kirill A. Shutemov
  2010-08-21 20:19 ` [tip:perf/core] perf tools: " tip-bot for Kirill A. Shutemov
  2 siblings, 1 reply; 6+ messages in thread
From: Arnaldo Carvalho de Melo @ 2010-08-21 17:15 UTC (permalink / raw)
  To: Kirill A. Shutemov
  Cc: Peter Zijlstra, Paul Mackerras, Ingo Molnar, linux-kernel

Em Sat, Aug 21, 2010 at 03:38:20AM +0300, Kirill A. Shutemov escreveu:
> Some Linux distributions like ALT Linux provides patched glibc with
> contains strlcpy(). It's confilcts with strlcpy() from perf.
> 
> Let's add check for strlcpy().

It doesn't work on !ALT Linux ;-\

    LINK /home/acme/git/build/perf//perf
/home/acme/git/build/perf//libperf.a(path.o): In function `perf_vsnpath':
/home/acme/git/linux/tools/perf/util/path.c:74: undefined reference to `strlcpy'
/home/acme/git/build/perf//libperf.a(abspath.o): In function `get_pwd_cwd':
/home/acme/git/linux/tools/perf/util/abspath.c:16: undefined reference to `strlcpy'
/home/acme/git/build/perf//libperf.a(abspath.o): In function `make_nonrelative_path':
/home/acme/git/linux/tools/perf/util/abspath.c:27: undefined reference to `strlcpy'
collect2: ld returned 1 exit status
make: *** [/home/acme/git/build/perf//perf] Error 1
make: Leaving directory `/home/acme/git/linux/tools/perf'
[acme@emilia linux]$ 

See below why:
 
> Signed-off-by: Kirill A. Shutemov <kirill@shutemov.name>
> ---
>  tools/perf/Makefile          |    8 ++++++++
>  tools/perf/feature-tests.mak |   11 +++++++++++
>  tools/perf/util/cache.h      |    2 ++
>  tools/perf/util/path.c       |    3 ++-
>  4 files changed, 23 insertions(+), 1 deletions(-)
> 
> diff --git a/tools/perf/Makefile b/tools/perf/Makefile
> index 4f1fa77..496a0d6 100644
> --- a/tools/perf/Makefile
> +++ b/tools/perf/Makefile
> @@ -653,6 +653,14 @@ else
> diff --git a/tools/perf/util/path.c b/tools/perf/util/path.c
> index 58a470d..029661c 100644
> --- a/tools/perf/util/path.c
> +++ b/tools/perf/util/path.c
> @@ -22,6 +22,7 @@ static const char *get_perf_dir(void)
>  	return ".";
>  }
>  
> +#ifdef STRLCPY

Should be:

+#ifdef NO_STRLCPY

I'm fixing it up.

>  size_t strlcpy(char *dest, const char *src, size_t size)
>  {
>  	size_t ret = strlen(src);
> @@ -33,7 +34,7 @@ size_t strlcpy(char *dest, const char *src, size_t size)
>  	}
>  	return ret;
>  }

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

* Re: [PATCH 1/2] perf: add test for strlcpy()
  2010-08-21 17:15 ` [PATCH 1/2] perf: add test for strlcpy() Arnaldo Carvalho de Melo
@ 2010-08-21 17:24   ` Kirill A. Shutemov
  0 siblings, 0 replies; 6+ messages in thread
From: Kirill A. Shutemov @ 2010-08-21 17:24 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: Peter Zijlstra, Paul Mackerras, Ingo Molnar, linux-kernel

On Sat, Aug 21, 2010 at 02:15:37PM -0300, Arnaldo Carvalho de Melo wrote:
> Em Sat, Aug 21, 2010 at 03:38:20AM +0300, Kirill A. Shutemov escreveu:
> > Some Linux distributions like ALT Linux provides patched glibc with
> > contains strlcpy(). It's confilcts with strlcpy() from perf.
> > 
> > Let's add check for strlcpy().
> 
> It doesn't work on !ALT Linux ;-\
> 
>     LINK /home/acme/git/build/perf//perf
> /home/acme/git/build/perf//libperf.a(path.o): In function `perf_vsnpath':
> /home/acme/git/linux/tools/perf/util/path.c:74: undefined reference to `strlcpy'
> /home/acme/git/build/perf//libperf.a(abspath.o): In function `get_pwd_cwd':
> /home/acme/git/linux/tools/perf/util/abspath.c:16: undefined reference to `strlcpy'
> /home/acme/git/build/perf//libperf.a(abspath.o): In function `make_nonrelative_path':
> /home/acme/git/linux/tools/perf/util/abspath.c:27: undefined reference to `strlcpy'
> collect2: ld returned 1 exit status
> make: *** [/home/acme/git/build/perf//perf] Error 1
> make: Leaving directory `/home/acme/git/linux/tools/perf'
> [acme@emilia linux]$ 
> 
> See below why:
>  
> > Signed-off-by: Kirill A. Shutemov <kirill@shutemov.name>
> > ---
> >  tools/perf/Makefile          |    8 ++++++++
> >  tools/perf/feature-tests.mak |   11 +++++++++++
> >  tools/perf/util/cache.h      |    2 ++
> >  tools/perf/util/path.c       |    3 ++-
> >  4 files changed, 23 insertions(+), 1 deletions(-)
> > 
> > diff --git a/tools/perf/Makefile b/tools/perf/Makefile
> > index 4f1fa77..496a0d6 100644
> > --- a/tools/perf/Makefile
> > +++ b/tools/perf/Makefile
> > @@ -653,6 +653,14 @@ else
> > diff --git a/tools/perf/util/path.c b/tools/perf/util/path.c
> > index 58a470d..029661c 100644
> > --- a/tools/perf/util/path.c
> > +++ b/tools/perf/util/path.c
> > @@ -22,6 +22,7 @@ static const char *get_perf_dir(void)
> >  	return ".";
> >  }
> >  
> > +#ifdef STRLCPY
> 
> Should be:
> 
> +#ifdef NO_STRLCPY
> 

Oops. Sorry.

> I'm fixing it up.
> 
> >  size_t strlcpy(char *dest, const char *src, size_t size)
> >  {
> >  	size_t ret = strlen(src);
> > @@ -33,7 +34,7 @@ size_t strlcpy(char *dest, const char *src, size_t size)
> >  	}
> >  	return ret;
> >  }

-- 
 Kirill A. Shutemov

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

* Re: [PATCH 2/2] perf: fix build with -Wl,--as-needed
  2010-08-21  0:38 ` [PATCH 2/2] perf: fix build with -Wl,--as-needed Kirill A. Shutemov
@ 2010-08-21 17:25   ` Arnaldo Carvalho de Melo
  0 siblings, 0 replies; 6+ messages in thread
From: Arnaldo Carvalho de Melo @ 2010-08-21 17:25 UTC (permalink / raw)
  To: Kirill A. Shutemov
  Cc: Peter Zijlstra, Paul Mackerras, Ingo Molnar, linux-kernel,
	Tom Zanussi, Ozan Çağlayan

Tom,
	Here it is.

- Arnaldo

Em Sat, Aug 21, 2010 at 03:38:21AM +0300, Kirill A. Shutemov escreveu:
> We need to put all libraries at the end of linking command to be able to
> use -Wl,--as-needed (default in some distributions).
> 
> python-config --ldconfig also prints -lpython*, but we need to put it
> to EXTLIBS, not to ALL_LDFLAGS.
> 
> Let's add call of python-config --libs and put its output to EXTLIBS.
> 
> Signed-off-by: Kirill A. Shutemov <kirill@shutemov.name>
> ---
>  tools/perf/Makefile |    4 +++-
>  1 files changed, 3 insertions(+), 1 deletions(-)
> 
> diff --git a/tools/perf/Makefile b/tools/perf/Makefile
> index 496a0d6..a5972f6 100644
> --- a/tools/perf/Makefile
> +++ b/tools/perf/Makefile
> @@ -605,12 +605,14 @@ ifdef NO_LIBPYTHON
>  	BASIC_CFLAGS += -DNO_LIBPYTHON
>  else
>  	PYTHON_EMBED_LDOPTS = `python-config --ldflags 2>/dev/null`
> +	PYTHON_EMBED_LIBS = `python-config --libs 2>/dev/null`
>  	PYTHON_EMBED_CCOPTS = `python-config --cflags 2>/dev/null`
> -	FLAGS_PYTHON_EMBED=$(PYTHON_EMBED_CCOPTS) $(PYTHON_EMBED_LDOPTS)
> +	FLAGS_PYTHON_EMBED=$(PYTHON_EMBED_CCOPTS) $(PYTHON_EMBED_LDOPTS) $(PYTHON_EMBED_LIBS)
>  	ifneq ($(call try-cc,$(SOURCE_PYTHON_EMBED),$(FLAGS_PYTHON_EMBED)),y)
>  		BASIC_CFLAGS += -DNO_LIBPYTHON
>  	else
>  		ALL_LDFLAGS += $(PYTHON_EMBED_LDOPTS)
> +		EXTLIBS += $(PYTHON_EMBED_LIBS)
>  		LIB_OBJS += $(OUTPUT)util/scripting-engines/trace-event-python.o
>  		LIB_OBJS += $(OUTPUT)scripts/python/Perf-Trace-Util/Context.o
>  	endif
> -- 
> 1.7.2.1

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

* [tip:perf/core] perf tools: add test for strlcpy()
  2010-08-21  0:38 [PATCH 1/2] perf: add test for strlcpy() Kirill A. Shutemov
  2010-08-21  0:38 ` [PATCH 2/2] perf: fix build with -Wl,--as-needed Kirill A. Shutemov
  2010-08-21 17:15 ` [PATCH 1/2] perf: add test for strlcpy() Arnaldo Carvalho de Melo
@ 2010-08-21 20:19 ` tip-bot for Kirill A. Shutemov
  2 siblings, 0 replies; 6+ messages in thread
From: tip-bot for Kirill A. Shutemov @ 2010-08-21 20:19 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: acme, linux-kernel, paulus, hpa, mingo, a.p.zijlstra, tglx,
	kirill, mingo

Commit-ID:  f4e7ac0a233a4dc9b51345546ab69c64bb43e2c1
Gitweb:     http://git.kernel.org/tip/f4e7ac0a233a4dc9b51345546ab69c64bb43e2c1
Author:     Kirill A. Shutemov <kirill@shutemov.name>
AuthorDate: Sat, 21 Aug 2010 03:38:20 +0300
Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Sat, 21 Aug 2010 11:22:47 -0300

perf tools: add test for strlcpy()

Some Linux distributions like ALT Linux provides patched glibc with
contains strlcpy(). It's confilcts with strlcpy() from perf.

Let's add check for strlcpy().

Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Ingo Molnar <mingo@elte.hu>
LKML-Reference: <1282351101-8879-1-git-send-email-kirill@shutemov.name>
Signed-off-by: Kirill A. Shutemov <kirill@shutemov.name>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/Makefile          |    9 +++++++++
 tools/perf/feature-tests.mak |   11 +++++++++++
 tools/perf/util/cache.h      |    2 ++
 tools/perf/util/path.c       |    3 ++-
 4 files changed, 24 insertions(+), 1 deletions(-)

diff --git a/tools/perf/Makefile b/tools/perf/Makefile
index dcb9700..7473de0 100644
--- a/tools/perf/Makefile
+++ b/tools/perf/Makefile
@@ -647,6 +647,15 @@ else
 	endif
 endif
 
+
+ifdef NO_STRLCPY
+	BASIC_CFLAGS += -DNO_STRLCPY
+else
+	ifneq ($(call try-cc,$(SOURCE_STRLCPY),),y)
+		BASIC_CFLAGS += -DNO_STRLCPY
+	endif
+endif
+
 ifndef CC_LD_DYNPATH
 	ifdef NO_R_TO_GCC_LINKER
 		# Some gcc does not accept and pass -R to the linker to specify
diff --git a/tools/perf/feature-tests.mak b/tools/perf/feature-tests.mak
index ddb68e6..ef3d0d6 100644
--- a/tools/perf/feature-tests.mak
+++ b/tools/perf/feature-tests.mak
@@ -110,6 +110,17 @@ int main(void)
 }
 endef
 
+define SOURCE_STRLCPY
+#include <stdlib.h>
+extern size_t strlcpy(char *dest, const char *src, size_t size);
+
+int main(void)
+{
+	strlcpy(NULL, NULL, 0);
+	return 0;
+}
+endef
+
 # try-cc
 # Usage: option = $(call try-cc, source-to-build, cc-options)
 try-cc = $(shell sh -c						  \
diff --git a/tools/perf/util/cache.h b/tools/perf/util/cache.h
index 27e9ebe..a772979 100644
--- a/tools/perf/util/cache.h
+++ b/tools/perf/util/cache.h
@@ -82,6 +82,8 @@ extern char *perf_path(const char *fmt, ...) __attribute__((format (printf, 1, 2
 extern char *perf_pathdup(const char *fmt, ...)
 	__attribute__((format (printf, 1, 2)));
 
+#ifdef NO_STRLCPY
 extern size_t strlcpy(char *dest, const char *src, size_t size);
+#endif
 
 #endif /* __PERF_CACHE_H */
diff --git a/tools/perf/util/path.c b/tools/perf/util/path.c
index 58a470d..bd74977 100644
--- a/tools/perf/util/path.c
+++ b/tools/perf/util/path.c
@@ -22,6 +22,7 @@ static const char *get_perf_dir(void)
 	return ".";
 }
 
+#ifdef NO_STRLCPY
 size_t strlcpy(char *dest, const char *src, size_t size)
 {
 	size_t ret = strlen(src);
@@ -33,7 +34,7 @@ size_t strlcpy(char *dest, const char *src, size_t size)
 	}
 	return ret;
 }
-
+#endif
 
 static char *get_pathname(void)
 {

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

end of thread, other threads:[~2010-08-21 20:19 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-08-21  0:38 [PATCH 1/2] perf: add test for strlcpy() Kirill A. Shutemov
2010-08-21  0:38 ` [PATCH 2/2] perf: fix build with -Wl,--as-needed Kirill A. Shutemov
2010-08-21 17:25   ` Arnaldo Carvalho de Melo
2010-08-21 17:15 ` [PATCH 1/2] perf: add test for strlcpy() Arnaldo Carvalho de Melo
2010-08-21 17:24   ` Kirill A. Shutemov
2010-08-21 20:19 ` [tip:perf/core] perf tools: " tip-bot for Kirill A. Shutemov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox