All of lore.kernel.org
 help / color / mirror / Atom feed
From: Daniel Borkmann <daniel@iogearbox.net>
To: Akihiko Odaki <akihiko.odaki@daynix.com>
Cc: Andrii Nakryiko <andrii@kernel.org>,
	Mykola Lysenko <mykolal@fb.com>,
	Alexei Starovoitov <ast@kernel.org>,
	Martin KaFai Lau <martin.lau@linux.dev>,
	Song Liu <song@kernel.org>,
	Yonghong Song <yonghong.song@linux.dev>,
	John Fastabend <john.fastabend@gmail.com>,
	KP Singh <kpsingh@kernel.org>,
	Stanislav Fomichev <sdf@google.com>, Hao Luo <haoluo@google.com>,
	Jiri Olsa <jolsa@kernel.org>, Shuah Khan <shuah@kernel.org>,
	Nick Terrell <terrelln@fb.com>,
	bpf@vger.kernel.org, linux-kselftest@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH bpf-next] selftests/bpf: Use pkg-config to determine ld flags
Date: Mon, 16 Oct 2023 13:39:13 +0200	[thread overview]
Message-ID: <062d9a75-caa0-d05d-14db-cd59dafab8b9@iogearbox.net> (raw)
In-Reply-To: <20231015133916.257197-1-akihiko.odaki@daynix.com>

On 10/15/23 3:39 PM, Akihiko Odaki wrote:
> When linking statically, libraries may require other dependencies to be
> included to ld flags. In particular, libelf may require libzstd. Use
> pkg-config to determine such dependencies.

Is this not covered via -lz or is it that the name differs?

Anyway, this change breaks selftest build for BPF CI (see below), could this
either be made optional or detected differently?

https://github.com/kernel-patches/bpf/actions/runs/6524480596/job/17716170021

[...]
   make: pkg-config: Command not found
     CC       bench.o
   make: pkg-config: Command not found
   make: pkg-config: Command not found
     CC       bench_count.o
   make: pkg-config: Command not found
     BINARY   xdp_redirect_multi
     HOSTLD  /tmp/work/bpf/bpf/tools/testing/selftests/bpf/tools/build/resolve_btfids/fixdep-in.o
     LINK    /tmp/work/bpf/bpf/tools/testing/selftests/bpf/tools/build/resolve_btfids/fixdep
     CC       veristat.o
     INSTALL /tmp/work/bpf/bpf/tools/testing/selftests/bpf/tools/build/resolve_btfids/libsubcmd//include/subcmd/exec-cmd.h
     CC      /tmp/work/bpf/bpf/tools/testing/selftests/bpf/tools/build/resolve_btfids/libsubcmd/exec-cmd.o
   make: pkg-config: Command not found
     INSTALL /tmp/work/bpf/bpf/tools/testing/selftests/bpf/tools/build/resolve_btfids/libsubcmd//include/subcmd/help.h
     CC      /tmp/work/bpf/bpf/tools/testing/selftests/bpf/tools/build/resolve_btfids/libsubcmd/help.o
     INSTALL /tmp/work/bpf/bpf/tools/testing/selftests/bpf/tools/build/resolve_btfids/libsubcmd//include/subcmd/pager.h
   make: pkg-config: Command not found
     BINARY   test_verifier
     CC      /tmp/work/bpf/bpf/tools/testing/selftests/bpf/tools/build/resolve_btfids/libsubcmd/pager.o
     BINARY   test_tag
     CC      /tmp/work/bpf/bpf/tools/testing/selftests/bpf/tools/build/resolve_btfids/libsubcmd/parse-options.o
   make: pkg-config: Command not found
     CC      /tmp/work/bpf/bpf/tools/testing/selftests/bpf/tools/build/resolve_btfids/libsubcmd/run-command.o
     INSTALL /tmp/work/bpf/bpf/tools/testing/selftests/bpf/tools/build/resolve_btfids/libsubcmd//include/subcmd/parse-options.h
   make: pkg-config: Command not found
     INSTALL /tmp/work/bpf/bpf/tools/testing/selftests/bpf/tools/build/resolve_btfids/libsubcmd//include/subcmd/run-command.h
     CC      /tmp/work/bpf/bpf/tools/testing/selftests/bpf/tools/build/resolve_btfids/libsubcmd/sigchain.o
     BINARY   flow_dissector_load
     CC      /tmp/work/bpf/bpf/tools/testing/selftests/bpf/tools/build/resolve_btfids/libsubcmd/subcmd-config.o
   make: pkg-config: Command not found
     BINARY   test_lirc_mode2_user
     INSTALL libsubcmd_headers
     BINARY   xdping
   make: pkg-config: Command not found

