]> git.baikalelectronics.ru Git - kernel.git/commitdiff
libbpf: Add C/LDFLAGS to libbpf.so and test_libpf targets
authorIvan Khoronzhuk <ivan.khoronzhuk@linaro.org>
Fri, 11 Oct 2019 00:28:05 +0000 (03:28 +0300)
committerAlexei Starovoitov <ast@kernel.org>
Sat, 12 Oct 2019 23:08:59 +0000 (16:08 -0700)
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 <ivan.khoronzhuk@linaro.org>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Acked-by: Andrii Nakryiko <andriin@fb.com>
Link: https://lore.kernel.org/bpf/20191011002808.28206-13-ivan.khoronzhuk@linaro.org
tools/lib/bpf/Makefile

index 46280b5ad48d8396abc3269ca536e7cc418984cc..75b538577c17059fafa6095696cf464cf6b8c42c 100644 (file)
@@ -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)|" \