tools: Factor Clang, LLC and LLVM utils definitions
Subsystems (8)
RFC PATCH v2 1/1 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 commit c8a950d0d3b9 ("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.
Some personal notes:
1. I have NOT tested with cross-toolchain for other archs (cross compiler/linker etc.).
2. This patch is on top of Linux v5.11-rc4.
I hope to get some feedback from especially Linux-bpf folks.
---
Changelog RFC v1->v2:
- Add Jiri's ACK
- Adapt to fit Linux v5.11-rc4
tools/bpf/bpftool/Makefile | 2 -- tools/bpf/runqslower/Makefile | 3 --- tools/build/feature/Makefile | 4 ++-- tools/perf/Makefile.perf | 1 - tools/scripts/Makefile.include | 7 +++++++ tools/testing/selftests/bpf/Makefile | 3 +-- tools/testing/selftests/tc-testing/Makefile | 3 +-- 7 files changed, 11 insertions(+), 12 deletions(-)
tools/bpf/bpftool/Makefile +0 -2
@@ -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 \
tools/bpf/runqslower/Makefile +0 -3
@@ -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)
tools/build/feature/Makefile +2 -2
@@ -1,4 +1,6 @@ # 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)
tools/perf/Makefile.perf +0 -1
@@ -176,7 +176,6 @@ endef LD += $(EXTRA_LDFLAGS) PKG_CONFIG = $(CROSS_COMPILE)pkg-config -LLVM_CONFIG ?= llvm-config RM = rm -f LN = ln -f
tools/scripts/Makefile.include +7 -0
@@ -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
tools/testing/selftests/bpf/Makefile +1 -2
@@ -1,6 +1,7 @@ # SPDX-License-Identifier: GPL-2.0 include ../../../../scripts/Kbuild.include include ../../../scripts/Makefile.arch +include ../../../scripts/Makefile.include CXX ?= $(CROSS_COMPILE)g++
@@ -18,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) \
tools/testing/selftests/tc-testing/Makefile +1 -2
@@ -1,4 +1,5 @@ # SPDX-License-Identifier: GPL-2.0 +include ../../../scripts/Makefile.include top_srcdir = $(abspath ../../../..) APIDIR := $(top_scrdir)/include/uapi
@@ -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),)
Signature · 1 line
2.30.0
Quoted 38 lines · Sedat Dilek
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.includefile and add missing includes where needed.
Honestly, I was inspired by commitc8a950d0d3b9("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 -Ctools/clean[ bpftool ]
$MAKE $MAKE_OPTS -Ctools/bpf/bpftool/[ perf ]
PYTHON=python3 $MAKE $MAKE_OPTS -Ctools/perf/I was careful with respecting the user's wish to override custom compiler, linker, GNU/binutils and/or LLVM utils settings.
Some personal notes:
1. I have NOT tested with cross-toolchain for other archs (cross compiler/linker etc.).
2. This patch is on top of Linux v5.11-rc4.
Quoted 5 lines
I hope to get some feedback from especially Linux-bpf folks.
Signed-off-by Sedat Dilek <[email protected]>---
Hi Sedat,
If no one objects, we'll take this through bpf-next tree. Can you please re-send this as a non-RFC patch against the bpf-next tree? Feel free to add my ack. Thanks.
Quoted 4 lines
Changelog RFC
v1->v2:
- Add Jiri's ACK
- Adapt to fit Linux v5.11-rc4
[...]
Quoted 46 lines · Andrii Nakryiko
Quoted 38 lines · Sedat Dilek
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.includefile and add missing includes where needed.
Honestly, I was inspired by commitc8a950d0d3b9("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 -Ctools/clean[ bpftool ]
$MAKE $MAKE_OPTS -Ctools/bpf/bpftool/[ perf ]
PYTHON=python3 $MAKE $MAKE_OPTS -Ctools/perf/I was careful with respecting the user's wish to override custom compiler, linker, GNU/binutils and/or LLVM utils settings.
Some personal notes:
1. I have NOT tested with cross-toolchain for other archs (cross compiler/linker etc.).
2. This patch is on top of Linux v5.11-rc4.Quoted 5 lines
I hope to get some feedback from especially Linux-bpf folks.
Signed-off-by Sedat Dilek <[email protected]>---
Quoted 6 lines
Hi Sedat,
If no one objects, we'll take this through bpf-next tree. Can you please re-send this as a non-RFC patch against the bpf-next tree? Feel free to add my ack. Thanks.
I am OK with that and will add your ACK.
Is [1] bpf-next Git?
- Sedat -
[1] https://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf-next.git/
Quoted 6 lines
Quoted 4 lines
Changelog RFC
v1->v2:
- Add Jiri's ACK
- Adapt to fit Linux v5.11-rc4[...]
Quoted 51 lines · Sedat Dilek
Quoted 48 lines · Andrii Nakryiko
Quoted 38 lines · Sedat Dilek
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.includefile and add missing includes where needed.
Honestly, I was inspired by commitc8a950d0d3b9("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 -Ctools/clean[ bpftool ]
$MAKE $MAKE_OPTS -Ctools/bpf/bpftool/[ perf ]
PYTHON=python3 $MAKE $MAKE_OPTS -Ctools/perf/I was careful with respecting the user's wish to override custom compiler, linker, GNU/binutils and/or LLVM utils settings.
Some personal notes:
1. I have NOT tested with cross-toolchain for other archs (cross compiler/linker etc.).
2. This patch is on top of Linux v5.11-rc4.Quoted 5 lines
I hope to get some feedback from especially Linux-bpf folks.
Signed-off-by Sedat Dilek <[email protected]>---
Hi Sedat,
Quoted 7 lines
Quoted 4 lines
If no one objects, we'll take this through bpf-next tree. Can you please re-send this as a non-RFC patch against the bpf-next tree? Feel free to add my ack. Thanks.
I am OK with that and will add your ACK.
Is [1] bpf-next Git?
Yes, please use [PATCH bpf-next] subject prefix and cc [email protected] as well.
Quoted 11 lines
- Sedat -
[1] https://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf-next.git/
Quoted 6 lines
Quoted 4 lines
Changelog RFC
v1->v2:
- Add Jiri's ACK
- Adapt to fit Linux v5.11-rc4[...]
Quoted 58 lines · Andrii Nakryiko
Quoted 56 lines · Sedat Dilek
Quoted 52 lines · Andrii Nakryiko
Quoted 38 lines · Sedat Dilek
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.includefile and add missing includes where needed.
Honestly, I was inspired by commitc8a950d0d3b9("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 -Ctools/clean[ bpftool ]
$MAKE $MAKE_OPTS -Ctools/bpf/bpftool/[ perf ]
PYTHON=python3 $MAKE $MAKE_OPTS -Ctools/perf/I was careful with respecting the user's wish to override custom compiler, linker, GNU/binutils and/or LLVM utils settings.
Some personal notes:
1. I have NOT tested with cross-toolchain for other archs (cross compiler/linker etc.).
2. This patch is on top of Linux v5.11-rc4.Quoted 5 lines
I hope to get some feedback from especially Linux-bpf folks.
Signed-off-by Sedat Dilek <[email protected]>---
Hi Sedat,
If no one objects, we'll take this through bpf-next tree. Can you please re-send this as a non-RFC patch against the bpf-next tree? Feel free to add my ack. Thanks.
Quoted 6 lines
Quoted 2 lines
I am OK with that and will add your ACK.
Is [1] bpf-next Git?Yes, please use [PATCH bpf-next] subject prefix and cc [email protected] as well.
Please see link:
https://lore.kernel.org/r/[email protected]
- Sedat -
Quoted 11 lines
Quoted 11 lines
- Sedat -
[1] https://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf-next.git/
Quoted 6 lines
Quoted 4 lines
Changelog RFC
v1->v2:
- Add Jiri's ACK
- Adapt to fit Linux v5.11-rc4[...]