Message ID | 20190916105433.11404-6-ivan.khoronzhuk@linaro.org |
---|---|
State | New |
Headers | show |
Series | samples: bpf: improve/fix cross-compilation | expand |
On Mon, Sep 16, 2019 at 3:59 AM Ivan Khoronzhuk <ivan.khoronzhuk@linaro.org> 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 > like "SMP is not supported" for armv7 and bunch of other errors are > issued resulting to incorrect final object. > --- > samples/bpf/Makefile | 10 ++++++++++ > 1 file changed, 10 insertions(+) > > diff --git a/samples/bpf/Makefile b/samples/bpf/Makefile > index 8ecc5d0c2d5b..d3c8db3df560 100644 > --- a/samples/bpf/Makefile > +++ b/samples/bpf/Makefile > @@ -185,6 +185,16 @@ 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 = $(shell echo "$(KBUILD_CFLAGS) " | \ > + sed 's/[[:blank:]]/\n/g' | sed '/^-D__LINUX_ARM_ARCH__/!d') Does the following work exactly like that without shelling out (and being arguably simpler)? ARM_ARCH_SELECTOR = $(filter -D__LINUX_ARM_ARCH__%, $(KBUILD_CFLAGS)) > + > +CLANG_EXTRA_CFLAGS := $(ARM_ARCH_SELECTOR) > +KBUILD_HOSTCFLAGS := $(ARM_ARCH_SELECTOR) Isn't this clearing out previous value of KBUILD_HOSTCFLAGS? Is that intentional, or it was supposed to be += here? > +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 > -- > 2.17.1 >
On Mon, Sep 16, 2019 at 01:44:23PM -0700, Andrii Nakryiko wrote: >On Mon, Sep 16, 2019 at 3:59 AM Ivan Khoronzhuk ><ivan.khoronzhuk@linaro.org> 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 >> like "SMP is not supported" for armv7 and bunch of other errors are >> issued resulting to incorrect final object. >> --- >> samples/bpf/Makefile | 10 ++++++++++ >> 1 file changed, 10 insertions(+) >> >> diff --git a/samples/bpf/Makefile b/samples/bpf/Makefile >> index 8ecc5d0c2d5b..d3c8db3df560 100644 >> --- a/samples/bpf/Makefile >> +++ b/samples/bpf/Makefile >> @@ -185,6 +185,16 @@ 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 = $(shell echo "$(KBUILD_CFLAGS) " | \ >> + sed 's/[[:blank:]]/\n/g' | sed '/^-D__LINUX_ARM_ARCH__/!d') > >Does the following work exactly like that without shelling out (and >being arguably simpler)? > >ARM_ARCH_SELECTOR = $(filter -D__LINUX_ARM_ARCH__%, $(KBUILD_CFLAGS)) > >> + >> +CLANG_EXTRA_CFLAGS := $(ARM_ARCH_SELECTOR) >> +KBUILD_HOSTCFLAGS := $(ARM_ARCH_SELECTOR) > >Isn't this clearing out previous value of KBUILD_HOSTCFLAGS? Is that >intentional, or it was supposed to be += here? > >> +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 >> -- >> 2.17.1 >> Just left from previous version filtering all -D options. Will update in next v., SELECTOR also. -- Regards, Ivan Khoronzhuk
diff --git a/samples/bpf/Makefile b/samples/bpf/Makefile index 8ecc5d0c2d5b..d3c8db3df560 100644 --- a/samples/bpf/Makefile +++ b/samples/bpf/Makefile @@ -185,6 +185,16 @@ 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 = $(shell echo "$(KBUILD_CFLAGS) " | \ + sed 's/[[:blank:]]/\n/g' | sed '/^-D__LINUX_ARM_ARCH__/!d') + +CLANG_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