Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752135AbdHGNGY (ORCPT ); Mon, 7 Aug 2017 09:06:24 -0400 Received: from mail-pg0-f49.google.com ([74.125.83.49]:35852 "EHLO mail-pg0-f49.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751247AbdHGNGV (ORCPT ); Mon, 7 Aug 2017 09:06:21 -0400 From: Joel Fernandes To: linux-kernel@vger.kernel.org Cc: Chenbo Feng , Alison Chaiken , Juri.Lelli@arm.com, Joel Fernandes , Alexei Starovoitov , Daniel Borkmann , netdev@vger.kernel.org (open list:BPF (Safe dynamic programs and tools)) Subject: [PATCH RFC v2 2/5] samples/bpf: Enable cross compiler support Date: Mon, 7 Aug 2017 06:05:59 -0700 Message-Id: <20170807130602.31785-3-joelaf@google.com> X-Mailer: git-send-email 2.14.0.rc1.383.gd1ce394fe2-goog In-Reply-To: <20170807130602.31785-1-joelaf@google.com> References: <20170807130602.31785-1-joelaf@google.com> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1001 Lines: 30 When cross compiling, bpf samples use HOSTCC, however what we really want is to use the cross compiler to build for the cross target since that is what will help run the BPF target code. Detect this and also set -static as LDFLAGS since often times we don't have control over what C library the cross target is running and its not smart to rely on it. Signed-off-by: Joel Fernandes --- samples/bpf/Makefile | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/samples/bpf/Makefile b/samples/bpf/Makefile index 6c7468eb3684..e5642c8c144d 100644 --- a/samples/bpf/Makefile +++ b/samples/bpf/Makefile @@ -152,6 +152,12 @@ HOSTLOADLIBES_test_map_in_map += -lelf LLC ?= llc CLANG ?= clang +# Detect that we're cross compiling and use the right compilers and flags +ifdef CROSS_COMPILE +HOSTCC = $(CROSS_COMPILE)gcc +HOSTLDFLAGS += -static +endif + # Trick to allow make to be run from this directory all: $(MAKE) -C ../../ $(CURDIR)/ -- 2.14.0.rc1.383.gd1ce394fe2-goog