Skip to content

Commit

Permalink
tools: Factor Clang, LLC and LLVM utils definitions
Browse files Browse the repository at this point in the history
When dealing with BPF/BTF/pahole and DWARF v5 I wanted to build bpftool.

While looking into the source code I found duplicate assignments in misc tools
for the LLVM eco system, e.g. clang and llvm-objcopy.

Move the Clang, LLC and/or LLVM utils definitions to tools/scripts/Makefile.include
file and add missing includes where needed. Honestly, I was inspired by the commit
c8a950d ("tools: Factor HOSTCC, HOSTLD, HOSTAR definitions").

I tested with bpftool and perf on Debian/testing AMD64 and LLVM/Clang v11.1.0-rc1.

Build instructions:

[ make and make-options ]
MAKE="make V=1"
MAKE_OPTS="HOSTCC=clang HOSTCXX=clang++ HOSTLD=ld.lld CC=clang LD=ld.lld LLVM=1 LLVM_IAS=1"
MAKE_OPTS="$MAKE_OPTS PAHOLE=/opt/pahole/bin/pahole"

[ clean-up ]
$MAKE $MAKE_OPTS -C tools/ clean

[ bpftool ]
$MAKE $MAKE_OPTS -C tools/bpf/bpftool/

[ perf ]
PYTHON=python3 $MAKE $MAKE_OPTS -C tools/perf/

I was careful with respecting the user's wish to override custom compiler, linker,
GNU/binutils and/or LLVM utils settings.

Signed-off-by: Sedat Dilek <[email protected]>
Signed-off-by: Daniel Borkmann <[email protected]>
Acked-by: Andrii Nakryiko <[email protected]>
Acked-by: Jiri Olsa <[email protected]> # tools/build and tools/perf
Link: https://lore.kernel.org/bpf/[email protected]
  • Loading branch information
dileks authored and borkmann committed Jan 29, 2021
1 parent 8259fde commit 211a741
Show file tree
Hide file tree
Showing 7 changed files with 10 additions and 12 deletions.
2 changes: 0 additions & 2 deletions tools/bpf/bpftool/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,6 @@ endif

INSTALL ?= install
RM ?= rm -f
CLANG ?= clang
LLVM_STRIP ?= llvm-strip

FEATURE_USER = .bpftool
FEATURE_TESTS = libbfd disassembler-four-args reallocarray zlib libcap \
Expand Down
3 changes: 0 additions & 3 deletions tools/bpf/runqslower/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@ include ../../scripts/Makefile.include

OUTPUT ?= $(abspath .output)/

CLANG ?= clang
LLC ?= llc
LLVM_STRIP ?= llvm-strip
BPFTOOL_OUTPUT := $(OUTPUT)bpftool/
DEFAULT_BPFTOOL := $(BPFTOOL_OUTPUT)bpftool
BPFTOOL ?= $(DEFAULT_BPFTOOL)
Expand Down
4 changes: 2 additions & 2 deletions tools/build/feature/Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
# SPDX-License-Identifier: GPL-2.0
include ../../scripts/Makefile.include

FILES= \
test-all.bin \
test-backtrace.bin \
Expand Down Expand Up @@ -76,8 +78,6 @@ FILES= \
FILES := $(addprefix $(OUTPUT),$(FILES))

PKG_CONFIG ?= $(CROSS_COMPILE)pkg-config
LLVM_CONFIG ?= llvm-config
CLANG ?= clang

all: $(FILES)

Expand Down
1 change: 0 additions & 1 deletion tools/perf/Makefile.perf
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,6 @@ endef
LD += $(EXTRA_LDFLAGS)

PKG_CONFIG = $(CROSS_COMPILE)pkg-config
LLVM_CONFIG ?= llvm-config

RM = rm -f
LN = ln -f
Expand Down
7 changes: 7 additions & 0 deletions tools/scripts/Makefile.include
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,13 @@ HOSTCC ?= gcc
HOSTLD ?= ld
endif

# Some tools require Clang, LLC and/or LLVM utils
CLANG ?= clang
LLC ?= llc
LLVM_CONFIG ?= llvm-config
LLVM_OBJCOPY ?= llvm-objcopy
LLVM_STRIP ?= llvm-strip

ifeq ($(CC_NO_CLANG), 1)
EXTRA_WARNINGS += -Wstrict-aliasing=3
endif
Expand Down
2 changes: 0 additions & 2 deletions tools/testing/selftests/bpf/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@ ifneq ($(wildcard $(GENHDR)),)
GENFLAGS := -DHAVE_GENHDR
endif

CLANG ?= clang
LLVM_OBJCOPY ?= llvm-objcopy
BPF_GCC ?= $(shell command -v bpf-gcc;)
SAN_CFLAGS ?=
CFLAGS += -g -rdynamic -Wall -O2 $(GENFLAGS) $(SAN_CFLAGS) \
Expand Down
3 changes: 1 addition & 2 deletions tools/testing/selftests/tc-testing/Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# SPDX-License-Identifier: GPL-2.0
include ../../../scripts/Makefile.include

top_srcdir = $(abspath ../../../..)
APIDIR := $(top_scrdir)/include/uapi
Expand All @@ -7,8 +8,6 @@ TEST_GEN_FILES = action.o
KSFT_KHDR_INSTALL := 1
include ../lib.mk

CLANG ?= clang
LLC ?= llc
PROBE := $(shell $(LLC) -march=bpf -mcpu=probe -filetype=null /dev/null 2>&1)

ifeq ($(PROBE),)
Expand Down

0 comments on commit 211a741

Please sign in to comment.