linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/3] perf tools: Plug jvmti compilation into perf build
@ 2016-11-02 13:35 Jiri Olsa
  2016-11-02 13:35 ` [PATCH 1/3] tools build: Add CFLAGS_REMOVE_* support Jiri Olsa
                   ` (4 more replies)
  0 siblings, 5 replies; 14+ messages in thread
From: Jiri Olsa @ 2016-11-02 13:35 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: lkml, Ingo Molnar, Peter Zijlstra, Andi Kleen, William Cohen,
	Stephane Eranian, Namhyung Kim, David Ahern

hi,
adding jvmti compilation under perf build, so it's easy
to put it under rpm.

I plan on updating fedora/rhel perf rpm, to have the jvmti
placed in like:

  $ rpm -qpl build/x86_64/perf-4.8.5-300.fc24.x86_64.rpm | grep jvmti
  /usr/lib64/libperf-jvmti.so

Stephane,
I'm keeping the jvmti/Makefile as I dont fully follow
the need for .lo objects. Please let me know if you'd
be ok with this new way of building jvmti lib.

Also available in:
  git://git.kernel.org/pub/scm/linux/kernel/git/jolsa/perf.git
  perf/fixes

thanks,
jirla


---
Jiri Olsa (3):
      tools build: Add CFLAGS_REMOVE_* support
      tools build: Add jvmti feature detection support
      perf tools: Plug jvmti compilation into perf build

 tools/build/Build.include           |  4 +++-
 tools/build/Documentation/Build.txt |  6 ++++--
 tools/build/feature/Makefile        |  6 +++++-
 tools/build/feature/test-jvmti.c    | 13 +++++++++++++
 tools/perf/Makefile.config          | 26 ++++++++++++++++++++++++++
 tools/perf/Makefile.perf            | 24 +++++++++++++++++++++++-
 tools/perf/jvmti/Build              |  8 ++++++++
 tools/perf/tests/make               |  2 +-
 8 files changed, 83 insertions(+), 6 deletions(-)
 create mode 100644 tools/build/feature/test-jvmti.c
 create mode 100644 tools/perf/jvmti/Build

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

* [PATCH 1/3] tools build: Add CFLAGS_REMOVE_* support
  2016-11-02 13:35 [PATCH 0/3] perf tools: Plug jvmti compilation into perf build Jiri Olsa
@ 2016-11-02 13:35 ` Jiri Olsa
  2016-11-14 14:36   ` Arnaldo Carvalho de Melo
  2016-11-15 10:41   ` [tip:perf/core] " tip-bot for Jiri Olsa
  2016-11-02 13:35 ` [PATCH 2/3] tools build: Add jvmti feature detection support Jiri Olsa
                   ` (3 subsequent siblings)
  4 siblings, 2 replies; 14+ messages in thread
From: Jiri Olsa @ 2016-11-02 13:35 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: lkml, Ingo Molnar, Peter Zijlstra, Andi Kleen, William Cohen,
	Stephane Eranian, Namhyung Kim, David Ahern

Adding support to remove options from final CFLAGS
for both object file and build target. It's now
possible to remove CFLAGS options like:

  CFLAGS_REMOVE_krava.o += -Wstrict-prototypes

Link: http://lkml.kernel.org/n/tip-0t59dihg30fh035xo69df3m8@git.kernel.org
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
---
 tools/build/Build.include           | 4 +++-
 tools/build/Documentation/Build.txt | 6 ++++--
 2 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/tools/build/Build.include b/tools/build/Build.include
index 1dcb95e76f70..c4ae12a5d0a5 100644
--- a/tools/build/Build.include
+++ b/tools/build/Build.include
@@ -89,7 +89,9 @@ if_changed = $(if $(strip $(any-prereq) $(arg-check)),             \
 # - per target C flags
 # - per object C flags
 # - BUILD_STR macro to allow '-D"$(variable)"' constructs
-c_flags = -Wp,-MD,$(depfile),-MT,$@ $(CFLAGS) -D"BUILD_STR(s)=\#s" $(CFLAGS_$(basetarget).o) $(CFLAGS_$(obj))
+c_flags_1 = -Wp,-MD,$(depfile),-MT,$@ $(CFLAGS) -D"BUILD_STR(s)=\#s" $(CFLAGS_$(basetarget).o) $(CFLAGS_$(obj))
+c_flags_2 = $(filter-out $(CFLAGS_REMOVE_$(basetarget).o), $(c_flags_1))
+c_flags   = $(filter-out $(CFLAGS_REMOVE_$(obj)), $(c_flags_2))
 cxx_flags = -Wp,-MD,$(depfile),-MT,$@ $(CXXFLAGS) -D"BUILD_STR(s)=\#s" $(CXXFLAGS_$(basetarget).o) $(CXXFLAGS_$(obj))
 
 ###
diff --git a/tools/build/Documentation/Build.txt b/tools/build/Documentation/Build.txt
index a47bffbae159..a22587475dbe 100644
--- a/tools/build/Documentation/Build.txt
+++ b/tools/build/Documentation/Build.txt
@@ -135,8 +135,10 @@ CFLAGS
 
 It's possible to alter the standard object C flags in the following way:
 
-  CFLAGS_perf.o += '...' - alters CFLAGS for perf.o object
-  CFLAGS_gtk += '...'    - alters CFLAGS for gtk build object
+  CFLAGS_perf.o        += '...'  - adds CFLAGS for perf.o object
+  CFLAGS_gtk           += '...'  - adds CFLAGS for gtk build object
+  CFLAGS_REMOVE_perf.o += '...'  - removes CFLAGS for perf.o object
+  CFLAGS_REMOVE_gtk    += '...'  - removes CFLAGS for gtk build object
 
 This C flags changes has the scope of the Build makefile they are defined in.
 
-- 
2.7.4

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

* [PATCH 2/3] tools build: Add jvmti feature detection support
  2016-11-02 13:35 [PATCH 0/3] perf tools: Plug jvmti compilation into perf build Jiri Olsa
  2016-11-02 13:35 ` [PATCH 1/3] tools build: Add CFLAGS_REMOVE_* support Jiri Olsa
@ 2016-11-02 13:35 ` Jiri Olsa
  2016-11-15 10:42   ` [tip:perf/core] " tip-bot for Jiri Olsa
  2016-11-02 13:35 ` [PATCH 3/3] perf tools: Plug jvmti compilation into perf build Jiri Olsa
                   ` (2 subsequent siblings)
  4 siblings, 1 reply; 14+ messages in thread
From: Jiri Olsa @ 2016-11-02 13:35 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: lkml, Ingo Molnar, Peter Zijlstra, Andi Kleen, William Cohen,
	Stephane Eranian, Namhyung Kim, David Ahern

Adding support to detect jvmti support. It is not plugged
into the FEATURE_TESTS machinery, because it's quite rare
and will be used separately from perf via feature_check
call.

Link: http://lkml.kernel.org/n/tip-0ijegqf46qirs2azru6gimdi@git.kernel.org
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
---
 tools/build/feature/Makefile     |  6 +++++-
 tools/build/feature/test-jvmti.c | 13 +++++++++++++
 2 files changed, 18 insertions(+), 1 deletion(-)
 create mode 100644 tools/build/feature/test-jvmti.c

diff --git a/tools/build/feature/Makefile b/tools/build/feature/Makefile
index ac9c477a2a48..8f668bce8996 100644
--- a/tools/build/feature/Makefile
+++ b/tools/build/feature/Makefile
@@ -47,7 +47,8 @@ FILES=					\
 	test-bpf.bin			\
 	test-get_cpuid.bin		\
 	test-sdt.bin			\
-	test-cxx.bin
+	test-cxx.bin			\
+	test-jvmti.bin
 
 FILES := $(addprefix $(OUTPUT),$(FILES))
 
@@ -225,6 +226,9 @@ $(OUTPUT)test-sdt.bin:
 $(OUTPUT)test-cxx.bin:
 	$(BUILDXX) -std=gnu++11
 
+$(OUTPUT)test-jvmti.bin:
+	$(BUILD)
+
 -include $(OUTPUT)*.d
 
 ###############################
