• Jean-Philippe Brucker's avatar
    tools/runqslower: Fix cross-build · e4ac80ef
    Jean-Philippe Brucker authored
    Commit be79505c ("tools/runqslower: Install libbpf headers when
    building") uses the target libbpf to build the host bpftool, which
    doesn't work when cross-building:
    
      make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- -C tools/bpf/runqslower O=/tmp/runqslower
      ...
        LINK    /tmp/runqslower/bpftool/bpftool
      /usr/bin/ld: /tmp/runqslower/libbpf/libbpf.a(libbpf-in.o): Relocations in generic ELF (EM: 183)
      /usr/bin/ld: /tmp/runqslower/libbpf/libbpf.a: error adding symbols: file in wrong format
      collect2: error: ld returned 1 exit status
    
    When cross-building, the target architecture differs from the host. The
    bpftool used for building runqslower is executed on the host, and thus
    must use a different libbpf than that used for runqslower itself.
    Remove the LIBBPF_OUTPUT and LIBBPF_DESTDIR parameters, so the bpftool
    build makes its own library if necessary.
    
    In the selftests, pass the host bpftool, already a prerequisite for the
    runqslower recipe, as BPFTOOL_OUTPUT. The runqslower Makefile will use
    the bpftool that's already built for selftests instead of making a new
    one.
    
    Fixes: be79505c ("tools/runqslower: Install libbpf headers when building")
    Signed-off-by: default avatarJean-Philippe Brucker <jean-philippe@linaro.org>
    Signed-off-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
    Reviewed-by: default avatarQuentin Monnet <quentin@isovalent.com>
    Link: https://lore.kernel.org/bpf/20211112155128.565680-1-jean-philippe@linaro.orgSigned-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
    e4ac80ef
Makefile 20.4 KB