From patchwork Fri Oct 11 00:28:05 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ivan Khoronzhuk X-Patchwork-Id: 175889 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp41613ill; Thu, 10 Oct 2019 17:28:43 -0700 (PDT) X-Google-Smtp-Source: APXvYqyweXn8wNeNboqDTaGQvaiBA7kstBJoP1H4dZvcCzyoAaTGpPM7tyzaYnOiow4jOpWu/9J7 X-Received: by 2002:a50:d794:: with SMTP id w20mr10992594edi.258.1570753723146; Thu, 10 Oct 2019 17:28:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570753723; cv=none; d=google.com; s=arc-20160816; b=GLBh64a1HwbNk8jaUV50IsVCSLrUgkELor4r1BBgXNGBNeDvDTgzVxmqQD3RYV6gfP 4DmK0IUe6DXcnt7zQNXcBrj7yD9ft78juYb7U6hkNit/Icw0Dfx2DJz2hE7VpVN3U3yG uf6gC/MITxE5Lw6b/cu9p2REq+qSFvlvsj2g9qJ8jRQNxmQP2eOhWkKNxwE35yQ9PIlZ nizwTT3sSlD+/x0UMtD9om5lFuT9ZO9sVaas26q1qzQZ5P9rJgOyePzX2Gi3glsTTdQC WKGUlvFk1SkORNeWF0IhpOhrmj5mUrza0oGGLE4IegayKcmZL66RL5m2ur6DvCH98LW4 hSIw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=dPicZ6dKiXggVDaTmZsHbexmmGF0NBX0XkLCl2NE9e8=; b=Rtn3XjesvZjxPSOfivM80NI3OEXjJucIAqE82x0F/wukjoosVyBkAFFd+N+F8JwwHU qiW35XgLBZzBGpkqtEC/5f8G8/bIKK/NGBYYfh+QRWqUvQS76cKiJEgQ00aqD2UO+3Co OMcUOlTUnva0KKl4O7xvtftkNsMlAFnp6f5R2vhKL9rioFkCjp32uUpIBzyv2cnr0RQh qdghbAs0p4QCOCT14tORL7Dag763+EiHtVDnmROhWecdyFV1sjG62S8m/D98iiqXPMKZ WPM2XWaf1yn+1t6mrzuC6xAks3nXVa0rBw9gIHAUE9sFpq1dgOgmcBrEvk0UssZ0sidz pA7g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=t3MFZlp7; spf=pass (google.com: best guess record for domain of netdev-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=netdev-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y50si4737688edd.237.2019.10.10.17.28.42; Thu, 10 Oct 2019 17:28:43 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of netdev-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=t3MFZlp7; spf=pass (google.com: best guess record for domain of netdev-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=netdev-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727743AbfJKA2m (ORCPT + 8 others); Thu, 10 Oct 2019 20:28:42 -0400 Received: from mail-lf1-f66.google.com ([209.85.167.66]:45460 "EHLO mail-lf1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727768AbfJKA2l (ORCPT ); Thu, 10 Oct 2019 20:28:41 -0400 Received: by mail-lf1-f66.google.com with SMTP id r134so5712277lff.12 for ; Thu, 10 Oct 2019 17:28:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=dPicZ6dKiXggVDaTmZsHbexmmGF0NBX0XkLCl2NE9e8=; b=t3MFZlp7JrKOCwmfn7u1hOiMi68CPBBmhejF5DP7FCApB0OUHnL1e1Vz0PnjgoLIqj wAkQ0GsgS4/ldLyAt8/zw9mgK+sFqHd4lVWktvbzEARep/C0sshXBBKSEaDAGcVo0/6V 8BTYD9LaGz/q/C5QeVOsLb/AKAwgJehXdhpIyM/J8HjfAaW5Btm4K7VJtZpNYWUEfCbY V7wShmtXIoIbmuXnBXoESSkwV7otaZ4ffWiRKF6rodq/UYfP4y6E9PWlD7sMelgEXZIG kjdyeC45fhvQOlabnZHkFElf7V9BeT+hBH7v0X8MgAM1mpO27+xgEXiqHAKtawGnSvK1 yzqw== 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=dPicZ6dKiXggVDaTmZsHbexmmGF0NBX0XkLCl2NE9e8=; b=GUqcOArrsRW9Gf1UKhKEvvtL4kDD/GA1t2xg0rAlCIIWLKHGC65H5aoWMXxGY9QG0/ wQhNfV3Tyzuh1hHJOkaCl4TN0NdEDfBKDfrHoiMGzhP71plMctruBJxYzo529vmI0+vk eNA8enN+71hhqk1I9UmX0ZFKVT0m2rKAK8UjcMKSnvRwPyHlVHNqkfQ/9ls/KzJ6Y/BF PRkIDkXepVCC9l4zn/Q6bC2X1cz8YKYVvV9ST7M4a2O6kf09i5F2tvGDfR9rFP9GPXzx g23O9Qjm8bA7xy71F6ZOP7+49kNOtKvz/zzKjKZ6mfp/tb8vb7j4vpUO9vXFdrjHUiE5 VRSw== X-Gm-Message-State: APjAAAXpuMOKjiI1Pzp/jZslRkhHEd+dcPmbSY/F1nK6usjL9ym8TgPZ G3QV+Aa4MoTtHQEe5dR6KSc/Pg== X-Received: by 2002:a19:c392:: with SMTP id t140mr7564752lff.156.1570753717149; Thu, 10 Oct 2019 17:28:37 -0700 (PDT) Received: from localhost.localdomain (88-201-94-178.pool.ukrtel.net. [178.94.201.88]) by smtp.gmail.com with ESMTPSA id 126sm2367010lfh.45.2019.10.10.17.28.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Oct 2019 17:28:36 -0700 (PDT) From: Ivan Khoronzhuk To: ast@kernel.org, daniel@iogearbox.net, yhs@fb.com, davem@davemloft.net, jakub.kicinski@netronome.com, hawk@kernel.org, john.fastabend@gmail.com Cc: linux-kernel@vger.kernel.org, netdev@vger.kernel.org, bpf@vger.kernel.org, clang-built-linux@googlegroups.com, ilias.apalodimas@linaro.org, sergei.shtylyov@cogentembedded.com, Ivan Khoronzhuk Subject: [PATCH v5 bpf-next 12/15] libbpf: add C/LDFLAGS to libbpf.so and test_libpf targets Date: Fri, 11 Oct 2019 03:28:05 +0300 Message-Id: <20191011002808.28206-13-ivan.khoronzhuk@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191011002808.28206-1-ivan.khoronzhuk@linaro.org> References: <20191011002808.28206-1-ivan.khoronzhuk@linaro.org> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org In case of C/LDFLAGS there is no way to pass them correctly to build command, for instance when --sysroot is used or external libraries are used, like -lelf, wich can be absent in toolchain. This can be used for samples/bpf cross-compiling allowing to get elf lib from sysroot. Signed-off-by: Ivan Khoronzhuk --- tools/lib/bpf/Makefile | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) -- 2.17.1 diff --git a/tools/lib/bpf/Makefile b/tools/lib/bpf/Makefile index 46280b5ad48d..75b538577c17 100644 --- a/tools/lib/bpf/Makefile +++ b/tools/lib/bpf/Makefile @@ -174,8 +174,9 @@ bpf_helper_defs.h: $(srctree)/include/uapi/linux/bpf.h $(OUTPUT)libbpf.so: $(OUTPUT)libbpf.so.$(LIBBPF_VERSION) $(OUTPUT)libbpf.so.$(LIBBPF_VERSION): $(BPF_IN) - $(QUIET_LINK)$(CC) --shared -Wl,-soname,libbpf.so.$(LIBBPF_MAJOR_VERSION) \ - -Wl,--version-script=$(VERSION_SCRIPT) $^ -lelf -o $@ + $(QUIET_LINK)$(CC) $(LDFLAGS) \ + --shared -Wl,-soname,libbpf.so.$(LIBBPF_MAJOR_VERSION) \ + -Wl,--version-script=$(VERSION_SCRIPT) $^ -lelf -o $@ @ln -sf $(@F) $(OUTPUT)libbpf.so @ln -sf $(@F) $(OUTPUT)libbpf.so.$(LIBBPF_MAJOR_VERSION) @@ -183,7 +184,7 @@ $(OUTPUT)libbpf.a: $(BPF_IN) $(QUIET_LINK)$(RM) $@; $(AR) rcs $@ $^ $(OUTPUT)test_libbpf: test_libbpf.c $(OUTPUT)libbpf.a - $(QUIET_LINK)$(CC) $(INCLUDES) $^ -lelf -o $@ + $(QUIET_LINK)$(CC) $(CFLAGS) $(LDFLAGS) $(INCLUDES) $^ -lelf -o $@ $(OUTPUT)libbpf.pc: $(QUIET_GEN)sed -e "s|@PREFIX@|$(prefix)|" \