diff --git a/tools/build/feature/test-jvmti.c b/tools/build/feature/test-jvmti.c
new file mode 100644
index 000000000000..1c665f09b9d6
--- /dev/null
+++ b/tools/build/feature/test-jvmti.c
@@ -0,0 +1,13 @@
+#include <jvmti.h>
+#include <jvmticmlr.h>
+
+int main(void)
+{
+	JavaVM			jvm	__attribute__((unused));
+	jvmtiEventCallbacks	cb	__attribute__((unused));
+	jvmtiCapabilities	caps	__attribute__((unused));
+	jvmtiJlocationFormat	format	__attribute__((unused));
+	jvmtiEnv		jvmti	__attribute__((unused));
+
+	return 0;
+}
-- 
2.7.4

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

* [PATCH 3/3] perf tools: Plug jvmti compilation into perf build
  2016-11-02 13:35 [PATCH 0/3] perf tools: Plug jvmti compilation into perf build Jiri Olsa
  2016-11-02 13:35 ` [PATCH 1/3] tools build: Add CFLAGS_REMOVE_* support Jiri Olsa
  2016-11-02 13:35 ` [PATCH 2/3] tools build: Add jvmti feature detection support Jiri Olsa
@ 2016-11-02 13:35 ` Jiri Olsa
  2016-11-15 10:43   ` [tip:perf/core] perf jvmti: Plug " tip-bot for Jiri Olsa
  2016-11-11  9:51 ` [PATCH 0/3] perf tools: Plug jvmti " Jiri Olsa
  2016-11-11 23:18 ` Stephane Eranian
  4 siblings, 1 reply; 14+ messages in thread
From: Jiri Olsa @ 2016-11-02 13:35 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: lkml, Ingo Molnar, Peter Zijlstra, Andi Kleen, William Cohen,
	Stephane Eranian, Namhyung Kim, David Ahern

Compile jvmti agent as part of the perf build. The agent
library is called libperf-jvmti.so and is installed in
default place together with other files:

  $ make libperf-jvmti.so
    BUILD:   Doing 'make -j4' parallel build
    ...
    CC       jvmti/libjvmti.o
    CC       jvmti/jvmti_agent.o
    LD       jvmti/jvmti-in.o
    LINK     libperf-jvmti.so

  $ make DESTDIR=/tmp/krava/ install-bin
  ...
  $ find /tmp/krava/ | grep libperf
  /tmp/krava/lib64/libperf-jvmti.so
  /tmp/krava/lib64/libperf-gtk.so

Link: http://lkml.kernel.org/n/tip-litdnr71x1ss0jeu3ze9b8h4@git.kernel.org
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
---
 tools/perf/Makefile.config | 26 ++++++++++++++++++++++++++
 tools/perf/Makefile.perf   | 24 +++++++++++++++++++++++-
 tools/perf/jvmti/Build     |  8 ++++++++
 tools/perf/tests/make      |  2 +-
 4 files changed, 58 insertions(+), 2 deletions(-)
 create mode 100644 tools/perf/jvmti/Build

diff --git a/tools/perf/Makefile.config b/tools/perf/Makefile.config
index cffdd9cf3ebf..8a493d46fab9 100644
--- a/tools/perf/Makefile.config
+++ b/tools/perf/Makefile.config
@@ -758,6 +758,31 @@ ifndef NO_AUXTRACE
   endif
 endif
 
+ifndef NO_JVMTI
+  ifneq (,$(wildcard /usr/sbin/update-java-alternatives))
+    JDIR=$(shell /usr/sbin/update-java-alternatives -l | head -1 | awk '{print $$3}')
+  else
+    ifneq (,$(wildcard /usr/sbin/alternatives))
+      JDIR=$(shell alternatives --display java | tail -1 | cut -d' ' -f 5 | sed 's%/jre/bin/java.%%g')
+    endif
+  endif
+  ifndef JDIR
+    $(warning No alternatives command found, you need to set JDIR= to point to the root of your Java directory)
+    NO_JVMTI := 1
+  endif
+endif
+
+ifndef NO_JVMTI
+  FEATURE_CHECK_CFLAGS-jvmti := -I$(JDIR)/include -I$(JDIR)/include/linux
+  $(call feature_check,jvmti)
+  ifeq ($(feature-jvmti), 1)
+    $(call detected_var,JDIR)
+  else
+    $(warning No openjdk development package found, please install JDK package)
+    NO_JVMTI := 1
+  endif
+endif
+
 # Among the variables below, these:
 #   perfexecdir
 #   template_dir
@@ -850,6 +875,7 @@ ifeq ($(VF),1)
   $(call print_var,sysconfdir)
   $(call print_var,LIBUNWIND_DIR)
   $(call print_var,LIBDW_DIR)
+  $(call print_var,JDIR)
 
   ifeq ($(dwarf-post-unwind),1)
     $(call feature_print_text,"DWARF post unwind library", $(dwarf-post-unwind-text))
diff --git a/tools/perf/Makefile.perf b/tools/perf/Makefile.perf
index 7de14f470f3c..3cb1df43ad3e 100644
--- a/tools/perf/Makefile.perf
+++ b/tools/perf/Makefile.perf
@@ -86,6 +86,8 @@ include ../scripts/utilities.mak
 #
 # Define FEATURES_DUMP to provide features detection dump file
 # and bypass the feature detection
+#
+# Define NO_JVMTI if you do not want jvmti agent built
 
 # As per kernel Makefile, avoid funny character set dependencies
 unexport LC_ALL
@@ -283,6 +285,12 @@ ifndef NO_PERF_READ_VDSOX32
 PROGRAMS += $(OUTPUT)perf-read-vdsox32
 endif
 
+LIBJVMTI = libperf-jvmti.so
+
+ifndef NO_JVMTI
+PROGRAMS += $(OUTPUT)$(LIBJVMTI)
+endif
+
 # what 'all' will build and 'install' will install, in perfexecdir
 ALL_PROGRAMS = $(PROGRAMS) $(SCRIPTS)
 
@@ -551,6 +559,16 @@ $(OUTPUT)perf-read-vdsox32: perf-read-vdso.c util/find-vdso-map.c
 	$(QUIET_CC)$(CC) -mx32 $(filter -static,$(LDFLAGS)) -Wall -Werror -o $@ perf-read-vdso.c
 endif
 
