From patchwork Mon Aug 7 13:03:03 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joel Fernandes X-Patchwork-Id: 798627 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=google.com header.i=@google.com header.b="sb526XYb"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3xQyRw2srRz9sR9 for ; Mon, 7 Aug 2017 23:05:00 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751967AbdHGND1 (ORCPT ); Mon, 7 Aug 2017 09:03:27 -0400 Received: from mail-pg0-f46.google.com ([74.125.83.46]:35212 "EHLO mail-pg0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751944AbdHGNDZ (ORCPT ); Mon, 7 Aug 2017 09:03:25 -0400 Received: by mail-pg0-f46.google.com with SMTP id v189so1497309pgd.2 for ; Mon, 07 Aug 2017 06:03:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=YjsEfL0qjD5nQJwZoXiXIRMJpfgYqPc1pj1A0qvx6PU=; b=sb526XYbgK4FAwqEbA9/O8q/QhGe8nmlQQoLfmhuZVO+gZ0SQSWi/R3DUOFxZLAOdW lUCs3MhvJ8TnrOAL6LCMJdni7nrGbUCkGhww1sJFbn4hcBTRT99xCJt/l1tTonTITzkO 5dOloPJtojCi9YvrLUzfSHJBygOzoilWT+mjo9yb3sPMv6HpYqqH0OG/OG185cvZeOyP Ibh43kycmJ/9oH11DP5dw/AW/0hfctHz5w/4pk3vr2FoS2LVQrPuXtkhzewRgTZrDL29 6fq8Xa6To0PrHw+U4ploSQfwNpY3+aQtDboKIVvtWy/Mdcao2lNmHKhrtoC+0mUhBVow 4i5g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=YjsEfL0qjD5nQJwZoXiXIRMJpfgYqPc1pj1A0qvx6PU=; b=RAGPRyZcHrMcTt9P49qxuC/Fkv1OdaGyJIZjwSZufDAa1DznMsMPVujQ+3llO/TBOs dwE7l/371i7SeO5j4RpqjG+NDEGhvjY+01uOEbUF64wranE8Q81Vfa2Of3tigOOErpvy 0eGtMc3QTqiQR4zk6Nfyrir8EXO40R+OTdqhkFTBXl1NQPNljURyDQSS4NttQunKcX1o RXUa7O2+LoEBxGBYAgETnWUJvg85QpIMeoN9N7398w1sBnQrVFb2iBVQ+FOyYq0IehGS 8FYjiMp1q2BbJKB8fnxnSdT4zBzzVhgTsOByUODIKinU6tEm7DZwOkIAYl0YSUkLMdOl ydYw== X-Gm-Message-State: AHYfb5iZxzo69UaEb7mWQT0ykqID50m5WXVlt8IGbP+rql26UG6HUQP0 PpQbN633M6ddcUfs X-Received: by 10.84.132.78 with SMTP id 72mr547773ple.66.1502111004603; Mon, 07 Aug 2017 06:03:24 -0700 (PDT) Received: from joelaf-glaptop0.roam.corp.google.com (c-24-130-92-142.hsd1.ca.comcast.net. [24.130.92.142]) by smtp.gmail.com with ESMTPSA id d28sm2955686pfb.139.2017.08.07.06.03.23 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 07 Aug 2017 06:03:24 -0700 (PDT) From: Joel Fernandes To: linux-kernel@vger.kernel.org Cc: Chenbo Feng , Alison Chaiken , Juri Lelli , Joel Fernandes , Alexei Starovoitov , Daniel Borkmann , netdev@vger.kernel.org (open list:BPF (Safe dynamic programs and tools)) Subject: [PATCH RFC 2/5] samples/bpf: Enable cross compiler support Date: Mon, 7 Aug 2017 06:03:03 -0700 Message-Id: <20170807130306.31530-3-joelaf@google.com> X-Mailer: git-send-email 2.14.0.rc1.383.gd1ce394fe2-goog In-Reply-To: <20170807130306.31530-1-joelaf@google.com> References: <20170807130306.31530-1-joelaf@google.com> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org 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)/