Skip to contentSkip to conversation

tools build: Correct link flags for libopenssl

PATCH Applied Leo Yan 2 participants 2 messages Mar 17 – Mar 27

lore
Share & tools
lore

Leo Yan

author
#0 lore raw

PATCH v3 1/1 tools build: Correct link flags for libopenssl

The perf static build reports that the BPF skeleton is disabled due to the missing libopenssl feature.

Use PKG_CONFIG to determine the link flags for libopenssl. Add "--static" to the PKG_CONFIG command for static linking.

Fixes 7678523109d1 ("tools/build: Add a feature test for libopenssl")

---
Changes in v3:
- Used PKG_CONFIG to explore ssl link flags (Ian).
- Link to v2: https://lore.kernel.org/r/[email protected]

---
 tools/build/feature/Makefile | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)
tools/build/feature/Makefile +8 -2
index 1fbcb3ce74d2173072748a417fc63bd9a5b13888..f163a245837a63f13f5e6526be097fe9a0e8245d 100644
@@ -103,12 +103,18 @@ else
   endif
 endif
 
+ifeq ($(findstring -static,${LDFLAGS}),-static)
+  PKG_CONFIG += --static
+endif
+
 all: $(FILES)
 
 __BUILD = $(CC) $(CFLAGS) -MD -Wall -Werror -o $@ $(patsubst %.bin,%.c,$(@F)) $(LDFLAGS)
   BUILD = $(__BUILD) > $(@:.bin=.make.output) 2>&1
   BUILD_BFD = $(BUILD) -DPACKAGE='"perf"' -lbfd -ldl
-  BUILD_ALL = $(BUILD) -fstack-protector-all -O2 -D_FORTIFY_SOURCE=2 -ldw -lelf -lnuma -lelf -lslang $(FLAGS_PERL_EMBED) $(FLAGS_PYTHON_EMBED) -ldl -lz -llzma -lzstd -lssl
+  BUILD_ALL = $(BUILD) -fstack-protector-all -O2 -D_FORTIFY_SOURCE=2 -ldw -lelf -lnuma -lelf -lslang \
+	      $(FLAGS_PERL_EMBED) $(FLAGS_PYTHON_EMBED) -ldl -lz -llzma -lzstd \
+	      $(shell $(PKG_CONFIG) --libs --cflags openssl 2>/dev/null)
 
 __BUILDXX = $(CXX) $(CXXFLAGS) -MD -Wall -Werror -o $@ $(patsubst %.bin,%.cpp,$(@F)) $(LDFLAGS)
   BUILDXX = $(__BUILDXX) > $(@:.bin=.make.output) 2>&1
@@ -384,7 +390,7 @@ $(OUTPUT)test-libpfm4.bin:
 	$(BUILD) -lpfm
 
 $(OUTPUT)test-libopenssl.bin:
-	$(BUILD) -lssl
+	$(BUILD) $(shell $(PKG_CONFIG) --libs --cflags openssl 2>/dev/null)
 
 $(OUTPUT)test-bpftool-skeletons.bin:
 	$(SYSTEM_BPFTOOL) version | grep '^features:.*skeletons' \

---
base-commit: bb551508e78c886e6d3bcca6c744d3bc3fd8ad59
change-id: 20260317-tools_fix_build_libopenssl-8290bfebda3c

Best regards,

Signature · 1 line
Leo Yan <[email protected]>
Applied
#1 lore raw
Quoted 8 lines · Leo Yan

The perf static build reports that the BPF skeleton is disabled due to the missing libopenssl feature.

Use PKG_CONFIG to determine the link flags for libopenssl. Add "--static" to the PKG_CONFIG command for static linking.

[...]

Applied to perf-tools-next, thanks!

Best regards,
Namhyung