+ifndef NO_JVMTI
+LIBJVMTI_IN := $(OUTPUT)jvmti/jvmti-in.o
+
+$(LIBJVMTI_IN): FORCE
+	$(Q)$(MAKE) -f $(srctree)/tools/build/Makefile.build dir=jvmti obj=jvmti
+
+$(OUTPUT)$(LIBJVMTI): $(LIBJVMTI_IN)
+	$(QUIET_LINK)$(CC) -shared -Wl,-soname -Wl,$(LIBJVMTI) -o $@ $< -lelf -lrt
+endif
+
 $(patsubst perf-%,%.o,$(PROGRAMS)): $(wildcard */*.h)
 
 LIBPERF_IN := $(OUTPUT)libperf-in.o
@@ -688,6 +706,10 @@ ifndef NO_PERF_READ_VDSOX32
 	$(call QUIET_INSTALL, perf-read-vdsox32) \
 		$(INSTALL) $(OUTPUT)perf-read-vdsox32 '$(DESTDIR_SQ)$(bindir_SQ)';
 endif
+ifndef NO_JVMTI
+	$(call QUIET_INSTALL, $(LIBJVMTI)) \
+		$(INSTALL) $(OUTPUT)$(LIBJVMTI) '$(DESTDIR_SQ)$(libdir_SQ)';
+endif
 	$(call QUIET_INSTALL, libexec) \
 		$(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(perfexec_instdir_SQ)'
 	$(call QUIET_INSTALL, perf-archive) \
@@ -754,7 +776,7 @@ clean:: $(LIBTRACEEVENT)-clean $(LIBAPI)-clean $(LIBBPF)-clean $(LIBSUBCMD)-clea
 	$(call QUIET_CLEAN, core-objs)  $(RM) $(LIB_FILE) $(OUTPUT)perf-archive $(OUTPUT)perf-with-kcore $(LANG_BINDINGS)
 	$(Q)find $(if $(OUTPUT),$(OUTPUT),.) -name '*.o' -delete -o -name '\.*.cmd' -delete -o -name '\.*.d' -delete
 	$(Q)$(RM) $(OUTPUT).config-detected
-	$(call QUIET_CLEAN, core-progs) $(RM) $(ALL_PROGRAMS) perf perf-read-vdso32 perf-read-vdsox32 $(OUTPUT)pmu-events/jevents
+	$(call QUIET_CLEAN, core-progs) $(RM) $(ALL_PROGRAMS) perf perf-read-vdso32 perf-read-vdsox32 $(OUTPUT)pmu-events/jevents $(OUTPUT)$(LIBJVMTI).so
 	$(call QUIET_CLEAN, core-gen)   $(RM)  *.spec *.pyc *.pyo */*.pyc */*.pyo $(OUTPUT)common-cmds.h TAGS tags cscope* $(OUTPUT)PERF-VERSION-FILE $(OUTPUT)FEATURE-DUMP $(OUTPUT)util/*-bison* $(OUTPUT)util/*-flex* \
 		$(OUTPUT)util/intel-pt-decoder/inat-tables.c $(OUTPUT)fixdep \
 		$(OUTPUT)tests/llvm-src-{base,kbuild,prologue,relocation}.c \
diff --git a/tools/perf/jvmti/Build b/tools/perf/jvmti/Build
new file mode 100644
index 000000000000..eaeb8cb5379b
--- /dev/null
+++ b/tools/perf/jvmti/Build
@@ -0,0 +1,8 @@
+jvmti-y += libjvmti.o
+jvmti-y += jvmti_agent.o
+
+CFLAGS_jvmti         = -fPIC -DPIC -I$(JDIR)/include -I$(JDIR)/include/linux
+CFLAGS_REMOVE_jvmti  = -Wmissing-declarations
+CFLAGS_REMOVE_jvmti += -Wstrict-prototypes
+CFLAGS_REMOVE_jvmti += -Wextra
+CFLAGS_REMOVE_jvmti += -Wwrite-strings
diff --git a/tools/perf/tests/make b/tools/perf/tests/make
index 143f4d549769..08ed7f12cc37 100644
--- a/tools/perf/tests/make
+++ b/tools/perf/tests/make
@@ -106,7 +106,7 @@ make_minimal        := NO_LIBPERL=1 NO_LIBPYTHON=1 NO_NEWT=1 NO_GTK2=1
 make_minimal        += NO_DEMANGLE=1 NO_LIBELF=1 NO_LIBUNWIND=1 NO_BACKTRACE=1
 make_minimal        += NO_LIBNUMA=1 NO_LIBAUDIT=1 NO_LIBBIONIC=1
 make_minimal        += NO_LIBDW_DWARF_UNWIND=1 NO_AUXTRACE=1 NO_LIBBPF=1
-make_minimal        += NO_LIBCRYPTO=1 NO_SDT=1
+make_minimal        += NO_LIBCRYPTO=1 NO_SDT=1 NO_JVMTI=1
 
 # $(run) contains all available tests
 run := make_pure
-- 
2.7.4

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

* Re: [PATCH 0/3] perf tools: Plug jvmti compilation into perf build
  2016-11-02 13:35 [PATCH 0/3] perf tools: Plug jvmti compilation into perf build Jiri Olsa
                   ` (2 preceding siblings ...)
  2016-11-02 13:35 ` [PATCH 3/3] perf tools: Plug jvmti compilation into perf build Jiri Olsa
@ 2016-11-11  9:51 ` Jiri Olsa
  2016-11-11 15:13   ` Stephane Eranian
  2016-11-11 23:18 ` Stephane Eranian
  4 siblings, 1 reply; 14+ messages in thread
From: Jiri Olsa @ 2016-11-11  9:51 UTC (permalink / raw)
  To: Stephane Eranian
  Cc: Arnaldo Carvalho de Melo, lkml, Ingo Molnar, Peter Zijlstra,
	Andi Kleen, William Cohen, Namhyung Kim, David Ahern

On Wed, Nov 02, 2016 at 02:35:46PM +0100, Jiri Olsa wrote:
> hi,
> adding jvmti compilation under perf build, so it's easy
> to put it under rpm.
> 
> I plan on updating fedora/rhel perf rpm, to have the jvmti
> placed in like:
> 
>   $ rpm -qpl build/x86_64/perf-4.8.5-300.fc24.x86_64.rpm | grep jvmti
>   /usr/lib64/libperf-jvmti.so
> 
> Stephane,
> I'm keeping the jvmti/Makefile as I dont fully follow
> the need for .lo objects. Please let me know if you'd
> be ok with this new way of building jvmti lib.

ping

thanks,
jirka

> 
> Also available in:
>   git://git.kernel.org/pub/scm/linux/kernel/git/jolsa/perf.git
>   perf/fixes
> 
> thanks,
> jirla
> 
> 
> ---
> Jiri Olsa (3):
>       tools build: Add CFLAGS_REMOVE_* support
>       tools build: Add jvmti feature detection support
>       perf tools: Plug jvmti compilation into perf build
> 
>  tools/build/Build.include           |  4 +++-
>  tools/build/Documentation/Build.txt |  6 ++++--
>  tools/build/feature/Makefile        |  6 +++++-
>  tools/build/feature/test-jvmti.c    | 13 +++++++++++++
>  tools/perf/Makefile.config          | 26 ++++++++++++++++++++++++++
>  tools/perf/Makefile.perf            | 24 +++++++++++++++++++++++-
>  tools/perf/jvmti/Build              |  8 ++++++++
>  tools/perf/tests/make               |  2 +-
>  8 files changed, 83 insertions(+), 6 deletions(-)
>  create mode 100644 tools/build/feature/test-jvmti.c
>  create mode 100644 tools/perf/jvmti/Build

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

* Re: [PATCH 0/3] perf tools: Plug jvmti compilation into perf build
  2016-11-11  9:51 ` [PATCH 0/3] perf tools: Plug jvmti " Jiri Olsa
@ 2016-11-11 15:13   ` Stephane Eranian
  0 siblings, 0 replies; 14+ messages in thread
From: Stephane Eranian @ 2016-11-11 15:13 UTC (permalink / raw)
  To: Jiri Olsa
  Cc: Arnaldo Carvalho de Melo, lkml, Ingo Molnar, Peter Zijlstra,
	Andi Kleen, William Cohen, Namhyung Kim, David Ahern

On Fri, Nov 11, 2016 at 1:51 AM, Jiri Olsa <jolsa@redhat.com> wrote:
>
> On Wed, Nov 02, 2016 at 02:35:46PM +0100, Jiri Olsa wrote:
> > hi,
> > adding jvmti compilation under perf build, so it's easy
> > to put it under rpm.
> >
> > I plan on updating fedora/rhel perf rpm, to have the jvmti
> > placed in like:
> >
> >   $ rpm -qpl build/x86_64/perf-4.8.5-300.fc24.x86_64.rpm | grep jvmti
> >   /usr/lib64/libperf-jvmti.so
> >
> > Stephane,
> > I'm keeping the jvmti/Makefile as I dont fully follow
> > the need for .lo objects. Please let me know if you'd
> > be ok with this new way of building jvmti lib.
>
> ping

Sorry for the delay. Will look at this today and get back to you.

>
>
>
> thanks,
> jirka
>
> >
> > Also available in:
> >   git://git.kernel.org/pub/scm/linux/kernel/git/jolsa/perf.git
> >   perf/fixes
> >
> > thanks,
> > jirla
> >
> >
> > ---
> > Jiri Olsa (3):
> >       tools build: Add CFLAGS_REMOVE_* support
> >       tools build: Add jvmti feature detection support
> >       perf tools: Plug jvmti compilation into perf build
> >
> >  tools/build/Build.include           |  4 +++-
> >  tools/build/Documentation/Build.txt |  6 ++++--
> >  tools/build/feature/Makefile        |  6 +++++-
> >  tools/build/feature/test-jvmti.c    | 13 +++++++++++++
> >  tools/perf/Makefile.config          | 26 ++++++++++++++++++++++++++
> >  tools/perf/Makefile.perf            | 24 +++++++++++++++++++++++-
> >  tools/perf/jvmti/Build              |  8 ++++++++
> >  tools/perf/tests/make               |  2 +-
> >  8 files changed, 83 insertions(+), 6 deletions(-)
> >  create mode 100644 tools/build/feature/test-jvmti.c
> >  create mode 100644 tools/perf/jvmti/Build

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

* Re: [PATCH 0/3] perf tools: Plug jvmti compilation into perf build
  2016-11-02 13:35 [PATCH 0/3] perf tools: Plug jvmti compilation into perf build Jiri Olsa
                   ` (3 preceding siblings ...)
  2016-11-11  9:51 ` [PATCH 0/3] perf tools: Plug jvmti " Jiri Olsa
@ 2016-11-11 23:18 ` Stephane Eranian
  2016-11-12 12:10   ` [PATCH] perf tools: Remove jvmti/Makefile file Jiri Olsa
  4 siblings, 1 reply; 14+ messages in thread
From: Stephane Eranian @ 2016-11-11 23:18 UTC (permalink / raw)
  To: Jiri Olsa
  Cc: Arnaldo Carvalho de Melo, lkml, Ingo Molnar, Peter Zijlstra,
	Andi Kleen, William Cohen, Namhyung Kim, David Ahern

Jiri,

On Wed, Nov 2, 2016 at 6:35 AM, Jiri Olsa <jolsa@kernel.org> wrote:
> hi,
> adding jvmti compilation under perf build, so it's easy
> to put it under rpm.
>
> I plan on updating fedora/rhel perf rpm, to have the jvmti
> placed in like:
>
>   $ rpm -qpl build/x86_64/perf-4.8.5-300.fc24.x86_64.rpm | grep jvmti
>   /usr/lib64/libperf-jvmti.so
>
> Stephane,
> I'm keeping the jvmti/Makefile as I dont fully follow
> the need for .lo objects. Please let me know if you'd
> be ok with this new way of building jvmti lib.
>
Tested the patch on x86_64. With and without NO_JVMTI.
Tried the libperf-jvmti.so on existing test case, got correct results.

I believe you can now remove the jvmti/Makefile, it is not needed
anymore. We must always (and only) build the .so as this library
is meant to be used as a Java agent.

Tested-by: Stephane Eranian <eranian@google.com>

> Also available in:
>   git://git.kernel.org/pub/scm/linux/kernel/git/jolsa/perf.git
>   perf/fixes
>
> thanks,
> jirla
>
>
> ---
> Jiri Olsa (3):
>       tools build: Add CFLAGS_REMOVE_* support
>       tools build: Add jvmti feature detection support
>       perf tools: Plug jvmti compilation into perf build
>
>  tools/build/Build.include           |  4 +++-
>  tools/build/Documentation/Build.txt |  6 ++++--
>  tools/build/feature/Makefile        |  6 +++++-
>  tools/build/feature/test-jvmti.c    | 13 +++++++++++++
>  tools/perf/Makefile.config          | 26 ++++++++++++++++++++++++++
>  tools/perf/Makefile.perf            | 24 +++++++++++++++++++++++-
>  tools/perf/jvmti/Build              |  8 ++++++++
>  tools/perf/tests/make               |  2 +-
>  8 files changed, 83 insertions(+), 6 deletions(-)
>  create mode 100644 tools/build/feature/test-jvmti.c
>  create mode 100644 tools/perf/jvmti/Build

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

* [PATCH] perf tools: Remove jvmti/Makefile file
  2016-11-11 23:18 ` Stephane Eranian
@ 2016-11-12 12:10   ` Jiri Olsa
  2016-11-15 10:43     ` [tip:perf/core] perf kvmti: Remove unused Makefile file tip-bot for Jiri Olsa
  0 siblings, 1 reply; 14+ messages in thread
From: Jiri Olsa @ 2016-11-12 12:10 UTC (permalink / raw)
  To: Stephane Eranian, Arnaldo Carvalho de Melo
  Cc: Jiri Olsa, lkml, Ingo Molnar, Peter Zijlstra, Andi Kleen,
	William Cohen, Namhyung Kim, David Ahern

On Fri, Nov 11, 2016 at 03:18:03PM -0800, Stephane Eranian wrote:
> Jiri,
> 
> On Wed, Nov 2, 2016 at 6:35 AM, Jiri Olsa <jolsa@kernel.org> wrote:
> > hi,
> > adding jvmti compilation under perf build, so it's easy
> > to put it under rpm.
> >
> > I plan on updating fedora/rhel perf rpm, to have the jvmti
> > placed in like:
> >
> >   $ rpm -qpl build/x86_64/perf-4.8.5-300.fc24.x86_64.rpm | grep jvmti
> >   /usr/lib64/libperf-jvmti.so
> >
> > Stephane,
> > I'm keeping the jvmti/Makefile as I dont fully follow
> > the need for .lo objects. Please let me know if you'd
> > be ok with this new way of building jvmti lib.
> >
> Tested the patch on x86_64. With and without NO_JVMTI.
> Tried the libperf-jvmti.so on existing test case, got correct results.
> 
> I believe you can now remove the jvmti/Makefile, it is not needed
> anymore. We must always (and only) build the .so as this library
> is meant to be used as a Java agent.
> 
> Tested-by: Stephane Eranian <eranian@google.com>

great, attaching the removal patch

Arnaldo,
I rebased my perf/fixes branch, it also contains attached patch

thanks,
jirka


---
Now when jvmti compilation is plugged into Makefile.perf,
there's no need for this makefile.

Link: http://lkml.kernel.org/n/tip-qqz5y4auujk02u888to7cqpn@git.kernel.org
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
---
 tools/perf/jvmti/Makefile | 89 -----------------------------------------------
 1 file changed, 89 deletions(-)
 delete mode 100644 tools/perf/jvmti/Makefile

diff --git a/tools/perf/jvmti/Makefile b/tools/perf/jvmti/Makefile
deleted file mode 100644
index df14e6b67b63..000000000000
--- a/tools/perf/jvmti/Makefile
+++ /dev/null
@@ -1,89 +0,0 @@
-ARCH=$(shell uname -m)
-
-ifeq ($(ARCH), x86_64)
-JARCH=amd64
-endif
-ifeq ($(ARCH), armv7l)
-JARCH=armhf
-endif
-ifeq ($(ARCH), armv6l)
-JARCH=armhf
-endif
-ifeq ($(ARCH), aarch64)
-JARCH=aarch64
-endif
-ifeq ($(ARCH), ppc64)
-JARCH=powerpc
-endif
-ifeq ($(ARCH), ppc64le)
-JARCH=powerpc
-endif
-
-DESTDIR=/usr/local
-
-VERSION=1
-REVISION=0
-AGE=0
-
-LN=ln -sf
-RM=rm
-
-SLIBJVMTI=libjvmti.so.$(VERSION).$(REVISION).$(AGE)
-VLIBJVMTI=libjvmti.so.$(VERSION)
-SLDFLAGS=-shared -Wl,-soname -Wl,$(VLIBJVMTI)
-SOLIBEXT=so
-
-# The following works at least on fedora 23, you may need the next
-# line for other distros.
-ifneq (,$(wildcard /usr/sbin/update-java-alternatives))
-JDIR=$(shell /usr/sbin/update-java-alternatives -l | head -1 | awk '{print $$3}')
-else
-  ifneq (,$(wildcard /usr/sbin/alternatives))
-    JDIR=$(shell alternatives --display java | tail -1 | cut -d' ' -f 5 | sed 's%/jre/bin/java.%%g')
-  endif
-endif
-ifndef JDIR
-$(error Could not find alternatives command, you need to set JDIR= to point to the root of your Java directory)
-else
-  ifeq (,$(wildcard $(JDIR)/include/jvmti.h))
-  $(error the openjdk development package appears to me missing, install and try again)
-  endif
-endif
-$(info Using Java from $(JDIR))
-# -lrt required in 32-bit mode for clock_gettime()
-LIBS=-lelf -lrt
-INCDIR=-I $(JDIR)/include -I $(JDIR)/include/linux
-
-TARGETS=$(SLIBJVMTI)
-
-SRCS=libjvmti.c jvmti_agent.c
-OBJS=$(SRCS:.c=.o)
-SOBJS=$(OBJS:.o=.lo)
-OPT=-O2 -g -Werror -Wall
-
-CFLAGS=$(INCDIR) $(OPT)
-
-all: $(TARGETS)
-
-.c.o:
-	$(CC) $(CFLAGS) -c $*.c
-.c.lo:
-	$(CC) -fPIC -DPIC $(CFLAGS) -c $*.c -o $*.lo
-
-$(OBJS) $(SOBJS): Makefile jvmti_agent.h ../util/jitdump.h
-
-$(SLIBJVMTI):  $(SOBJS)
-	$(CC) $(CFLAGS) $(SLDFLAGS)  -o $@ $(SOBJS) $(LIBS)
-	$(LN) $@ libjvmti.$(SOLIBEXT)
-
-clean:
-	$(RM) -f *.o *.so.* *.so *.lo
-
-install:
-	-mkdir -p $(DESTDIR)/lib
-	install -m 755 $(SLIBJVMTI) $(DESTDIR)/lib/
-	(cd $(DESTDIR)/lib; $(LN) $(SLIBJVMTI) $(VLIBJVMTI))
-	(cd $(DESTDIR)/lib; $(LN) $(SLIBJVMTI) libjvmti.$(SOLIBEXT))
-	ldconfig
-
-.SUFFIXES: .c .S .o .lo
-- 
2.7.4

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

* Re: [PATCH 1/3] tools build: Add CFLAGS_REMOVE_* support
  2016-11-02 13:35 ` [PATCH 1/3] tools build: Add CFLAGS_REMOVE_* support Jiri Olsa
@ 2016-11-14 14:36   ` Arnaldo Carvalho de Melo
  2016-11-14 14:37     ` Arnaldo Carvalho de Melo
  2016-11-15 10:41   ` [tip:perf/core] " tip-bot for Jiri Olsa
  1 sibling, 1 reply; 14+ messages in thread
From: Arnaldo Carvalho de Melo @ 2016-11-14 14:36 UTC (permalink / raw)
  To: Jiri Olsa
  Cc: lkml, Ingo Molnar, Peter Zijlstra, Andi Kleen, William Cohen,
	Stephane Eranian, Namhyung Kim, David Ahern

Em Wed, Nov 02, 2016 at 02:35:47PM +0100, Jiri Olsa escreveu:
> Adding support to remove options from final CFLAGS
> for both object file and build target. It's now
> possible to remove CFLAGS options like:
> 
>   CFLAGS_REMOVE_krava.o += -Wstrict-prototypes

That is cool, and I just looked and this comes from the kernel sources,
is there some place where the subset of such features that is supported
in tools/build is being documented?

Applying it, thanks.

- Arnaldo
 
> Link: http://lkml.kernel.org/n/tip-0t59dihg30fh035xo69df3m8@git.kernel.org
> Signed-off-by: Jiri Olsa <jolsa@kernel.org>
> ---
>  tools/build/Build.include           | 4 +++-
>  tools/build/Documentation/Build.txt | 6 ++++--
>  2 files changed, 7 insertions(+), 3 deletions(-)
> 
> diff --git a/tools/build/Build.include b/tools/build/Build.include
> index 1dcb95e76f70..c4ae12a5d0a5 100644
> --- a/tools/build/Build.include
> +++ b/tools/build/Build.include
> @@ -89,7 +89,9 @@ if_changed = $(if $(strip $(any-prereq) $(arg-check)),             \
>  # - per target C flags
>  # - per object C flags
>  # - BUILD_STR macro to allow '-D"$(variable)"' constructs
> -c_flags = -Wp,-MD,$(depfile),-MT,$@ $(CFLAGS) -D"BUILD_STR(s)=\#s" $(CFLAGS_$(basetarget).o) $(CFLAGS_$(obj))
> +c_flags_1 = -Wp,-MD,$(depfile),-MT,$@ $(CFLAGS) -D"BUILD_STR(s)=\#s" $(CFLAGS_$(basetarget).o) $(CFLAGS_$(obj))
> +c_flags_2 = $(filter-out $(CFLAGS_REMOVE_$(basetarget).o), $(c_flags_1))
> +c_flags   = $(filter-out $(CFLAGS_REMOVE_$(obj)), $(c_flags_2))
>  cxx_flags = -Wp,-MD,$(depfile),-MT,$@ $(CXXFLAGS) -D"BUILD_STR(s)=\#s" $(CXXFLAGS_$(basetarget).o) $(CXXFLAGS_$(obj))
>  
>  ###
> diff --git a/tools/build/Documentation/Build.txt b/tools/build/Documentation/Build.txt
> index a47bffbae159..a22587475dbe 100644
> --- a/tools/build/Documentation/Build.txt
> +++ b/tools/build/Documentation/Build.txt
> @@ -135,8 +135,10 @@ CFLAGS
>  
>  It's possible to alter the standard object C flags in the following way:
>  
> -  CFLAGS_perf.o += '...' - alters CFLAGS for perf.o object
> -  CFLAGS_gtk += '...'    - alters CFLAGS for gtk build object
> +  CFLAGS_perf.o        += '...'  - adds CFLAGS for perf.o object
> +  CFLAGS_gtk           += '...'  - adds CFLAGS for gtk build object
> +  CFLAGS_REMOVE_perf.o += '...'  - removes CFLAGS for perf.o object
> +  CFLAGS_REMOVE_gtk    += '...'  - removes CFLAGS for gtk build object
>  
>  This C flags changes has the scope of the Build makefile they are defined in.
>  
> -- 
> 2.7.4

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

* Re: [PATCH 1/3] tools build: Add CFLAGS_REMOVE_* support
  2016-11-14 14:36   ` Arnaldo Carvalho de Melo
@ 2016-11-14 14:37     ` Arnaldo Carvalho de Melo
  0 siblings, 0 replies; 14+ messages in thread
From: Arnaldo Carvalho de Melo @ 2016-11-14 14:37 UTC (permalink / raw)
  To: Jiri Olsa
  Cc: lkml, Ingo Molnar, Peter Zijlstra, Andi Kleen, William Cohen,
	Stephane Eranian, Namhyung Kim, David Ahern

Em Mon, Nov 14, 2016 at 11:36:14AM -0300, Arnaldo Carvalho de Melo escreveu:
> Em Wed, Nov 02, 2016 at 02:35:47PM +0100, Jiri Olsa escreveu:
> > Adding support to remove options from final CFLAGS
> > for both object file and build target. It's now
> > possible to remove CFLAGS options like:
> > 
> >   CFLAGS_REMOVE_krava.o += -Wstrict-prototypes
> 
> That is cool, and I just looked and this comes from the kernel sources,
> is there some place where the subset of such features that is supported
> in tools/build is being documented?
> 
> Applying it, thanks.

Duh, yeah:

tools/build/Documentation/Build.txt

Nevermind, I'll add a note to the cset log.

- Arnaldo
 
> - Arnaldo
>  
> > Link: http://lkml.kernel.org/n/tip-0t59dihg30fh035xo69df3m8@git.kernel.org
> > Signed-off-by: Jiri Olsa <jolsa@kernel.org>
> > ---
> >  tools/build/Build.include           | 4 +++-
> >  tools/build/Documentation/Build.txt | 6 ++++--
> >  2 files changed, 7 insertions(+), 3 deletions(-)
> > 
> > diff --git a/tools/build/Build.include b/tools/build/Build.include
> > index 1dcb95e76f70..c4ae12a5d0a5 100644
> > --- a/tools/build/Build.include
> > +++ b/tools/build/Build.include
> > @@ -89,7 +89,9 @@ if_changed = $(if $(strip $(any-prereq) $(arg-check)),             \
> >  # - per target C flags
> >  # - per object C flags
> >  # - BUILD_STR macro to allow '-D"$(variable)"' constructs
> > -c_flags = -Wp,-MD,$(depfile),-MT,$@ $(CFLAGS) -D"BUILD_STR(s)=\#s" $(CFLAGS_$(basetarget).o) $(CFLAGS_$(obj))
> > +c_flags_1 = -Wp,-MD,$(depfile),-MT,$@ $(CFLAGS) -D"BUILD_STR(s)=\#s" $(CFLAGS_$(basetarget).o) $(CFLAGS_$(obj))
> > +c_flags_2 = $(filter-out $(CFLAGS_REMOVE_$(basetarget).o), $(c_flags_1))
> > +c_flags   = $(filter-out $(CFLAGS_REMOVE_$(obj)), $(c_flags_2))
> >  cxx_flags = -Wp,-MD,$(depfile),-MT,$@ $(CXXFLAGS) -D"BUILD_STR(s)=\#s" $(CXXFLAGS_$(basetarget).o) $(CXXFLAGS_$(obj))
> >  
> >  ###
> > diff --git a/tools/build/Documentation/Build.txt b/tools/build/Documentation/Build.txt
> > index a47bffbae159..a22587475dbe 100644
> > --- a/tools/build/Documentation/Build.txt
> > +++ b/tools/build/Documentation/Build.txt
> > @@ -135,8 +135,10 @@ CFLAGS
> >  
> >  It's possible to alter the standard object C flags in the following way:
> >  
> > -  CFLAGS_perf.o += '...' - alters CFLAGS for perf.o object
> > -  CFLAGS_gtk += '...'    - alters CFLAGS for gtk build object
> > +  CFLAGS_perf.o        += '...'  - adds CFLAGS for perf.o object
> > +  CFLAGS_gtk           += '...'  - adds CFLAGS for gtk build object
> > +  CFLAGS_REMOVE_perf.o += '...'  - removes CFLAGS for perf.o object
> > +  CFLAGS_REMOVE_gtk    += '...'  - removes CFLAGS for gtk build object
> >  
> >  This C flags changes has the scope of the Build makefile they are defined in.
> >  
> > -- 
> > 2.7.4

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

* [tip:perf/core] tools build: Add CFLAGS_REMOVE_* support
  2016-11-02 13:35 ` [PATCH 1/3] tools build: Add CFLAGS_REMOVE_* support Jiri Olsa
  2016-11-14 14:36   ` Arnaldo Carvalho de Melo
@ 2016-11-15 10:41   ` tip-bot for Jiri Olsa
  1 sibling, 0 replies; 14+ messages in thread
From: tip-bot for Jiri Olsa @ 2016-11-15 10:41 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: andi, namhyung, dsahern, tglx, hpa, acme, mingo, eranian,
	a.p.zijlstra, jolsa, wcohen, linux-kernel

Commit-ID:  2ec8107d8e0d1d285b2bbf1999e7f4e46b6b535b
Gitweb:     http://git.kernel.org/tip/2ec8107d8e0d1d285b2bbf1999e7f4e46b6b535b
Author:     Jiri Olsa <jolsa@kernel.org>
AuthorDate: Wed, 2 Nov 2016 14:35:47 +0100
Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Mon, 14 Nov 2016 11:37:25 -0300

tools build: Add CFLAGS_REMOVE_* support

Adding support to remove options from final CFLAGS for both object file
and build target. It's now possible to remove CFLAGS options like:

  CFLAGS_REMOVE_krava.o += -Wstrict-prototypes

Committer notes:

This comes from the kernel's kbuild infrastructure, the subset that is
supported in tools/ is being documented at tools/build/Documentation/Build.txt.

Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Tested-by: Stephane Eranian <eranian@google.com>
Cc: Andi Kleen <andi@firstfloor.org>
Cc: David Ahern <dsahern@gmail.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: William Cohen <wcohen@redhat.com>
Link: http://lkml.kernel.org/r/1478093749-5602-2-git-send-email-jolsa@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/build/Build.include           | 4 +++-
 tools/build/Documentation/Build.txt | 6 ++++--
 2 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/tools/build/Build.include b/tools/build/Build.include
index 1dcb95e..c4ae12a 100644
--- a/tools/build/Build.include
+++ b/tools/build/Build.include
@@ -89,7 +89,9 @@ if_changed = $(if $(strip $(any-prereq) $(arg-check)),             \
 # - per target C flags
 # - per object C flags
 # - BUILD_STR macro to allow '-D"$(variable)"' constructs
-c_flags = -Wp,-MD,$(depfile),-MT,$@ $(CFLAGS) -D"BUILD_STR(s)=\#s" $(CFLAGS_$(basetarget).o) $(CFLAGS_$(obj))
+c_flags_1 = -Wp,-MD,$(depfile),-MT,$@ $(CFLAGS) -D"BUILD_STR(s)=\#s" $(CFLAGS_$(basetarget).o) $(CFLAGS_$(obj))
+c_flags_2 = $(filter-out $(CFLAGS_REMOVE_$(basetarget).o), $(c_flags_1))
+c_flags   = $(filter-out $(CFLAGS_REMOVE_$(obj)), $(c_flags_2))
 cxx_flags = -Wp,-MD,$(depfile),-MT,$@ $(CXXFLAGS) -D"BUILD_STR(s)=\#s" $(CXXFLAGS_$(basetarget).o) $(CXXFLAGS_$(obj))
 
 ###
diff --git a/tools/build/Documentation/Build.txt b/tools/build/Documentation/Build.txt
index a47bffb..a225874 100644
--- a/tools/build/Documentation/Build.txt
+++ b/tools/build/Documentation/Build.txt
@@ -135,8 +135,10 @@ CFLAGS
 
 It's possible to alter the standard object C flags in the following way:
 
-  CFLAGS_perf.o += '...' - alters CFLAGS for perf.o object
-  CFLAGS_gtk += '...'    - alters CFLAGS for gtk build object
+  CFLAGS_perf.o        += '...'  - adds CFLAGS for perf.o object
+  CFLAGS_gtk           += '...'  - adds CFLAGS for gtk build object
+  CFLAGS_REMOVE_perf.o += '...'  - removes CFLAGS for perf.o object
+  CFLAGS_REMOVE_gtk    += '...'  - removes CFLAGS for gtk build object
 
 This C flags changes has the scope of the Build makefile they are defined in.
 

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

* [tip:perf/core] tools build: Add jvmti feature detection support
  2016-11-02 13:35 ` [PATCH 2/3] tools build: Add jvmti feature detection support Jiri Olsa
@ 2016-11-15 10:42   ` tip-bot for Jiri Olsa
  0 siblings, 0 replies; 14+ messages in thread
From: tip-bot for Jiri Olsa @ 2016-11-15 10:42 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: a.p.zijlstra, linux-kernel, hpa, eranian, andi, tglx, mingo,
	dsahern, acme, wcohen, jolsa, namhyung

Commit-ID:  285932a25879602407f207e862bc5b8416711f42
Gitweb:     http://git.kernel.org/tip/285932a25879602407f207e862bc5b8416711f42
Author:     Jiri Olsa <jolsa@kernel.org>
AuthorDate: Wed, 2 Nov 2016 14:35:48 +0100
Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Mon, 14 Nov 2016 12:40:32 -0300

tools build: Add jvmti feature detection support

Adding support to detect jvmti support. It is not plugged into the
FEATURE_TESTS machinery, because it's quite rare and will be used
separately from perf via feature_check call.

Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Tested-by: Stephane Eranian <eranian@google.com>
Cc: Andi Kleen <andi@firstfloor.org>
Cc: David Ahern <dsahern@gmail.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: William Cohen <wcohen@redhat.com>
Link: http://lkml.kernel.org/r/1478093749-5602-3-git-send-email-jolsa@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/build/feature/Makefile     |  6 +++++-
 tools/build/feature/test-jvmti.c | 13 +++++++++++++
 2 files changed, 18 insertions(+), 1 deletion(-)

diff --git a/tools/build/feature/Makefile b/tools/build/feature/Makefile
index ac9c477..8f668bc 100644
--- a/tools/build/feature/Makefile
+++ b/tools/build/feature/Makefile
@@ -47,7 +47,8 @@ FILES=					\
 	test-bpf.bin			\
 	test-get_cpuid.bin		\
 	test-sdt.bin			\
-	test-cxx.bin
+	test-cxx.bin			\
+	test-jvmti.bin
 
 FILES := $(addprefix $(OUTPUT),$(FILES))
 
@@ -225,6 +226,9 @@ $(OUTPUT)test-sdt.bin:
 $(OUTPUT)test-cxx.bin:
 	$(BUILDXX) -std=gnu++11
 
+$(OUTPUT)test-jvmti.bin:
+	$(BUILD)
+
 -include $(OUTPUT)*.d
 
 ###############################
diff --git a/tools/build/feature/test-jvmti.c b/tools/build/feature/test-jvmti.c
new file mode 100644
index 0000000..1c665f0
--- /dev/null
+++ b/tools/build/feature/test-jvmti.c
@@ -0,0 +1,13 @@
+#include <jvmti.h>
+#include <jvmticmlr.h>
+
+int main(void)
+{
+	JavaVM			jvm	__attribute__((unused));
+	jvmtiEventCallbacks	cb	__attribute__((unused));
+	jvmtiCapabilities	caps	__attribute__((unused));
+	jvmtiJlocationFormat	format	__attribute__((unused));
+	jvmtiEnv		jvmti	__attribute__((unused));
+
+	return 0;
+}

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

* [tip:perf/core] perf jvmti: Plug compilation into perf build
  2016-11-02 13:35 ` [PATCH 3/3] perf tools: Plug jvmti compilation into perf build Jiri Olsa
@ 2016-11-15 10:43   ` tip-bot for Jiri Olsa
  0 siblings, 0 replies; 14+ messages in thread
From: tip-bot for Jiri Olsa @ 2016-11-15 10:43 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: mingo, a.p.zijlstra, andi, eranian, namhyung, dsahern, wcohen,
	linux-kernel, hpa, jolsa, acme, tglx

Commit-ID:  d4dfdf00d43e017dc57372566ceba0e5e1595eba
Gitweb:     http://git.kernel.org/tip/d4dfdf00d43e017dc57372566ceba0e5e1595eba
Author:     Jiri Olsa <jolsa@kernel.org>
AuthorDate: Wed, 2 Nov 2016 14:35:49 +0100
Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Mon, 14 Nov 2016 12:42:47 -0300

perf jvmti: Plug compilation into perf build

Compile jvmti agent as part of the perf build. The agent library is
called libperf-jvmti.so and is installed in default place together with
other files:

  $ make libperf-jvmti.so
    BUILD:   Doing 'make -j4' parallel build
    ...
    CC       jvmti/libjvmti.o
    CC       jvmti/jvmti_agent.o
    LD       jvmti/jvmti-in.o
    LINK     libperf-jvmti.so

  $ make DESTDIR=/tmp/krava/ install-bin
  ...
  $ find /tmp/krava/ | grep libperf
  /tmp/krava/lib64/libperf-jvmti.so
  /tmp/krava/lib64/libperf-gtk.so

Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Tested-by: Stephane Eranian <eranian@google.com>
Cc: Andi Kleen <andi@firstfloor.org>
Cc: David Ahern <dsahern@gmail.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: William Cohen <wcohen@redhat.com>
Link: http://lkml.kernel.org/r/1478093749-5602-4-git-send-email-jolsa@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/Makefile.config | 26 ++++++++++++++++++++++++++
 tools/perf/Makefile.perf   | 24 +++++++++++++++++++++++-
 tools/perf/jvmti/Build     |  8 ++++++++
 tools/perf/tests/make      |  2 +-
 4 files changed, 58 insertions(+), 2 deletions(-)

diff --git a/tools/perf/Makefile.config b/tools/perf/Makefile.config
index cffdd9c..8a493d4 100644
--- a/tools/perf/Makefile.config
+++ b/tools/perf/Makefile.config
@@ -758,6 +758,31 @@ ifndef NO_AUXTRACE
   endif
 endif
 
+ifndef NO_JVMTI
+  ifneq (,$(wildcard /usr/sbin/update-java-alternatives))
+    JDIR=$(shell /usr/sbin/update-java-alternatives -l | head -1 | awk '{print $$3}')
+  else
+    ifneq (,$(wildcard /usr/sbin/alternatives))
+      JDIR=$(shell alternatives --display java | tail -1 | cut -d' ' -f 5 | sed 's%/jre/bin/java.%%g')
+    endif
+  endif
+  ifndef JDIR
+    $(warning No alternatives command found, you need to set JDIR= to point to the root of your Java directory)
+    NO_JVMTI := 1
+  endif
+endif
+
+ifndef NO_JVMTI
+  FEATURE_CHECK_CFLAGS-jvmti := -I$(JDIR)/include -I$(JDIR)/include/linux
+  $(call feature_check,jvmti)
+  ifeq ($(feature-jvmti), 1)
+    $(call detected_var,JDIR)
+  else
+    $(warning No openjdk development package found, please install JDK package)
+    NO_JVMTI := 1
+  endif
+endif
+
 # Among the variables below, these:
 #   perfexecdir
 #   template_dir
@@ -850,6 +875,7 @@ ifeq ($(VF),1)
   $(call print_var,sysconfdir)
   $(call print_var,LIBUNWIND_DIR)
   $(call print_var,LIBDW_DIR)
+  $(call print_var,JDIR)
 
   ifeq ($(dwarf-post-unwind),1)
     $(call feature_print_text,"DWARF post unwind library", $(dwarf-post-unwind-text))
diff --git a/tools/perf/Makefile.perf b/tools/perf/Makefile.perf
index 7de14f4..3cb1df4 100644
--- a/tools/perf/Makefile.perf
+++ b/tools/perf/Makefile.perf
@@ -86,6 +86,8 @@ include ../scripts/utilities.mak
 #
 # Define FEATURES_DUMP to provide features detection dump file
 # and bypass the feature detection
+#
+# Define NO_JVMTI if you do not want jvmti agent built
 
 # As per kernel Makefile, avoid funny character set dependencies
 unexport LC_ALL
@@ -283,6 +285,12 @@ ifndef NO_PERF_READ_VDSOX32
 PROGRAMS += $(OUTPUT)perf-read-vdsox32
 endif
 
+LIBJVMTI = libperf-jvmti.so
+
+ifndef NO_JVMTI
+PROGRAMS += $(OUTPUT)$(LIBJVMTI)
+endif
+
 # what 'all' will build and 'install' will install, in perfexecdir
 ALL_PROGRAMS = $(PROGRAMS) $(SCRIPTS)
 
@@ -551,6 +559,16 @@ $(OUTPUT)perf-read-vdsox32: perf-read-vdso.c util/find-vdso-map.c
 	$(QUIET_CC)$(CC) -mx32 $(filter -static,$(LDFLAGS)) -Wall -Werror -o $@ perf-read-vdso.c
 endif
 
+ifndef NO_JVMTI
+LIBJVMTI_IN := $(OUTPUT)jvmti/jvmti-in.o
+
+$(LIBJVMTI_IN): FORCE
+	$(Q)$(MAKE) -f $(srctree)/tools/build/Makefile.build dir=jvmti obj=jvmti
+
+$(OUTPUT)$(LIBJVMTI): $(LIBJVMTI_IN)
+	$(QUIET_LINK)$(CC) -shared -Wl,-soname -Wl,$(LIBJVMTI) -o $@ $< -lelf -lrt
+endif
+
 $(patsubst perf-%,%.o,$(PROGRAMS)): $(wildcard */*.h)
 
 LIBPERF_IN := $(OUTPUT)libperf-in.o
