Received: by 2002:a5b:505:0:0:0:0:0 with SMTP id o5csp1409219ybp; Wed, 9 Oct 2019 13:43:15 -0700 (PDT) X-Google-Smtp-Source: APXvYqxQ05RlzF866/fHsLZs5vg5KkDSCPweJ1jEf2CLOIj4g8yRIRuFGOKarrlS2fDwC298A2+6 X-Received: by 2002:a17:906:7c57:: with SMTP id g23mr4739279ejp.116.1570653795054; Wed, 09 Oct 2019 13:43:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570653795; cv=none; d=google.com; s=arc-20160816; b=r5T5bZHr60YAN9CW3E2PDODhehtzCXFBo2YL8C4xpS3De+KX6FPk9zeQbICb9/K1GH pXTUsFWTxMpH9S4ETrhqPnaxXcZSWsXMy25Wjcgc0yd1Mb+RPvOc6l3JtuccSEQoEd1M AKrI2fIjHlIFpqrM+78uWgDmfvrAC2BATlkJjqm1P3dpbT007s0yEJPqGUo8H8Ajdost oNIBgzXPHXegfiDH/wdFPynmhTz00QniR9Zf6H30yz1Q+aJ121A6CsHVNEY1hAKhgfi9 YAkBMifVu3FgeEWEZP3oBloC2eHWPHhgFNDcmlV1/upICZnmbicTFPbKGB3CpyM5DcFw mnMA== 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 f57si2129168edb.165.2019.10.09.13.42.51; Wed, 09 Oct 2019 13:43:15 -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 S1732250AbfJIUmS (ORCPT + 99 others); Wed, 9 Oct 2019 16:42:18 -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(-) 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)|" \ -- 2.17.1