From patchwork Wed Sep 4 21:22:07 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ivan Khoronzhuk X-Patchwork-Id: 173079 Delivered-To: patch@linaro.org Received: by 2002:a05:6e02:ce:0:0:0:0 with SMTP id r14csp455167ilq; Wed, 4 Sep 2019 14:23:33 -0700 (PDT) X-Google-Smtp-Source: APXvYqwzCDz7qqRDBxCv0V6GLKpusHx13mzcoqv3LiJaaNDFMcZtXHD6LvbgkraPTCYuXOACGJbn X-Received: by 2002:a63:4522:: with SMTP id s34mr168987pga.362.1567632213252; Wed, 04 Sep 2019 14:23:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1567632213; cv=none; d=google.com; s=arc-20160816; b=hyn0IPsHV/cDeJc7WerUGCsZJPLY5M5s6RnnxNfLxQbkfPcteUo6sOOzfY2G8dIgO7 6GTZmwJuvgqeE4/EtTeB8R1T7wQWDPDuFd4fmZ9EXOjLO0Vcg8y6h/RNN86btvuDNIZn +SHt3di5P70+4hcRYYcFZGda8xHcV3hsQd6v7NQeUKSnRoD0eZYEkDe8NOlD/tZ1bxRi qdMIOsD3F+8Lg+Cu9fTjU8iPC4cE0jz272ZVJbH/q8d29+PGFS8+Bxv2vX6gI21pV36W KjR1AgPwo1TWc6WF3byeLKWeHgfBX2pKbYouYk3Nku/w3tO65cmde2ntzmn323Zsr49I zcLg== 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=yAjuHlaJV4iM+XkUvTeUDNJ1TAXGjdj3xJMvNO0S43o=; b=Ap5JqDaVdlJF7qJrOayUs5n0z/YEoYiKRaP8gHrX10vCy+07CAmYkE0CF0otGHSVEC ZnGzYpgkivF2HfpxW5ZKzO7xa7pR64Gov4JJ4MRejQn+h89rrN4gC91WdJrWBp3Km1FD duy8Zft6xI/mS51sR1Sn6r22n+Q0mZUImS7F7+b70vH84KJ9eDiUAn0sTWZugYvNS5ND 1wtrTC2JCu+sLeZA7k0nc2cBSlyv8wnueboSGr3eETx6TB8gQTrxfUflsJMiPtTJUhki MJc5fH1FESIkSbBSGAagNmitPzybIsm7G8My38g8m7cvfJ1W0s5sWnuWpECar3kq+/05 Oixg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Cyv0J+ys; 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 g4si17759609pgf.383.2019.09.04.14.23.33; Wed, 04 Sep 2019 14:23:33 -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=Cyv0J+ys; 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 S1730842AbfIDVXc (ORCPT + 28 others); Wed, 4 Sep 2019 17:23:32 -0400 Received: from mail-lj1-f194.google.com ([209.85.208.194]:38389 "EHLO mail-lj1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730273AbfIDVXH (ORCPT ); Wed, 4 Sep 2019 17:23:07 -0400 Received: by mail-lj1-f194.google.com with SMTP id h3so194422ljb.5 for ; Wed, 04 Sep 2019 14:23:05 -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=yAjuHlaJV4iM+XkUvTeUDNJ1TAXGjdj3xJMvNO0S43o=; b=Cyv0J+ysGE8GlcBy84R0TU6rZdMLzrvRQiwpquEiozDeaAQQQbYdykncSxj9SDvUie 8cgkYnKiR0ReAyi40NULGieV75yTwmLbqtUC8erbl75yzlcUtht7eSCMcD96oSjQ6M48 na1DMKbDpuTpTnG6pBKnr8wpjHOb3yRIBcWZofhCezWk3TBniFS5nn7vx0YuyOh6Lmdh HWKQEzLvfpoT2NyKmWajaXus8qX7m3kiia7NxEwBexwDarrjZLHJ3aFVDEsLsVgZRvb9 Ba6Q8Da00IG4GVsd36zqBgKddkHbNRYPDGnrTw0kpAnEYfpgEDkKlGd7hMCJzVM7iMuK Jj8w== 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=yAjuHlaJV4iM+XkUvTeUDNJ1TAXGjdj3xJMvNO0S43o=; b=oZejzdDjS/AgENo20cvd4SscjZV8en2PfpeRno9nLB6cwo+8I/+TmaCKkcmXfz46r0 cF/QCeNU9DEEd5C3yxeu9htV5xGoLb0e3qLPABO9zHJ3OawAfoP197+NcJiOpJuPaq2y +GrfRqtGDTnXD3UWiSfBD2Zn9J8eJ/VMS103AhZmb1BUF82PeRcr3YKRVRUdx9sONtml 4fe5asG+Gg5IpR+pxd8HRvyXGaN/bDDh3WP027fJpUe/HtiZ2FzXfzy5U+hwhUxbOA5w IDk6pVmSeloFmcLGKmFgamLfJM8urd06vUAISn48GTCqosoxtmWQWi0Fqb3C4Qlfqqqs LAYg== X-Gm-Message-State: APjAAAVNqnsBec1qCsjCBZaCg7tcqr3MEVlEexFevBUBGAumQkzAj5dT D78Xn75xvSbapUlG916VK6AKGw== X-Received: by 2002:a05:651c:1ba:: with SMTP id c26mr4261123ljn.154.1567632184814; Wed, 04 Sep 2019 14:23:04 -0700 (PDT) Received: from localhost.localdomain (168-200-94-178.pool.ukrtel.net. [178.94.200.168]) by smtp.gmail.com with ESMTPSA id s8sm3540836ljd.94.2019.09.04.14.23.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Sep 2019 14:23:04 -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, Ivan Khoronzhuk Subject: [PATCH bpf-next 3/8] libbpf: Makefile: add C/CXX/LDFLAGS to libbpf.so and test_libpf targets Date: Thu, 5 Sep 2019 00:22:07 +0300 Message-Id: <20190904212212.13052-4-ivan.khoronzhuk@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190904212212.13052-1-ivan.khoronzhuk@linaro.org> References: <20190904212212.13052-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 LDFLAGS and EXTRA_CC flags there is no way to pass them correctly to build command, for instance when --sysroot is used or external libraries are used, like -lelf. In follow up patches this is used for samples/bpf cross-compiling getting elf lib from sysroot. Signed-off-by: Ivan Khoronzhuk --- tools/lib/bpf/Makefile | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) -- 2.17.1 diff --git a/tools/lib/bpf/Makefile b/tools/lib/bpf/Makefile index c6f94cffe06e..bccfa556ef4e 100644 --- a/tools/lib/bpf/Makefile +++ b/tools/lib/bpf/Makefile @@ -94,6 +94,10 @@ else CFLAGS := -g -Wall endif +ifdef EXTRA_CXXFLAGS + CXXFLAGS := $(EXTRA_CXXFLAGS) +endif + ifeq ($(feature-libelf-mmap), 1) override CFLAGS += -DHAVE_LIBELF_MMAP_SUPPORT endif @@ -176,8 +180,9 @@ $(BPF_IN): force elfdep bpfdep $(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) @@ -185,7 +190,7 @@ $(OUTPUT)libbpf.a: $(BPF_IN) $(QUIET_LINK)$(RM) $@; $(AR) rcs $@ $^ $(OUTPUT)test_libbpf: test_libbpf.cpp $(OUTPUT)libbpf.a - $(QUIET_LINK)$(CXX) $(INCLUDES) $^ -lelf -o $@ + $(QUIET_LINK)$(CXX) $(CXXFLAGS) $(LDFLAGS) $(INCLUDES) $^ -lelf -o $@ $(OUTPUT)libbpf.pc: $(QUIET_GEN)sed -e "s|@PREFIX@|$(prefix)|" \