Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752865AbdICS0J (ORCPT ); Sun, 3 Sep 2017 14:26:09 -0400 Received: from mail-pg0-f52.google.com ([74.125.83.52]:34804 "EHLO mail-pg0-f52.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752613AbdICS0G (ORCPT ); Sun, 3 Sep 2017 14:26:06 -0400 X-Google-Smtp-Source: ADKCNb6U3yhnPgNKmGknbV3AXPQ2U2TMkyLTYzxeJO/Lh8K0ghSCwBZ406evNogB7okkGFpIMedOTg== From: Joel Fernandes To: linux-kernel@vger.kernel.org, netdev@vger.kernel.org Cc: kernel-team@android.com, Juri Lelli , Alison Chaiken , Chenbo Feng , Joel Fernandes , Alexei Starovoitov , Daniel Borkmann , David Miller Subject: [PATCH RFC v3 2/4] samples/bpf: Enable cross compiler support Date: Sun, 3 Sep 2017 11:25:47 -0700 Message-Id: <20170903182549.30866-2-joelaf@google.com> X-Mailer: git-send-email 2.14.1.581.gf28d330327-goog In-Reply-To: <20170903182549.30866-1-joelaf@google.com> References: <20170903182549.30866-1-joelaf@google.com> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 999 Lines: 31 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. CC: Alexei Starovoitov CC: Daniel Borkmann Cc: David Miller Signed-off-by: Joel Fernandes --- samples/bpf/Makefile | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/samples/bpf/Makefile b/samples/bpf/Makefile index cf17c7932a6e..13f74b67ca44 100644 --- a/samples/bpf/Makefile +++ b/samples/bpf/Makefile @@ -177,6 +177,11 @@ HOSTLOADLIBES_syscall_tp += -lelf LLC ?= llc CLANG ?= clang +# Detect that we're cross compiling and use the cross compiler +ifdef CROSS_COMPILE +HOSTCC = $(CROSS_COMPILE)gcc +endif + # Trick to allow make to be run from this directory all: $(MAKE) -C ../../ $(CURDIR)/ -- 2.14.1.581.gf28d330327-goog