All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ihor Solodrai <ihor.solodrai@linux.dev>
To: Vitaly Chikunov <vt@altlinux.org>
Cc: Alexei Starovoitov <ast@kernel.org>,
	Andrii Nakryiko <andrii@kernel.org>,
	Daniel Borkmann <daniel@iogearbox.net>,
	bpf@vger.kernel.org, kernel-team@meta.com
Subject: Re: [PATCH bpf v2] resolve_btfids: Fix linker flags detection
Date: Tue, 3 Mar 2026 12:17:43 -0800	[thread overview]
Message-ID: <609c1db8-e674-4d65-8082-43e9fa4fbc9a@linux.dev> (raw)
In-Reply-To: <aac-hefhJ8znydSb@altlinux.org>

On 3/3/26 12:06 PM, Vitaly Chikunov wrote:
> Ihor,
> 
> [...]
>>  
>>  LIBELF_FLAGS := $(shell $(HOSTPKG_CONFIG) libelf --cflags 2>/dev/null)
>> +
>> +ifneq ($(filter -static,$(EXTRA_LDFLAGS)),)
>> +LIBELF_LIBS  := $(shell $(HOSTPKG_CONFIG) libelf --libs --static 2>/dev/null || echo -lelf -lzstd)
>> +else
>>  LIBELF_LIBS  := $(shell $(HOSTPKG_CONFIG) libelf --libs 2>/dev/null || echo -lelf)
>> +endif
>>  
>>  ZLIB_LIBS  := $(shell $(HOSTPKG_CONFIG) zlib --libs 2>/dev/null || echo -lz)
> 
> Perhaps, this line is not needed either, as `pkg-config libelf --libs
> --static` will add -lz.

The -lz has been there forever too [1], and a duplicate lib flag is
harmless here.  We also want to have reasonable defaults if pkg-config
is not available.

That said, the same can be achieved with the diff pasted below.

I don't mind either way, let's see if maintainers have an opinion.

diff --git a/tools/bpf/resolve_btfids/Makefile b/tools/bpf/resolve_btfids/Makefile
index 7672208f65e4..a7dac1587344 100644
--- a/tools/bpf/resolve_btfids/Makefile
+++ b/tools/bpf/resolve_btfids/Makefile
@@ -66,13 +66,11 @@ $(BPFOBJ): $(wildcard $(LIBBPF_SRC)/*.[ch] $(LIBBPF_SRC)/Makefile) | $(LIBBPF_OU
 LIBELF_FLAGS := $(shell $(HOSTPKG_CONFIG) libelf --cflags 2>/dev/null)
 
 ifneq ($(filter -static,$(EXTRA_LDFLAGS)),)
-LIBELF_LIBS  := $(shell $(HOSTPKG_CONFIG) libelf --libs --static 2>/dev/null || echo -lelf -lzstd)
+LIBELF_LIBS  := $(shell $(HOSTPKG_CONFIG) libelf --libs --static 2>/dev/null || echo -lelf -lzstd -lz)
 else
-LIBELF_LIBS  := $(shell $(HOSTPKG_CONFIG) libelf --libs 2>/dev/null || echo -lelf)
+LIBELF_LIBS  := $(shell $(HOSTPKG_CONFIG) libelf --libs 2>/dev/null || echo -lelf -lz)
 endif
 
-ZLIB_LIBS  := $(shell $(HOSTPKG_CONFIG) zlib --libs 2>/dev/null || echo -lz)
-
 HOSTCFLAGS_resolve_btfids += -g \
           -I$(srctree)/tools/include \
           -I$(srctree)/tools/include/uapi \
@@ -81,7 +79,7 @@ HOSTCFLAGS_resolve_btfids += -g \
           $(LIBELF_FLAGS) \
           -Wall -Werror
 
-LIBS = $(LIBELF_LIBS) $(ZLIB_LIBS)
+LIBS = $(LIBELF_LIBS)
 
 export srctree OUTPUT HOSTCFLAGS_resolve_btfids Q HOSTCC HOSTLD HOSTAR
 include $(srctree)/tools/build/Makefile.include


[1] https://lore.kernel.org/bpf/20200711215329.41165-2-jolsa@kernel.org/

> 
> Thanks,
> 
>> -ZSTD_LIBS  := $(shell $(HOSTPKG_CONFIG) libzstd --libs 2>/dev/null || echo -lzstd)
>>  
>>  HOSTCFLAGS_resolve_btfids += -g \
>>            -I$(srctree)/tools/include \
>> @@ -76,7 +81,7 @@ HOSTCFLAGS_resolve_btfids += -g \
>>            $(LIBELF_FLAGS) \
>>            -Wall -Werror
>>  
>> -LIBS = $(LIBELF_LIBS) $(ZLIB_LIBS) $(ZSTD_LIBS)
>> +LIBS = $(LIBELF_LIBS) $(ZLIB_LIBS)
>>  
>>  export srctree OUTPUT HOSTCFLAGS_resolve_btfids Q HOSTCC HOSTLD HOSTAR
>>  include $(srctree)/tools/build/Makefile.include
>> -- 
>> 2.53.0


  reply	other threads:[~2026-03-03 20:17 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-03 19:39 [PATCH bpf v2] resolve_btfids: Fix linker flags detection Ihor Solodrai
2026-03-03 20:06 ` Vitaly Chikunov
2026-03-03 20:17   ` Ihor Solodrai [this message]
2026-03-04 19:47 ` Vitaly Chikunov

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=609c1db8-e674-4d65-8082-43e9fa4fbc9a@linux.dev \
    --to=ihor.solodrai@linux.dev \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=kernel-team@meta.com \
    --cc=vt@altlinux.org \
    /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.