From patchwork Wed Oct 9 20:41:31 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ivan Khoronzhuk X-Patchwork-Id: 175690 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp1264543ill; Wed, 9 Oct 2019 13:42:24 -0700 (PDT) X-Google-Smtp-Source: APXvYqwy+0L38AuVs8ESii5NuQlV35lHZAU+DQmOczPnCAPSFv4I1SNMzFQ9aCJY84VjIhEM05S9 X-Received: by 2002:aa7:c959:: with SMTP id h25mr4822846edt.216.1570653744588; Wed, 09 Oct 2019 13:42:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570653744; cv=none; d=google.com; s=arc-20160816; b=cIaF0eJwCp9+EeVNG05k1pMpuERyTKbVpsZWXjyj+BN0OX2aVNUUt/fTrrLR5V4I9+ k4WJQPwzV1ybbIni1W9wslos3c/tbRfeVo5KTpUGmsoMQgVuHmLuM5LuoqZFHxm6zv/e Mtx418R2a6SVoDIjQnHSihqmjKJkvJz4Qon41fRDT10fb3AK3cy9O/KVJJgSMZT7Mvkc Jhd+7G8ULmhY/vSqqO4ZEuq4i3qFHCYzpKa9ayYbAndrkj5h2YTAnWyFfhziKcAxrbaT 0YIKgerEcep7dNk+F429lIE7TyPmx270arH3rPx/WMZ6Y3Py2yValg3VMVqdPtvZGWGE KkjA== 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=kcUDFvboIGVs/lRvRrRam3W53rLoFEO7a7iif6dtTIig+QwmV5WODRzNSA9gBGnk3b wbrVzoO49ayyoO/NxOSu9TPMaqDgYUOxN9aVUY8ingkLr10MrGNtNLgW01mpJY5FegVr 0ojXR6nZAmoh7XvFX768qOXOZGTva6ynFi0oCPbQWeu/iFBgu4WPc4kf5bJTtHLCixSl Bie6/Dhs35NcuKgWqcfJpbkdFRXSTL/xYhQArjKTxbNSnpCU34gqkYaQPKTRd44ODv4h lJehK2a5Kvn5WV75fi8om1ppEvbBsAMtPKfmAhBl0GthmdsQaaZneEL2qUMlgn68/WaP m+BA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=kPel8NhR; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-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 y2si1809263ejw.308.2019.10.09.13.42.24; Wed, 09 Oct 2019 13:42:24 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-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=kPel8NhR; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-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 S1732255AbfJIUmU (ORCPT + 26 others); Wed, 9 Oct 2019 16:42:20 -0400 Received: from mail-lj1-f195.google.com ([209.85.208.195]:33098 "EHLO mail-lj1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732136AbfJIUl7 (ORCPT ); Wed, 9 Oct 2019 16:41:59 -0400 Received: by mail-lj1-f195.google.com with SMTP id a22so3917706ljd.0 for ; Wed, 09 Oct 2019 13:41:57 -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=kPel8NhRVnyQDF2w6QWADNKWtsbDrjQPr/EdHwNRDl4cLpDTWXyvgReDZ91tE3VFXh dXHtbNI4k24um1FnMS7LDF9GQriPKlXm2AfN93wb6AlJCjBcZ+1ovPI3gmCbHjz7YiUG VTdR6WGa4vqentsck08qtxZzbc8hvVkqXMbD3LMwWWynxWghejtOT4tGdHljpAs/7Ago p43hmGYeoMy4u8J0oJUns/wP/+M+48aW9ccDLPcj4/rU/oCy+pYw5NM9CgumGq3C6Bar V0Sd3jBn0QjysTdCA5u0gfWo6eZSg9xv2soEhRb0SroRn5shjSsYspO+3Hs+E+nHixXg 0/3A== 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=DGNyFy86tymfxMH7Fn0dj8x55v8mqhshHZTHDfmh+2FCbgSw3r2e9J2WCX0go9PkP+ DIBIrn6xCpUAh+3QwOx3ZCr6EZpAaoT61sJJkhJtmhUoa1ERwGAtaboA+A5UVF2KvrEj TuuL4/iYETBiipJOxMEQXtqu2zvU2TsKJSWgre0gGp7eYRXob0YM3vnoTa3EG1xEUY/S /RsdBeLlBY4r8Sy58DoilkXa8+D/aDP6GmECkNZaGBVt0q1yPb0hTWZ1fzg4VpUMvIsd P3Fh/yu+oQ5ElLKFnEZvw8AuRbNUPj1QR7oEMafqbRrnZLoeZhLaWu9wVZdpt2tpu6BQ bU7Q== X-Gm-Message-State: APjAAAXii1k/Nj4G29sGlDBgwDXBmWCiLmUQ3vo82253dtUbgUOEdwxY pJQlHXvsQXeJokjnOaUTLSvjPQ== X-Received: by 2002:a2e:2943:: with SMTP id u64mr3622095lje.241.1570653716268; Wed, 09 Oct 2019 13:41:56 -0700 (PDT) Received: from localhost.localdomain (168-200-94-178.pool.ukrtel.net. [178.94.200.168]) by smtp.gmail.com with ESMTPSA id h3sm730871ljf.12.2019.10.09.13.41.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Oct 2019 13:41:55 -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 v4 bpf-next 12/15] libbpf: add C/LDFLAGS to libbpf.so and test_libpf targets Date: Wed, 9 Oct 2019 23:41:31 +0300 Message-Id: <20191009204134.26960-13-ivan.khoronzhuk@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191009204134.26960-1-ivan.khoronzhuk@linaro.org> References: <20191009204134.26960-1-ivan.khoronzhuk@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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)|" \