The Linux Kernel Mailing List
 help / color / mirror / Atom feed
* [PATCH] perf build: Fix LTO build of libperf-jvmti.so
@ 2026-07-01  4:21 Trevor Allison
  2026-07-09  0:12 ` Namhyung Kim
  0 siblings, 1 reply; 3+ messages in thread
From: Trevor Allison @ 2026-07-01  4:21 UTC (permalink / raw)
  To: peterz, mingo, acme, namhyung
  Cc: mark.rutland, alexander.shishkin, jolsa, irogers, adrian.hunter,
	james.clark, linux-perf-users, linux-kernel, tallison

Linking libperf-jvmti.so through jvmti-in.o (ld -r) breaks LTO when
-flto is passed via LDFLAGS.  Link the JVMTI object files directly
instead, and pass any LTO flags from LDFLAGS to the JVMTI compile step

Signed-off-by: Trevor Allison <tallison@redhat.com>
---
 tools/perf/Makefile.perf | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/tools/perf/Makefile.perf b/tools/perf/Makefile.perf
index 3f0544d37a7f..bc66d711fa39 100644
--- a/tools/perf/Makefile.perf
+++ b/tools/perf/Makefile.perf
@@ -686,10 +686,12 @@ ifndef NO_JVMTI
 LIBJVMTI_IN := $(OUTPUT)jvmti/jvmti-in.o
 
 $(LIBJVMTI_IN): prepare FORCE
-	$(Q)$(MAKE) -f $(srctree)/tools/build/Makefile.build dir=jvmti obj=jvmti
+	$(Q)$(MAKE) -f $(srctree)/tools/build/Makefile.build dir=jvmti obj=jvmti \
+		CFLAGS="$(CFLAGS) $(filter -flto% -ffat-lto-objects,$(LDFLAGS))"
 
 $(OUTPUT)$(LIBJVMTI): $(LIBJVMTI_IN)
-	$(QUIET_LINK)$(CC) $(LDFLAGS) -shared -Wl,-soname -Wl,$(LIBJVMTI) -o $@ $<
+	$(QUIET_LINK)$(CC) $(LDFLAGS) -shared -Wl,-soname -Wl,$(LIBJVMTI) -o $@ \
+		$(addprefix $(OUTPUT)jvmti/,libjvmti.o jvmti_agent.o libstring.o libctype.o)
 endif
 
 $(patsubst perf-%,%.o,$(PROGRAMS)): $(wildcard */*.h)
-- 
2.50.1 (Apple Git-155)


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

* Re: [PATCH] perf build: Fix LTO build of libperf-jvmti.so
  2026-07-01  4:21 [PATCH] perf build: Fix LTO build of libperf-jvmti.so Trevor Allison
@ 2026-07-09  0:12 ` Namhyung Kim
  2026-07-09  1:49   ` Ian Rogers
  0 siblings, 1 reply; 3+ messages in thread
From: Namhyung Kim @ 2026-07-09  0:12 UTC (permalink / raw)
  To: Trevor Allison
  Cc: peterz, mingo, acme, mark.rutland, alexander.shishkin, jolsa,
	irogers, adrian.hunter, james.clark, linux-perf-users,
	linux-kernel

Hello,

On Wed, Jul 01, 2026 at 12:21:45AM -0400, Trevor Allison wrote:
> Linking libperf-jvmti.so through jvmti-in.o (ld -r) breaks LTO when
> -flto is passed via LDFLAGS.  Link the JVMTI object files directly
> instead, and pass any LTO flags from LDFLAGS to the JVMTI compile step

Can you share the error message and put it in the commit message?

I think my build is fine with LDFLAGS=-flto.

Thanks,
Namhyung

> 
> Signed-off-by: Trevor Allison <tallison@redhat.com>
> ---
>  tools/perf/Makefile.perf | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/tools/perf/Makefile.perf b/tools/perf/Makefile.perf
> index 3f0544d37a7f..bc66d711fa39 100644
> --- a/tools/perf/Makefile.perf
> +++ b/tools/perf/Makefile.perf
> @@ -686,10 +686,12 @@ ifndef NO_JVMTI
>  LIBJVMTI_IN := $(OUTPUT)jvmti/jvmti-in.o
>  
>  $(LIBJVMTI_IN): prepare FORCE
> -	$(Q)$(MAKE) -f $(srctree)/tools/build/Makefile.build dir=jvmti obj=jvmti
> +	$(Q)$(MAKE) -f $(srctree)/tools/build/Makefile.build dir=jvmti obj=jvmti \
> +		CFLAGS="$(CFLAGS) $(filter -flto% -ffat-lto-objects,$(LDFLAGS))"
>  
>  $(OUTPUT)$(LIBJVMTI): $(LIBJVMTI_IN)
> -	$(QUIET_LINK)$(CC) $(LDFLAGS) -shared -Wl,-soname -Wl,$(LIBJVMTI) -o $@ $<
> +	$(QUIET_LINK)$(CC) $(LDFLAGS) -shared -Wl,-soname -Wl,$(LIBJVMTI) -o $@ \
> +		$(addprefix $(OUTPUT)jvmti/,libjvmti.o jvmti_agent.o libstring.o libctype.o)
>  endif
>  
>  $(patsubst perf-%,%.o,$(PROGRAMS)): $(wildcard */*.h)
> -- 
> 2.50.1 (Apple Git-155)
> 

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

* Re: [PATCH] perf build: Fix LTO build of libperf-jvmti.so
  2026-07-09  0:12 ` Namhyung Kim
