From: Yonghong Song <yhs@fb.com>
To: Andrew Delgadillo <adelg@google.com>, <bpf@vger.kernel.org>,
Alexei Starovoitov <ast@kernel.org>, <daniel@iogearbox.net>
Subject: Re: [PATCH bpf-next v2] selftests/bpf: Drop the need for LLVM's llc
Date: Thu, 10 Dec 2020 15:55:53 -0800 [thread overview]
Message-ID: <6bdcc1e4-5ce2-7876-e48f-bce04f7298b6@fb.com> (raw)
In-Reply-To: <20201210194157.3218806-2-adelg@google.com>
On 12/10/20 11:41 AM, Andrew Delgadillo wrote:
> LLC is meant for compiler development and debugging. Consequently, it
> exposes many low level options about its backend. To avoid future bugs
> introduced by using the raw LLC tool, use clang directly so that all
> appropriate options are passed to the back end.
>
> Additionally, simplify the Makefile by removing the
> CLANG_NATIVE_BPF_BUILD_RULE as it is not being use, stop passing
> dwarfris attr since elfutils/libdw now supports the bpf backend (which
> should work with any recent pahole), and stop passing alu32 since
> -mcpu=v3 implies alu32.
>
> Signed-off-by: Andrew Delgadillo <adelg@google.com>
> ---
> Changes since v1:
> * do not pass +dwarfris
> * do not pass +alu32 when using -mcpu=v3
> ---
> tools/testing/selftests/bpf/Makefile | 19 +++----------------
> 1 file changed, 3 insertions(+), 16 deletions(-)
>
> diff --git a/tools/testing/selftests/bpf/Makefile b/tools/testing/selftests/bpf/Makefile
> index 944ae17a39ed..a96f63dfd8dc 100644
> --- a/tools/testing/selftests/bpf/Makefile
> +++ b/tools/testing/selftests/bpf/Makefile
> @@ -19,7 +19,6 @@ ifneq ($(wildcard $(GENHDR)),)
> endif
>
> CLANG ?= clang
> -LLC ?= llc
> LLVM_OBJCOPY ?= llvm-objcopy
> BPF_GCC ?= $(shell command -v bpf-gcc;)
> SAN_CFLAGS ?=
> @@ -256,24 +255,13 @@ $(OUTPUT)/flow_dissector_load.o: flow_dissector_load.h
> # $3 - CFLAGS
> # $4 - LDFLAGS
You can remove TRUNNER_BPF_LDFLAGS completely, so we won't have $4 here.
> define CLANG_BPF_BUILD_RULE
> - $(call msg,CLNG-LLC,$(TRUNNER_BINARY),$2)
> - $(Q)($(CLANG) $3 -O2 -target bpf -emit-llvm \
> - -c $1 -o - || echo "BPF obj compilation failed") | \
> - $(LLC) -mattr=dwarfris -march=bpf -mcpu=v3 $4 -filetype=obj -o $2
> + $(call msg,CLNG-BPF,$(TRUNNER_BINARY),$2)
> + $(Q)$(CLANG) $3 -O2 -target bpf -c $1 -o $2 -mcpu=v3 $4
and $4 here.
> endef
> # Similar to CLANG_BPF_BUILD_RULE, but with disabled alu32
> define CLANG_NOALU32_BPF_BUILD_RULE
> - $(call msg,CLNG-LLC,$(TRUNNER_BINARY),$2)
> - $(Q)($(CLANG) $3 -O2 -target bpf -emit-llvm \
> - -c $1 -o - || echo "BPF obj compilation failed") | \
> - $(LLC) -march=bpf -mcpu=v2 $4 -filetype=obj -o $2
> -endef
> -# Similar to CLANG_BPF_BUILD_RULE, but using native Clang and bpf LLC
> -define CLANG_NATIVE_BPF_BUILD_RULE
> $(call msg,CLNG-BPF,$(TRUNNER_BINARY),$2)
> - $(Q)($(CLANG) $3 -O2 -emit-llvm \
> - -c $1 -o - || echo "BPF obj compilation failed") | \
> - $(LLC) -march=bpf -mcpu=v3 $4 -filetype=obj -o $2
> + $(Q)$(CLANG) $3 -O2 -target bpf -c $1 -o $2 -mcpu=v2 $4
and $4 here.
> endef
> # Build BPF object using GCC
> define GCC_BPF_BUILD_RULE
> @@ -402,7 +390,6 @@ TRUNNER_EXTRA_FILES := $(OUTPUT)/urandom_read $(OUTPUT)/bpf_testmod.ko \
> $(wildcard progs/btf_dump_test_case_*.c)
> TRUNNER_BPF_BUILD_RULE := CLANG_BPF_BUILD_RULE
> TRUNNER_BPF_CFLAGS := $(BPF_CFLAGS) $(CLANG_CFLAGS)
> -TRUNNER_BPF_LDFLAGS := -mattr=+alu32
> $(eval $(call DEFINE_TEST_RUNNER,test_progs))
>
> # Define test_progs-no_alu32 test runner.
>
next prev parent reply other threads:[~2020-12-10 23:58 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-12-09 20:53 [PATCH bpf-next] selftests/bpf: Drop the need for LLVM's llc Andrew Delgadillo
2020-12-10 2:16 ` Yonghong Song
2020-12-10 17:12 ` Andrew Delgadillo
2020-12-10 19:41 ` [PATCH bpf-next v2] " Andrew Delgadillo
2020-12-10 19:41 ` Andrew Delgadillo
2020-12-10 23:55 ` Yonghong Song [this message]
2020-12-11 0:43 ` [PATCH bpf-next v3] " Andrew Delgadillo
2020-12-11 1:26 ` Yonghong Song
2020-12-11 6:10 ` patchwork-bot+netdevbpf
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=6bdcc1e4-5ce2-7876-e48f-bce04f7298b6@fb.com \
--to=yhs@fb.com \
--cc=adelg@google.com \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox