lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Tue, 10 Mar 2020 11:36:22 -0700
From:   Song Liu <songliubraving@...com>
To:     <netdev@...r.kernel.org>, <bpf@...r.kernel.org>
CC:     <quentin@...valent.com>, <kernel-team@...com>, <ast@...nel.org>,
        <daniel@...earbox.net>, <arnaldo.melo@...il.com>,
        <jolsa@...nel.org>, Song Liu <songliubraving@...com>
Subject: [PATCH bpf-next 1/2] bpftool: only build bpftool-prog-profile with clang >= v11

bpftool-prog-profile requires clang of version 11.0.0 or newer. If
bpftool is built with older clang, show a hint of to the user.

Signed-off-by: Song Liu <songliubraving@...com>
---
 tools/bpf/bpftool/Makefile | 13 +++++++++++--
 tools/bpf/bpftool/prog.c   |  2 ++
 2 files changed, 13 insertions(+), 2 deletions(-)

diff --git a/tools/bpf/bpftool/Makefile b/tools/bpf/bpftool/Makefile
index 20a90d8450f8..05a37f0f76a9 100644
--- a/tools/bpf/bpftool/Makefile
+++ b/tools/bpf/bpftool/Makefile
@@ -60,6 +60,15 @@ LIBS = $(LIBBPF) -lelf -lz
 INSTALL ?= install
 RM ?= rm -f
 CLANG ?= clang
+CLANG_VERS = $(shell $(CLANG) --version | head -n 1 | awk '{print $$3}')
+CLANG_MAJ = $(shell echo $(CLANG_VERS) | cut -d '.' -f 1)
+WITHOUT_SKELETONS = -DBPFTOOL_WITHOUT_SKELETONS
+
+ifeq ($(shell test $(CLANG_MAJ) -ge 11; echo $$?),0)
+	PROG_FLAGS =
+else
+	PROG_FLAGS = $(WITHOUT_SKELETONS)
+endif
 
 FEATURE_USER = .bpftool
 FEATURE_TESTS = libbfd disassembler-four-args reallocarray zlib
@@ -114,7 +123,7 @@ OBJS = $(patsubst %.c,$(OUTPUT)%.o,$(SRCS)) $(OUTPUT)disasm.o
 _OBJS = $(filter-out $(OUTPUT)prog.o,$(OBJS)) $(OUTPUT)_prog.o
 
 $(OUTPUT)_prog.o: prog.c
-	$(QUIET_CC)$(COMPILE.c) -MMD -DBPFTOOL_WITHOUT_SKELETONS -o $@ $<
+	$(QUIET_CC)$(COMPILE.c) -MMD $(WITHOUT_SKELETONS) -o $@ $<
 
 $(OUTPUT)_bpftool: $(_OBJS) $(LIBBPF)
 	$(QUIET_LINK)$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $(_OBJS) $(LIBS)
@@ -126,7 +135,7 @@ profiler.skel.h: $(OUTPUT)_bpftool skeleton/profiler.bpf.o
 	$(QUIET_GEN)$(OUTPUT)./_bpftool gen skeleton skeleton/profiler.bpf.o > $@
 
 $(OUTPUT)prog.o: prog.c profiler.skel.h
-	$(QUIET_CC)$(COMPILE.c) -MMD -o $@ $<
+	$(QUIET_CC)$(COMPILE.c) -MMD $(PROG_FLAGS) -o $@ $<
 
 $(OUTPUT)disasm.o: $(srctree)/kernel/bpf/disasm.c
 	$(QUIET_CC)$(COMPILE.c) -MMD -o $@ $<
diff --git a/tools/bpf/bpftool/prog.c b/tools/bpf/bpftool/prog.c
index 576ddd82bc96..5db378d5d970 100644
--- a/tools/bpf/bpftool/prog.c
+++ b/tools/bpf/bpftool/prog.c
@@ -1545,6 +1545,8 @@ static int do_loadall(int argc, char **argv)
 
 static int do_profile(int argc, char **argv)
 {
+	fprintf(stdout, "bpftool prog profile command is not supported.\n"
+		"Please recompile bpftool with clang >= 11.0.0\n");
 	return 0;
 }
 
-- 
2.17.1

Powered by blists - more mailing lists