@@ -688,6 +706,10 @@ ifndef NO_PERF_READ_VDSOX32
 	$(call QUIET_INSTALL, perf-read-vdsox32) \
 		$(INSTALL) $(OUTPUT)perf-read-vdsox32 '$(DESTDIR_SQ)$(bindir_SQ)';
 endif
+ifndef NO_JVMTI
+	$(call QUIET_INSTALL, $(LIBJVMTI)) \
+		$(INSTALL) $(OUTPUT)$(LIBJVMTI) '$(DESTDIR_SQ)$(libdir_SQ)';
+endif
 	$(call QUIET_INSTALL, libexec) \
 		$(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(perfexec_instdir_SQ)'
 	$(call QUIET_INSTALL, perf-archive) \
@@ -754,7 +776,7 @@ clean:: $(LIBTRACEEVENT)-clean $(LIBAPI)-clean $(LIBBPF)-clean $(LIBSUBCMD)-clea
 	$(call QUIET_CLEAN, core-objs)  $(RM) $(LIB_FILE) $(OUTPUT)perf-archive $(OUTPUT)perf-with-kcore $(LANG_BINDINGS)
 	$(Q)find $(if $(OUTPUT),$(OUTPUT),.) -name '*.o' -delete -o -name '\.*.cmd' -delete -o -name '\.*.d' -delete
 	$(Q)$(RM) $(OUTPUT).config-detected
-	$(call QUIET_CLEAN, core-progs) $(RM) $(ALL_PROGRAMS) perf perf-read-vdso32 perf-read-vdsox32 $(OUTPUT)pmu-events/jevents
+	$(call QUIET_CLEAN, core-progs) $(RM) $(ALL_PROGRAMS) perf perf-read-vdso32 perf-read-vdsox32 $(OUTPUT)pmu-events/jevents $(OUTPUT)$(LIBJVMTI).so
 	$(call QUIET_CLEAN, core-gen)   $(RM)  *.spec *.pyc *.pyo */*.pyc */*.pyo $(OUTPUT)common-cmds.h TAGS tags cscope* $(OUTPUT)PERF-VERSION-FILE $(OUTPUT)FEATURE-DUMP $(OUTPUT)util/*-bison* $(OUTPUT)util/*-flex* \
 		$(OUTPUT)util/intel-pt-decoder/inat-tables.c $(OUTPUT)fixdep \
 		$(OUTPUT)tests/llvm-src-{base,kbuild,prologue,relocation}.c \
diff --git a/tools/perf/jvmti/Build b/tools/perf/jvmti/Build
new file mode 100644
index 0000000..eaeb8cb
--- /dev/null
+++ b/tools/perf/jvmti/Build
@@ -0,0 +1,8 @@
+jvmti-y += libjvmti.o
+jvmti-y += jvmti_agent.o
+
+CFLAGS_jvmti         = -fPIC -DPIC -I$(JDIR)/include -I$(JDIR)/include/linux
+CFLAGS_REMOVE_jvmti  = -Wmissing-declarations
+CFLAGS_REMOVE_jvmti += -Wstrict-prototypes
+CFLAGS_REMOVE_jvmti += -Wextra
+CFLAGS_REMOVE_jvmti += -Wwrite-strings
diff --git a/tools/perf/tests/make b/tools/perf/tests/make
index 143f4d5..08ed7f1 100644
--- a/tools/perf/tests/make
+++ b/tools/perf/tests/make
@@ -106,7 +106,7 @@ make_minimal        := NO_LIBPERL=1 NO_LIBPYTHON=1 NO_NEWT=1 NO_GTK2=1
 make_minimal        += NO_DEMANGLE=1 NO_LIBELF=1 NO_LIBUNWIND=1 NO_BACKTRACE=1
 make_minimal        += NO_LIBNUMA=1 NO_LIBAUDIT=1 NO_LIBBIONIC=1
 make_minimal        += NO_LIBDW_DWARF_UNWIND=1 NO_AUXTRACE=1 NO_LIBBPF=1
-make_minimal        += NO_LIBCRYPTO=1 NO_SDT=1
+make_minimal        += NO_LIBCRYPTO=1 NO_SDT=1 NO_JVMTI=1
 
 # $(run) contains all available tests
 run := make_pure

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

* [tip:perf/core] perf kvmti: Remove unused Makefile file
  2016-11-12 12:10   ` [PATCH] perf tools: Remove jvmti/Makefile file Jiri Olsa
@ 2016-11-15 10:43     ` tip-bot for Jiri Olsa
  0 siblings, 0 replies; 14+ messages in thread
From: tip-bot for Jiri Olsa @ 2016-11-15 10:43 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: jolsa, dsahern, andi, jolsa, eranian, mingo, tglx, namhyung,
	acme, a.p.zijlstra, hpa, wcohen, linux-kernel

Commit-ID:  8c9c3d2f950cca57f5fa9330c4d15d8f0dfda092
Gitweb:     http://git.kernel.org/tip/8c9c3d2f950cca57f5fa9330c4d15d8f0dfda092
Author:     Jiri Olsa <jolsa@redhat.com>
AuthorDate: Sat, 12 Nov 2016 13:10:16 +0100
Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Mon, 14 Nov 2016 12:42:56 -0300

perf kvmti: Remove unused Makefile file

Now when jvmti compilation is plugged into Makefile.perf, there's no
need for this makefile.

Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Acked-by: Stephane Eranian <eranian@google.com>
Cc: Andi Kleen <andi@firstfloor.org>
Cc: David Ahern <dsahern@gmail.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: William Cohen <wcohen@redhat.com>
Link: http://lkml.kernel.org/r/20161112121016.GA17194@krava
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/jvmti/Makefile | 89 -----------------------------------------------
 1 file changed, 89 deletions(-)

diff --git a/tools/perf/jvmti/Makefile b/tools/perf/jvmti/Makefile
deleted file mode 100644
index df14e6b..0000000
--- a/tools/perf/jvmti/Makefile
+++ /dev/null
@@ -1,89 +0,0 @@
-ARCH=$(shell uname -m)
-
-ifeq ($(ARCH), x86_64)
-JARCH=amd64
-endif
-ifeq ($(ARCH), armv7l)
-JARCH=armhf
-endif
-ifeq ($(ARCH), armv6l)
-JARCH=armhf
-endif
-ifeq ($(ARCH), aarch64)
-JARCH=aarch64
-endif
-ifeq ($(ARCH), ppc64)
-JARCH=powerpc
-endif
-ifeq ($(ARCH), ppc64le)
-JARCH=powerpc
-endif
-
-DESTDIR=/usr/local
-
-VERSION=1
-REVISION=0
-AGE=0
-
-LN=ln -sf
-RM=rm
-
-SLIBJVMTI=libjvmti.so.$(VERSION).$(REVISION).$(AGE)
-VLIBJVMTI=libjvmti.so.$(VERSION)
-SLDFLAGS=-shared -Wl,-soname -Wl,$(VLIBJVMTI)
-SOLIBEXT=so
-
-# The following works at least on fedora 23, you may need the next
-# line for other distros.
-ifneq (,$(wildcard /usr/sbin/update-java-alternatives))
-JDIR=$(shell /usr/sbin/update-java-alternatives -l | head -1 | awk '{print $$3}')
-else
-  ifneq (,$(wildcard /usr/sbin/alternatives))
-    JDIR=$(shell alternatives --display java | tail -1 | cut -d' ' -f 5 | sed 's%/jre/bin/java.%%g')
-  endif
-endif
-ifndef JDIR
-$(error Could not find alternatives command, you need to set JDIR= to point to the root of your Java directory)
-else
-  ifeq (,$(wildcard $(JDIR)/include/jvmti.h))
-  $(error the openjdk development package appears to me missing, install and try again)
-  endif
-endif
-$(info Using Java from $(JDIR))
-# -lrt required in 32-bit mode for clock_gettime()
-LIBS=-lelf -lrt
-INCDIR=-I $(JDIR)/include -I $(JDIR)/include/linux
-
-TARGETS=$(SLIBJVMTI)
-
-SRCS=libjvmti.c jvmti_agent.c
-OBJS=$(SRCS:.c=.o)
-SOBJS=$(OBJS:.o=.lo)
-OPT=-O2 -g -Werror -Wall
-
-CFLAGS=$(INCDIR) $(OPT)
-
-all: $(TARGETS)
-
-.c.o:
-	$(CC) $(CFLAGS) -c $*.c
-.c.lo:
-	$(CC) -fPIC -DPIC $(CFLAGS) -c $*.c -o $*.lo
-
-$(OBJS) $(SOBJS): Makefile jvmti_agent.h ../util/jitdump.h
-
-$(SLIBJVMTI):  $(SOBJS)
-	$(CC) $(CFLAGS) $(SLDFLAGS)  -o $@ $(SOBJS) $(LIBS)
-	$(LN) $@ libjvmti.$(SOLIBEXT)
-
-clean:
-	$(RM) -f *.o *.so.* *.so *.lo
-
-install:
-	-mkdir -p $(DESTDIR)/lib
-	install -m 755 $(SLIBJVMTI) $(DESTDIR)/lib/
-	(cd $(DESTDIR)/lib; $(LN) $(SLIBJVMTI) $(VLIBJVMTI))
-	(cd $(DESTDIR)/lib; $(LN) $(SLIBJVMTI) libjvmti.$(SOLIBEXT))
-	ldconfig
-
-.SUFFIXES: .c .S .o .lo

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

end of thread, other threads:[~2016-11-15 10:44 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-11-02 13:35 [PATCH 0/3] perf tools: Plug jvmti compilation into perf build Jiri Olsa
2016-11-02 13:35 ` [PATCH 1/3] tools build: Add CFLAGS_REMOVE_* support Jiri Olsa
2016-11-14 14:36   ` Arnaldo Carvalho de Melo
2016-11-14 14:37     ` Arnaldo Carvalho de Melo
2016-11-15 10:41   ` [tip:perf/core] " tip-bot for Jiri Olsa
2016-11-02 13:35 ` [PATCH 2/3] tools build: Add jvmti feature detection support Jiri Olsa
2016-11-15 10:42   ` [tip:perf/core] " tip-bot for Jiri Olsa
2016-11-02 13:35 ` [PATCH 3/3] perf tools: Plug jvmti compilation into perf build Jiri Olsa
2016-11-15 10:43   ` [tip:perf/core] perf jvmti: Plug " tip-bot for Jiri Olsa
2016-11-11  9:51 ` [PATCH 0/3] perf tools: Plug jvmti " Jiri Olsa
2016-11-11 15:13   ` Stephane Eranian
2016-11-11 23:18 ` Stephane Eranian
2016-11-12 12:10   ` [PATCH] perf tools: Remove jvmti/Makefile file Jiri Olsa
2016-11-15 10:43     ` [tip:perf/core] perf kvmti: Remove unused Makefile file tip-bot for Jiri Olsa

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).