Skip to content

Commit 876e88e

Browse files
Joel Fernandesdavem330
authored andcommitted
samples/bpf: Enable cross compiler support
When cross compiling, bpf samples use HOSTCC for compiling the non-BPF part of the sample, however what we really want is to use the cross compiler to build for the cross target since that is what will load and run the BPF sample. Detect this and compile samples correctly. Acked-by: Alexei Starovoitov <ast@kernel.org> Signed-off-by: Joel Fernandes <joelaf@google.com> Acked-by: Daniel Borkmann <daniel@iogearbox.net> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 95ec669 commit 876e88e

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

samples/bpf/Makefile

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,11 @@ HOSTLOADLIBES_syscall_tp += -lelf
177177
LLC ?= llc
178178
CLANG ?= clang
179179

180+
# Detect that we're cross compiling and use the cross compiler
181+
ifdef CROSS_COMPILE
182+
HOSTCC = $(CROSS_COMPILE)gcc
183+
endif
184+
180185
# Trick to allow make to be run from this directory
181186
all:
182187
$(MAKE) -C ../../ $(CURDIR)/

0 commit comments

Comments
 (0)