@ 2026-07-09  1:49   ` Ian Rogers
  0 siblings, 0 replies; 3+ messages in thread
From: Ian Rogers @ 2026-07-09  1:49 UTC (permalink / raw)
  To: Namhyung Kim
  Cc: Trevor Allison, peterz, mingo, acme, mark.rutland,
	alexander.shishkin, jolsa, adrian.hunter, james.clark,
	linux-perf-users, linux-kernel

On Wed, Jul 8, 2026 at 5:12 PM Namhyung Kim <namhyung@kernel.org> wrote:
>
> Hello,
>
> On Wed, Jul 01, 2026 at 12:21:45AM -0400, Trevor Allison wrote:
> > Linking libperf-jvmti.so through jvmti-in.o (ld -r) breaks LTO when
> > -flto is passed via LDFLAGS.  Link the JVMTI object files directly
> > instead, and pass any LTO flags from LDFLAGS to the JVMTI compile step
>
> Can you share the error message and put it in the commit message?
>
> I think my build is fine with LDFLAGS=-flto.

I had to do many manual steps to make LTO work in the past (IIRC,
using clang and lld). We do have an LTO option in the Makefiles:
https://web.git.kernel.org/pub/scm/linux/kernel/git/perf/perf-tools-next.git/tree/tools/perf/Makefile.config?h=perf-tools-next#n266

If LTO is ready, maybe we can add it to the build tests:
https://web.git.kernel.org/pub/scm/linux/kernel/git/perf/perf-tools-next.git/tree/tools/perf/tests/make?h=perf-tools-next

Thanks,
Ian

> Thanks,
> Namhyung
>
> >
> > Signed-off-by: Trevor Allison <tallison@redhat.com>
> > ---
> >  tools/perf/Makefile.perf | 6 ++++--
> >  1 file changed, 4 insertions(+), 2 deletions(-)
> >
> > diff --git a/tools/perf/Makefile.perf b/tools/perf/Makefile.perf
> > index 3f0544d37a7f..bc66d711fa39 100644
> > --- a/tools/perf/Makefile.perf
> > +++ b/tools/perf/Makefile.perf
> > @@ -686,10 +686,12 @@ ifndef NO_JVMTI
> >  LIBJVMTI_IN := $(OUTPUT)jvmti/jvmti-in.o
> >
> >  $(LIBJVMTI_IN): prepare FORCE
> > -     $(Q)$(MAKE) -f $(srctree)/tools/build/Makefile.build dir=jvmti obj=jvmti
> > +     $(Q)$(MAKE) -f $(srctree)/tools/build/Makefile.build dir=jvmti obj=jvmti \
> > +             CFLAGS="$(CFLAGS) $(filter -flto% -ffat-lto-objects,$(LDFLAGS))"
> >
> >  $(OUTPUT)$(LIBJVMTI): $(LIBJVMTI_IN)
> > -     $(QUIET_LINK)$(CC) $(LDFLAGS) -shared -Wl,-soname -Wl,$(LIBJVMTI) -o $@ $<
> > +     $(QUIET_LINK)$(CC) $(LDFLAGS) -shared -Wl,-soname -Wl,$(LIBJVMTI) -o $@ \
> > +             $(addprefix $(OUTPUT)jvmti/,libjvmti.o jvmti_agent.o libstring.o libctype.o)
> >  endif
> >
> >  $(patsubst perf-%,%.o,$(PROGRAMS)): $(wildcard */*.h)
> > --
> > 2.50.1 (Apple Git-155)
> >

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

end of thread, other threads:[~2026-07-09  1:50 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-01  4:21 [PATCH] perf build: Fix LTO build of libperf-jvmti.so Trevor Allison
2026-07-09  0:12 ` Namhyung Kim
2026-07-09  1:49   ` Ian Rogers

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