* [PATCH] samples/bpf: Add BTF build flags to Makefile
@ 2018-07-25 16:30 Taeung Song
2018-07-25 20:38 ` Martin KaFai Lau
2018-07-26 1:16 ` Jakub Kicinski
0 siblings, 2 replies; 6+ messages in thread
From: Taeung Song @ 2018-07-25 16:30 UTC (permalink / raw)
To: Daniel Borkmann, Alexei Starovoitov
Cc: netdev, linux-kernel, Martin KaFai Lau
To smoothly test BTF supported binary on samples/bpf,
let samples/bpf/Makefile probe llc, pahole and
llvm-objcopy for BPF support and use them
like tools/testing/selftests/bpf/Makefile
changed from the commit c0fa1b6c3efc ("bpf: btf:
Add BTF tests")
Cc: Martin KaFai Lau <kafai@fb.com>
Signed-off-by: Taeung Song <treeze.taeung@gmail.com>
---
samples/bpf/Makefile | 21 ++++++++++++++++++++-
1 file changed, 20 insertions(+), 1 deletion(-)
diff --git a/samples/bpf/Makefile b/samples/bpf/Makefile
index 1303af10e54d..e079266360a3 100644
--- a/samples/bpf/Makefile
+++ b/samples/bpf/Makefile
@@ -191,6 +191,8 @@ HOSTLOADLIBES_xdpsock += -pthread
# make samples/bpf/ LLC=~/git/llvm/build/bin/llc CLANG=~/git/llvm/build/bin/clang
LLC ?= llc
CLANG ?= clang
+LLVM_OBJCOPY ?= llvm-objcopy
+BTF_PAHOLE ?= pahole
# Detect that we're cross compiling and use the cross compiler
ifdef CROSS_COMPILE
@@ -198,6 +200,20 @@ HOSTCC = $(CROSS_COMPILE)gcc
CLANG_ARCH_ARGS = -target $(ARCH)
endif
+BTF_LLC_PROBE := $(shell $(LLC) -march=bpf -mattr=help 2>&1 | grep dwarfris)
+BTF_PAHOLE_PROBE := $(shell $(BTF_PAHOLE) --help 2>&1 | grep BTF)
+BTF_OBJCOPY_PROBE := $(shell $(LLVM_OBJCOPY) --help 2>&1 | grep -i 'usage.*llvm')
+
+ifneq ($(BTF_LLC_PROBE),)
+ifneq ($(BTF_PAHOLE_PROBE),)
+ifneq ($(BTF_OBJCOPY_PROBE),)
+ EXTRA_CFLAGS += -g
+ LLC_FLAGS += -mattr=dwarfris
+ DWARF2BTF = y
+endif
+endif
+endif
+
# Trick to allow make to be run from this directory
all:
$(MAKE) -C ../../ $(CURDIR)/ BPF_SAMPLES_PATH=$(CURDIR)
@@ -256,4 +272,7 @@ $(obj)/%.o: $(src)/%.c
-Wno-gnu-variable-sized-type-not-at-end \
-Wno-address-of-packed-member -Wno-tautological-compare \
-Wno-unknown-warning-option $(CLANG_ARCH_ARGS) \
- -O2 -emit-llvm -c $< -o -| $(LLC) -march=bpf -filetype=obj -o $@
+ -O2 -emit-llvm -c $< -o -| $(LLC) -march=bpf $(LLC_FLAGS) -filetype=obj -o $@
+ifeq ($(DWARF2BTF),y)
+ $(BTF_PAHOLE) -J $@
+endif
--
2.17.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH] samples/bpf: Add BTF build flags to Makefile
2018-07-25 16:30 [PATCH] samples/bpf: Add BTF build flags to Makefile Taeung Song
@ 2018-07-25 20:38 ` Martin KaFai Lau
2018-07-25 20:45 ` Martin KaFai Lau
2018-07-26 1:16 ` Jakub Kicinski
1 sibling, 1 reply; 6+ messages in thread
From: Martin KaFai Lau @ 2018-07-25 20:38 UTC (permalink / raw)
To: Taeung Song; +Cc: Daniel Borkmann, Alexei Starovoitov, netdev, linux-kernel
On Thu, Jul 26, 2018 at 01:30:39AM +0900, Taeung Song wrote:
> To smoothly test BTF supported binary on samples/bpf,
> let samples/bpf/Makefile probe llc, pahole and
> llvm-objcopy for BPF support and use them
> like tools/testing/selftests/bpf/Makefile
> changed from the commit c0fa1b6c3efc ("bpf: btf:
> Add BTF tests")
>
> Cc: Martin KaFai Lau <kafai@fb.com>
> Signed-off-by: Taeung Song <treeze.taeung@gmail.com>
Thanks for the patch. LGTM.
Acked-by: Martin KaFai Lau <kafai@fb.com>
> ---
> samples/bpf/Makefile | 21 ++++++++++++++++++++-
> 1 file changed, 20 insertions(+), 1 deletion(-)
>
> diff --git a/samples/bpf/Makefile b/samples/bpf/Makefile
> index 1303af10e54d..e079266360a3 100644
> --- a/samples/bpf/Makefile
> +++ b/samples/bpf/Makefile
> @@ -191,6 +191,8 @@ HOSTLOADLIBES_xdpsock += -pthread
> # make samples/bpf/ LLC=~/git/llvm/build/bin/llc CLANG=~/git/llvm/build/bin/clang
> LLC ?= llc
> CLANG ?= clang
> +LLVM_OBJCOPY ?= llvm-objcopy
> +BTF_PAHOLE ?= pahole
>
> # Detect that we're cross compiling and use the cross compiler
> ifdef CROSS_COMPILE
> @@ -198,6 +200,20 @@ HOSTCC = $(CROSS_COMPILE)gcc
> CLANG_ARCH_ARGS = -target $(ARCH)
> endif
>
> +BTF_LLC_PROBE := $(shell $(LLC) -march=bpf -mattr=help 2>&1 | grep dwarfris)
> +BTF_PAHOLE_PROBE := $(shell $(BTF_PAHOLE) --help 2>&1 | grep BTF)
> +BTF_OBJCOPY_PROBE := $(shell $(LLVM_OBJCOPY) --help 2>&1 | grep -i 'usage.*llvm')
> +
> +ifneq ($(BTF_LLC_PROBE),)
> +ifneq ($(BTF_PAHOLE_PROBE),)
> +ifneq ($(BTF_OBJCOPY_PROBE),)
> + EXTRA_CFLAGS += -g
> + LLC_FLAGS += -mattr=dwarfris
> + DWARF2BTF = y
> +endif
> +endif
> +endif
> +
> # Trick to allow make to be run from this directory
> all:
> $(MAKE) -C ../../ $(CURDIR)/ BPF_SAMPLES_PATH=$(CURDIR)
> @@ -256,4 +272,7 @@ $(obj)/%.o: $(src)/%.c
> -Wno-gnu-variable-sized-type-not-at-end \
> -Wno-address-of-packed-member -Wno-tautological-compare \
> -Wno-unknown-warning-option $(CLANG_ARCH_ARGS) \
> - -O2 -emit-llvm -c $< -o -| $(LLC) -march=bpf -filetype=obj -o $@
> + -O2 -emit-llvm -c $< -o -| $(LLC) -march=bpf $(LLC_FLAGS) -filetype=obj -o $@
> +ifeq ($(DWARF2BTF),y)
> + $(BTF_PAHOLE) -J $@
> +endif
> --
> 2.17.1
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] samples/bpf: Add BTF build flags to Makefile
2018-07-25 20:38 ` Martin KaFai Lau
@ 2018-07-25 20:45 ` Martin KaFai Lau
2018-07-26 9:54 ` Taeung Song
0 siblings, 1 reply; 6+ messages in thread
From: Martin KaFai Lau @ 2018-07-25 20:45 UTC (permalink / raw)
To: Taeung Song; +Cc: Daniel Borkmann, Alexei Starovoitov, netdev, linux-kernel
On Wed, Jul 25, 2018 at 01:38:44PM -0700, Martin KaFai Lau wrote:
> On Thu, Jul 26, 2018 at 01:30:39AM +0900, Taeung Song wrote:
> > To smoothly test BTF supported binary on samples/bpf,
> > let samples/bpf/Makefile probe llc, pahole and
> > llvm-objcopy for BPF support and use them
> > like tools/testing/selftests/bpf/Makefile
> > changed from the commit c0fa1b6c3efc ("bpf: btf:
> > Add BTF tests")
> >
> > Cc: Martin KaFai Lau <kafai@fb.com>
> > Signed-off-by: Taeung Song <treeze.taeung@gmail.com>
> Thanks for the patch. LGTM.
>
> Acked-by: Martin KaFai Lau <kafai@fb.com>
and it should go to bpf-next (Please use the proper tag in the
Subject, thanks!).
>
> > ---
> > samples/bpf/Makefile | 21 ++++++++++++++++++++-
> > 1 file changed, 20 insertions(+), 1 deletion(-)
> >
> > diff --git a/samples/bpf/Makefile b/samples/bpf/Makefile
> > index 1303af10e54d..e079266360a3 100644
> > --- a/samples/bpf/Makefile
> > +++ b/samples/bpf/Makefile
> > @@ -191,6 +191,8 @@ HOSTLOADLIBES_xdpsock += -pthread
> > # make samples/bpf/ LLC=~/git/llvm/build/bin/llc CLANG=~/git/llvm/build/bin/clang
> > LLC ?= llc
> > CLANG ?= clang
> > +LLVM_OBJCOPY ?= llvm-objcopy
> > +BTF_PAHOLE ?= pahole
> >
> > # Detect that we're cross compiling and use the cross compiler
> > ifdef CROSS_COMPILE
> > @@ -198,6 +200,20 @@ HOSTCC = $(CROSS_COMPILE)gcc
> > CLANG_ARCH_ARGS = -target $(ARCH)
> > endif
> >
> > +BTF_LLC_PROBE := $(shell $(LLC) -march=bpf -mattr=help 2>&1 | grep dwarfris)
> > +BTF_PAHOLE_PROBE := $(shell $(BTF_PAHOLE) --help 2>&1 | grep BTF)
> > +BTF_OBJCOPY_PROBE := $(shell $(LLVM_OBJCOPY) --help 2>&1 | grep -i 'usage.*llvm')
> > +
> > +ifneq ($(BTF_LLC_PROBE),)
> > +ifneq ($(BTF_PAHOLE_PROBE),)
> > +ifneq ($(BTF_OBJCOPY_PROBE),)
> > + EXTRA_CFLAGS += -g
> > + LLC_FLAGS += -mattr=dwarfris
> > + DWARF2BTF = y
> > +endif
> > +endif
> > +endif
> > +
> > # Trick to allow make to be run from this directory
> > all:
> > $(MAKE) -C ../../ $(CURDIR)/ BPF_SAMPLES_PATH=$(CURDIR)
> > @@ -256,4 +272,7 @@ $(obj)/%.o: $(src)/%.c
> > -Wno-gnu-variable-sized-type-not-at-end \
> > -Wno-address-of-packed-member -Wno-tautological-compare \
> > -Wno-unknown-warning-option $(CLANG_ARCH_ARGS) \
> > - -O2 -emit-llvm -c $< -o -| $(LLC) -march=bpf -filetype=obj -o $@
> > + -O2 -emit-llvm -c $< -o -| $(LLC) -march=bpf $(LLC_FLAGS) -filetype=obj -o $@
> > +ifeq ($(DWARF2BTF),y)
> > + $(BTF_PAHOLE) -J $@
> > +endif
> > --
> > 2.17.1
> >
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] samples/bpf: Add BTF build flags to Makefile
2018-07-25 16:30 [PATCH] samples/bpf: Add BTF build flags to Makefile Taeung Song
2018-07-25 20:38 ` Martin KaFai Lau
@ 2018-07-26 1:16 ` Jakub Kicinski
2018-07-26 10:08 ` Taeung Song
1 sibling, 1 reply; 6+ messages in thread
From: Jakub Kicinski @ 2018-07-26 1:16 UTC (permalink / raw)
To: Taeung Song
Cc: Daniel Borkmann, Alexei Starovoitov, netdev, linux-kernel,
Martin KaFai Lau
On Thu, 26 Jul 2018 01:30:39 +0900, Taeung Song wrote:
> To smoothly test BTF supported binary on samples/bpf,
> let samples/bpf/Makefile probe llc, pahole and
> llvm-objcopy for BPF support and use them
> like tools/testing/selftests/bpf/Makefile
> changed from the commit c0fa1b6c3efc ("bpf: btf:
> Add BTF tests")
>
> Cc: Martin KaFai Lau <kafai@fb.com>
> Signed-off-by: Taeung Song <treeze.taeung@gmail.com>
> ---
> samples/bpf/Makefile | 21 ++++++++++++++++++++-
> 1 file changed, 20 insertions(+), 1 deletion(-)
>
> diff --git a/samples/bpf/Makefile b/samples/bpf/Makefile
> index 1303af10e54d..e079266360a3 100644
> --- a/samples/bpf/Makefile
> +++ b/samples/bpf/Makefile
> @@ -191,6 +191,8 @@ HOSTLOADLIBES_xdpsock += -pthread
> # make samples/bpf/ LLC=~/git/llvm/build/bin/llc CLANG=~/git/llvm/build/bin/clang
> LLC ?= llc
> CLANG ?= clang
> +LLVM_OBJCOPY ?= llvm-objcopy
> +BTF_PAHOLE ?= pahole
>
> # Detect that we're cross compiling and use the cross compiler
> ifdef CROSS_COMPILE
> @@ -198,6 +200,20 @@ HOSTCC = $(CROSS_COMPILE)gcc
> CLANG_ARCH_ARGS = -target $(ARCH)
> endif
>
> +BTF_LLC_PROBE := $(shell $(LLC) -march=bpf -mattr=help 2>&1 | grep dwarfris)
> +BTF_PAHOLE_PROBE := $(shell $(BTF_PAHOLE) --help 2>&1 | grep BTF)
> +BTF_OBJCOPY_PROBE := $(shell $(LLVM_OBJCOPY) --help 2>&1 | grep -i 'usage.*llvm')
> +
> +ifneq ($(BTF_LLC_PROBE),)
> +ifneq ($(BTF_PAHOLE_PROBE),)
> +ifneq ($(BTF_OBJCOPY_PROBE),)
Nice patch! FWIW you could consider using $(and ...) here:
ifneq ($(and $(BTF_LLC_PROBE),$(BTF_PAHOLE_PROBE),$(BTF_OBJCOPY_PROBE)),)
https://www.gnu.org/software/make/manual/html_node/Conditional-Functions.html#Conditional-Functions
Not sure it's worth a respin..
> + EXTRA_CFLAGS += -g
> + LLC_FLAGS += -mattr=dwarfris
> + DWARF2BTF = y
> +endif
> +endif
> +endif
> +
> # Trick to allow make to be run from this directory
> all:
> $(MAKE) -C ../../ $(CURDIR)/ BPF_SAMPLES_PATH=$(CURDIR)
> @@ -256,4 +272,7 @@ $(obj)/%.o: $(src)/%.c
> -Wno-gnu-variable-sized-type-not-at-end \
> -Wno-address-of-packed-member -Wno-tautological-compare \
> -Wno-unknown-warning-option $(CLANG_ARCH_ARGS) \
> - -O2 -emit-llvm -c $< -o -| $(LLC) -march=bpf -filetype=obj -o $@
> + -O2 -emit-llvm -c $< -o -| $(LLC) -march=bpf $(LLC_FLAGS) -filetype=obj -o $@
> +ifeq ($(DWARF2BTF),y)
> + $(BTF_PAHOLE) -J $@
> +endif
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] samples/bpf: Add BTF build flags to Makefile
2018-07-25 20:45 ` Martin KaFai Lau
@ 2018-07-26 9:54 ` Taeung Song
0 siblings, 0 replies; 6+ messages in thread
From: Taeung Song @ 2018-07-26 9:54 UTC (permalink / raw)
To: Martin KaFai Lau
Cc: Daniel Borkmann, Alexei Starovoitov, netdev, linux-kernel
On 07/26/2018 05:45 AM, Martin KaFai Lau wrote:
> On Wed, Jul 25, 2018 at 01:38:44PM -0700, Martin KaFai Lau wrote:
>> On Thu, Jul 26, 2018 at 01:30:39AM +0900, Taeung Song wrote:
>>> To smoothly test BTF supported binary on samples/bpf,
>>> let samples/bpf/Makefile probe llc, pahole and
>>> llvm-objcopy for BPF support and use them
>>> like tools/testing/selftests/bpf/Makefile
>>> changed from the commit c0fa1b6c3efc ("bpf: btf:
>>> Add BTF tests")
>>>
>>> Cc: Martin KaFai Lau <kafai@fb.com>
>>> Signed-off-by: Taeung Song <treeze.taeung@gmail.com>
>> Thanks for the patch. LGTM.
>>
>> Acked-by: Martin KaFai Lau <kafai@fb.com>
> and it should go to bpf-next (Please use the proper tag in the
> Subject, thanks!).
>
Yep, will change it ! :)
Thanks,
Taeung
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] samples/bpf: Add BTF build flags to Makefile
2018-07-26 1:16 ` Jakub Kicinski
@ 2018-07-26 10:08 ` Taeung Song
0 siblings, 0 replies; 6+ messages in thread
From: Taeung Song @ 2018-07-26 10:08 UTC (permalink / raw)
To: Jakub Kicinski
Cc: Daniel Borkmann, Alexei Starovoitov, netdev, linux-kernel,
Martin KaFai Lau
On 07/26/2018 10:16 AM, Jakub Kicinski wrote:
> On Thu, 26 Jul 2018 01:30:39 +0900, Taeung Song wrote:
>> To smoothly test BTF supported binary on samples/bpf,
>> let samples/bpf/Makefile probe llc, pahole and
>> llvm-objcopy for BPF support and use them
>> like tools/testing/selftests/bpf/Makefile
>> changed from the commit c0fa1b6c3efc ("bpf: btf:
>> Add BTF tests")
>>
>> Cc: Martin KaFai Lau <kafai@fb.com>
>> Signed-off-by: Taeung Song <treeze.taeung@gmail.com>
>> ---
>> samples/bpf/Makefile | 21 ++++++++++++++++++++-
>> 1 file changed, 20 insertions(+), 1 deletion(-)
>>
>> diff --git a/samples/bpf/Makefile b/samples/bpf/Makefile
>> index 1303af10e54d..e079266360a3 100644
>> --- a/samples/bpf/Makefile
>> +++ b/samples/bpf/Makefile
>> @@ -191,6 +191,8 @@ HOSTLOADLIBES_xdpsock += -pthread
>> # make samples/bpf/ LLC=~/git/llvm/build/bin/llc CLANG=~/git/llvm/build/bin/clang
>> LLC ?= llc
>> CLANG ?= clang
>> +LLVM_OBJCOPY ?= llvm-objcopy
>> +BTF_PAHOLE ?= pahole
>>
>> # Detect that we're cross compiling and use the cross compiler
>> ifdef CROSS_COMPILE
>> @@ -198,6 +200,20 @@ HOSTCC = $(CROSS_COMPILE)gcc
>> CLANG_ARCH_ARGS = -target $(ARCH)
>> endif
>>
>> +BTF_LLC_PROBE := $(shell $(LLC) -march=bpf -mattr=help 2>&1 | grep dwarfris)
>> +BTF_PAHOLE_PROBE := $(shell $(BTF_PAHOLE) --help 2>&1 | grep BTF)
>> +BTF_OBJCOPY_PROBE := $(shell $(LLVM_OBJCOPY) --help 2>&1 | grep -i 'usage.*llvm')
>> +
>> +ifneq ($(BTF_LLC_PROBE),)
>> +ifneq ($(BTF_PAHOLE_PROBE),)
>> +ifneq ($(BTF_OBJCOPY_PROBE),)
>
> Nice patch! FWIW you could consider using $(and ...) here:
>
> ifneq ($(and $(BTF_LLC_PROBE),$(BTF_PAHOLE_PROBE),$(BTF_OBJCOPY_PROBE)),)
>
> https://www.gnu.org/software/make/manual/html_node/Conditional-Functions.html#Conditional-Functions
>
> Not sure it's worth a respin..
>
Hi Jakub,
Thanks for reviewing this.
I also think the conditional functions looks more tidy, will change it!
Thanks,
Taeung
>> + EXTRA_CFLAGS += -g
>> + LLC_FLAGS += -mattr=dwarfris
>> + DWARF2BTF = y
>> +endif
>> +endif
>> +endif
>> +
>> # Trick to allow make to be run from this directory
>> all:
>> $(MAKE) -C ../../ $(CURDIR)/ BPF_SAMPLES_PATH=$(CURDIR)
>> @@ -256,4 +272,7 @@ $(obj)/%.o: $(src)/%.c
>> -Wno-gnu-variable-sized-type-not-at-end \
>> -Wno-address-of-packed-member -Wno-tautological-compare \
>> -Wno-unknown-warning-option $(CLANG_ARCH_ARGS) \
>> - -O2 -emit-llvm -c $< -o -| $(LLC) -march=bpf -filetype=obj -o $@
>> + -O2 -emit-llvm -c $< -o -| $(LLC) -march=bpf $(LLC_FLAGS) -filetype=obj -o $@
>> +ifeq ($(DWARF2BTF),y)
>> + $(BTF_PAHOLE) -J $@
>> +endif
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2018-07-26 10:08 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-07-25 16:30 [PATCH] samples/bpf: Add BTF build flags to Makefile Taeung Song
2018-07-25 20:38 ` Martin KaFai Lau
2018-07-25 20:45 ` Martin KaFai Lau
2018-07-26 9:54 ` Taeung Song
2018-07-26 1:16 ` Jakub Kicinski
2018-07-26 10:08 ` Taeung Song
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.