diff mbox series

[v5,bpf-next,05/15] samples/bpf: use __LINUX_ARM_ARCH__ selector for arm

Message ID 20191011002808.28206-6-ivan.khoronzhuk@linaro.org
State Accepted
Delegated to: BPF Maintainers
Headers show
Series samples: bpf: improve/fix cross-compilation | expand

Commit Message

Ivan Khoronzhuk Oct. 11, 2019, 12:27 a.m. UTC
For arm, -D__LINUX_ARM_ARCH__=X is min version used as instruction
set selector and is absolutely required while parsing some parts of
headers. It's present in KBUILD_CFLAGS but not in autoconf.h, so let's
retrieve it from and add to programs cflags. In another case errors
like "SMP is not supported" for armv7 and bunch of other errors are
issued resulting to incorrect final object.

Signed-off-by: Ivan Khoronzhuk <ivan.khoronzhuk@linaro.org>
---
 samples/bpf/Makefile | 8 ++++++++
 1 file changed, 8 insertions(+)

Comments

Sergei Shtylyov Oct. 11, 2019, 8:46 a.m. UTC | #1
Hello!

    Sorry, didn't comment on v4...

On 11.10.2019 3:27, Ivan Khoronzhuk wrote:

> For arm, -D__LINUX_ARM_ARCH__=X is min version used as instruction
> set selector and is absolutely required while parsing some parts of
> headers. It's present in KBUILD_CFLAGS but not in autoconf.h, so let's
> retrieve it from and add to programs cflags. In another case errors

    From where? And it's program's, no?

> like "SMP is not supported" for armv7 and bunch of other errors are
> issued resulting to incorrect final object.
> 
> Signed-off-by: Ivan Khoronzhuk <ivan.khoronzhuk@linaro.org>
[...]

MBR, Sergei
Ivan Khoronzhuk Oct. 11, 2019, 9:56 a.m. UTC | #2
On Fri, Oct 11, 2019 at 11:46:54AM +0300, Sergei Shtylyov wrote:
>Hello!
>
>   Sorry, didn't comment on v4...
>
>On 11.10.2019 3:27, Ivan Khoronzhuk wrote:
>
>>For arm, -D__LINUX_ARM_ARCH__=X is min version used as instruction
>>set selector and is absolutely required while parsing some parts of
>>headers. It's present in KBUILD_CFLAGS but not in autoconf.h, so let's
>>retrieve it from and add to programs cflags. In another case errors
>
>   From where? And it's program's, no?
from KBUIL_CFLAGS. it's programs.

>
>>like "SMP is not supported" for armv7 and bunch of other errors are
>>issued resulting to incorrect final object.
>>
>>Signed-off-by: Ivan Khoronzhuk <ivan.khoronzhuk@linaro.org>
>[...]
>
>MBR, Sergei
diff mbox series

Patch

diff --git a/samples/bpf/Makefile b/samples/bpf/Makefile
index cf882e43648a..9b33e7395eac 100644
--- a/samples/bpf/Makefile
+++ b/samples/bpf/Makefile
@@ -185,6 +185,14 @@  HOSTLDLIBS_map_perf_test	+= -lrt
 HOSTLDLIBS_test_overhead	+= -lrt
 HOSTLDLIBS_xdpsock		+= -pthread
 
+ifeq ($(ARCH), arm)
+# Strip all except -D__LINUX_ARM_ARCH__ option needed to handle linux
+# headers when arm instruction set identification is requested.
+ARM_ARCH_SELECTOR := $(filter -D__LINUX_ARM_ARCH__%, $(KBUILD_CFLAGS))
+BPF_EXTRA_CFLAGS := $(ARM_ARCH_SELECTOR)
+KBUILD_HOSTCFLAGS += $(ARM_ARCH_SELECTOR)
+endif
+
 # Allows pointing LLC/CLANG to a LLVM backend with bpf support, redefine on cmdline:
 #  make samples/bpf/ LLC=~/git/llvm/build/bin/llc CLANG=~/git/llvm/build/bin/clang
 LLC ?= llc