>   tools/testing/selftests/bpf/Makefile   | 3 ++-
>   tools/testing/selftests/bpf/README.rst | 2 +-
>   2 files changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/tools/testing/selftests/bpf/Makefile b/tools/testing/selftests/bpf/Makefile
> index caede9b574cb..833134aa2eda 100644
> --- a/tools/testing/selftests/bpf/Makefile
> +++ b/tools/testing/selftests/bpf/Makefile
> @@ -4,6 +4,7 @@ include ../../../scripts/Makefile.arch
>   include ../../../scripts/Makefile.include
>   
>   CXX ?= $(CROSS_COMPILE)g++
> +PKG_CONFIG ?= $(CROSS_COMPILE)pkg-config
>   
>   CURDIR := $(abspath .)
>   TOOLSDIR := $(abspath ../../..)
> @@ -31,7 +32,7 @@ CFLAGS += -g -O0 -rdynamic -Wall -Werror $(GENFLAGS) $(SAN_CFLAGS)	\
>   	  -I$(CURDIR) -I$(INCLUDE_DIR) -I$(GENDIR) -I$(LIBDIR)		\
>   	  -I$(TOOLSINCDIR) -I$(APIDIR) -I$(OUTPUT)
>   LDFLAGS += $(SAN_LDFLAGS)
> -LDLIBS += -lelf -lz -lrt -lpthread
> +LDLIBS += $(shell $(PKG_CONFIG) --libs libelf zlib) -lrt -lpthread
>   
>   ifneq ($(LLVM),)
>   # Silence some warnings when compiled with clang
> diff --git a/tools/testing/selftests/bpf/README.rst b/tools/testing/selftests/bpf/README.rst
> index cb9b95702ac6..9af79c7a9b58 100644
> --- a/tools/testing/selftests/bpf/README.rst
> +++ b/tools/testing/selftests/bpf/README.rst
> @@ -77,7 +77,7 @@ In case of linker errors when running selftests, try using static linking:
>   
>   .. code-block:: console
>   
> -  $ LDLIBS=-static vmtest.sh
> +  $ LDLIBS=-static PKG_CONFIG='pkg-config --static' vmtest.sh
>   
>   .. note:: Some distros may not support static linking.
>   
> 


  reply	other threads:[~2023-10-16 11:39 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-15 13:39 [PATCH bpf-next] selftests/bpf: Use pkg-config to determine ld flags Akihiko Odaki
2023-10-15 13:39 ` Akihiko Odaki
2023-10-16 11:39 ` Daniel Borkmann [this message]
2023-10-16 11:57   ` Akihiko Odaki

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=062d9a75-caa0-d05d-14db-cd59dafab8b9@iogearbox.net \
    --to=daniel@iogearbox.net \
    --cc=akihiko.odaki@daynix.com \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=haoluo@google.com \
    --cc=john.fastabend@gmail.com \
    --cc=jolsa@kernel.org \
    --cc=kpsingh@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=martin.lau@linux.dev \
    --cc=mykolal@fb.com \
    --cc=sdf@google.com \
    --cc=shuah@kernel.org \
    --cc=song@kernel.org \
    --cc=terrelln@fb.com \
    --cc=yonghong.song@linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.