[PATCH] perf build: Fix static build of dlfilters
From: Leo Yan
Date: Mon Jul 13 2026 - 06:28:24 EST
Commit e1065ed188cf ("perf build: Add LDFLAGS to dlfilters .so link")
passes LDFLAGS when linking dlfilter shared objects. That breaks static
builds because LDFLAGS can contain -static, leading to an invalid link
command.
dlfilters are always built as shared objects, even for a static perf
binary. Filter out -static for the dlfilter .so link while preserving
the rest of LDFLAGS.
Fixes: e1065ed188cf ("perf build: Add LDFLAGS to dlfilters .so link")
Signed-off-by: Leo Yan <leo.yan@xxxxxxx>
---
tools/perf/Makefile.perf | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tools/perf/Makefile.perf b/tools/perf/Makefile.perf
index 2b53d9e0c73b3382724b1f776880aaa8fa505f59..0031112c036e830e50711d5cb0b3867cba36e374 100644
--- a/tools/perf/Makefile.perf
+++ b/tools/perf/Makefile.perf
@@ -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) $(LDFLAGS) $(EXTRA_CFLAGS) -shared -o $@ $<
+ $(QUIET_LINK)$(CC) $(filter-out -static,$(LDFLAGS)) $(EXTRA_CFLAGS) -shared -o $@ $<
ifndef NO_JVMTI
LIBJVMTI_IN := $(OUTPUT)jvmti/jvmti-in.o
---
base-commit: ef3af1df4f3372bd8ad47619452a283048b3bc8d
change-id: 20260713-perf_fix_static_build-6db03942fee1
Best regards,
--
Leo Yan <leo.yan@xxxxxxx>