Commit 211a741c authored by Sedat Dilek's avatar Sedat Dilek Committed by Daniel Borkmann
Browse files

tools: Factor Clang, LLC and LLVM utils definitions



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
c8a950d0 ("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: default avatarSedat Dilek <sedat.dilek@gmail.com>
Signed-off-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
Acked-by: default avatarAndrii Nakryiko <andrii@kernel.org>
Acked-by: Jiri Olsa <jolsa@redhat.com> # tools/build and tools/perf
Link: https://lore.kernel.org/bpf/20210128015117.20515-1-sedat.dilek@gmail.com
parent 8259fdeb
Loading
Loading
Loading
Loading
+0 −2
Original line number Diff line number Diff line
@@ -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 \
+0 −3
Original line number Diff line number Diff line
@@ -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)
+2 −2
Original line number Diff line number Diff line
# SPDX-License-Identifier: GPL-2.0
include ../../scripts/Makefile.include

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

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

all: $(FILES)

+0 −1
Original line number Diff line number Diff line
@@ -176,7 +176,6 @@ endef
LD += $(EXTRA_LDFLAGS)

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

RM      = rm -f
LN      = ln -f
+7 −0
Original line number Diff line number Diff line
@@ -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
Loading