Skip to contentSkip to conversation

perf build: Add LDFLAGS to dlfilters .so link

PATCH Applied Trevor Allison 3 participants 4 messages Jun 26 – Jul 4 perf events

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 perf build: Add LDFLAGS to dlfilters .so link

Build-time linker flags were not applied when linking dlfilters. Pass LDFLAGS for consistency with the other link rules.

---
 tools/perf/Makefile.perf | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/Makefile.perf +1 -1
index 3f0544d37a7f..2b53d9e0c73b 100644
@@ -680,7 +680,7 @@ $(OUTPUT)dlfilters/%.o: dlfilters/%.c include/perf/perf_dlfilter.h
 .SECONDARY: $(DLFILTERS:.so=.o)
 
 $(OUTPUT)dlfilters/%.so: $(OUTPUT)dlfilters/%.o
-	$(QUIET_LINK)$(CC) $(EXTRA_CFLAGS) -shared -o $@ $<
+	$(QUIET_LINK)$(CC) $(LDFLAGS) $(EXTRA_CFLAGS) -shared -o $@ $<
 
 ifndef NO_JVMTI
 LIBJVMTI_IN := $(OUTPUT)jvmti/jvmti-in.o
Signature · 1 line
2.50.1 (Apple Git-155)
#1 lore raw
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [Low] Adding `$(LDFLAGS)` to the unconditionally built `dlfilters` shared library link rule breaks…

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Low] Adding $(LDFLAGS) to the unconditionally built dlfilters shared library link rule breaks statically linked perf builds. --

commit 18f2c24db710920618ef1d894a2b24abff4dbeb9
Author: Trevor Allison <[email protected]>

perf build: Add LDFLAGS to dlfilters .so link

Build-time linker flags were not applied when linking dlfilters. Pass LDFLAGS for consistency with the other link rules.

tools/perf/Makefile.perf $(OUTPUT)dlfilters/%.o: dlfilters/%.c include/perf/perf_dlfilter.h · line 680

Quoted 10 lines
tools/perf/Makefile.perf +1 -1
index 476b8dcaef58c..f2294a6d89604 100644
@@ -677,7 +677,7 @@ $(OUTPUT)dlfilters/%.o: dlfilters/%.c include/perf/perf_dlfilter.h
 .SECONDARY: $(DLFILTERS:.so=.o)
 
 $(OUTPUT)dlfilters/%.so: $(OUTPUT)dlfilters/%.o
-	$(QUIET_LINK)$(CC) $(EXTRA_CFLAGS) -shared -o $@ $<
+	$(QUIET_LINK)$(CC) $(LDFLAGS) $(EXTRA_CFLAGS) -shared -o $@ $<

[Severity: Low]
Does this break static builds of perf?

If a user builds perf statically by setting LDFLAGS="-static", this rule will pass both "-static" and "-shared" to the linker. Since these flags are mutually exclusive, this results in a fatal linker error.

[ ... ]

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
maintainer
#2 lore raw
Quoted 26 lines · On Fri, Jun 26, 2026 at 06:34:23PM +0000, [email protected] wrote:

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Low] Adding $(LDFLAGS) to the unconditionally built dlfilters shared library link rule breaks statically linked perf builds. --

commit 18f2c24db710920618ef1d894a2b24abff4dbeb9
Author: Trevor Allison <[email protected]>

perf build: Add LDFLAGS to dlfilters .so link

Build-time linker flags were not applied when linking dlfilters. Pass LDFLAGS for consistency with the other link rules.

tools/perf/Makefile.perf $(OUTPUT)dlfilters/%.o: dlfilters/%.c include/perf/perf_dlfilter.h · line 680

Quoted 10 lines
tools/perf/Makefile.perf +1 -1
index 476b8dcaef58c..f2294a6d89604 100644
@@ -677,7 +677,7 @@ $(OUTPUT)dlfilters/%.o: dlfilters/%.c include/perf/perf_dlfilter.h
 .SECONDARY: $(DLFILTERS:.so=.o)
 
 $(OUTPUT)dlfilters/%.so: $(OUTPUT)dlfilters/%.o
-	$(QUIET_LINK)$(CC) $(EXTRA_CFLAGS) -shared -o $@ $<
+	$(QUIET_LINK)$(CC) $(LDFLAGS) $(EXTRA_CFLAGS) -shared -o $@ $<

[Severity: Low]
Does this break static builds of perf?

Quoted 3 lines

If a user builds perf statically by setting LDFLAGS="-static", this rule will pass both "-static" and "-shared" to the linker. Since these flags are mutually exclusive, this results in a fatal linker error.

Oops, I missed this message and merged it. It indeed caused a failure in the build test. It seems we should skip building dlfilters when the LDFLAGS has -static or remove -static from the LDFLAGS for dlfilters.

Thanks,
Namhyung

maintainer Applied
#3 lore raw
In reply to Trevor Allison
Quoted 4 lines · Trevor Allison

Build-time linker flags were not applied when linking dlfilters. Pass LDFLAGS for consistency with the other link rules.

Applied to perf-tools-next, thanks!

Best regards,
Namhyung