libbpf-tools: Fix build dependence for parallel builds
authorVitaly Chikunov <vt@altlinux.org>
Thu, 13 May 2021 08:46:42 +0000 (11:46 +0300)
committeryonghong-song <ys114321@gmail.com>
Fri, 14 May 2021 01:11:40 +0000 (18:11 -0700)
Add LIBBPF_OBJ dependence to `%.o'.

When libbpf-tools built in parallel (with `make -j`) sometimes
`map_helpers.o' is built before `libbpf.a' causing build error:

  $ make -j8 -C libbpf-tools BPFTOOL=/usr/sbin/bpftool
  ...
  make: Entering directory '/usr/src/RPM/BUILD/bcc-0.19.0/libbpf-tools'
    CC       map_helpers.o
  In file included from map_helpers.c:7:
  ./map_helpers.h:6:10: fatal error: 'bpf/bpf.h' file not found
   ^~~~~~~~~~~
  1 error generated.
  ...
  make: Leaving directory '/usr/src/RPM/BUILD/bcc-0.19.0/libbpf-tools'
    INSTALL  bpf.h libbpf.h btf.h xsk.h libbpf_util.h bpf_helpers.h bpf_helper_defs.h bpf_tracing.h bpf_endian.h bpf_core_read.h libbpf_common.h
  ...
    INSTALL  libbpf.a
  error: Bad exit status from /usr/src/tmp/rpm-tmp.63536 (%build)

Fixes: #3412
Signed-off-by: Vitaly Chikunov <vt@altlinux.org>
libbpf-tools/Makefile

index 3ee0c552bb809ff8e2dd674014cc117ae03d7e98..9ffbcad676403d169ec65204ecaee5a834748375 100644 (file)
@@ -82,7 +82,7 @@ $(APPS): %: $(OUTPUT)/%.o $(LIBBPF_OBJ) $(COMMON_OBJ) | $(OUTPUT)
 
 $(patsubst %,$(OUTPUT)/%.o,$(APPS)): %.o: %.skel.h
 
-$(OUTPUT)/%.o: %.c $(wildcard %.h) | $(OUTPUT)
+$(OUTPUT)/%.o: %.c $(wildcard %.h) $(LIBBPF_OBJ) | $(OUTPUT)
        $(call msg,CC,$@)
        $(Q)$(CC) $(CFLAGS) $(INCLUDES) -c $(filter %.c,$^) -o $@