Message ID | 20211122192019.1277299-1-jean-philippe@linaro.org (mailing list archive) |
---|---|
Headers | show |
Series | tools/bpf: Enable cross-building with clang | expand |
On Mon, 22 Nov 2021 at 19:23, Jean-Philippe Brucker <jean-philippe@linaro.org> wrote: > > Add support for cross-building BPF tools and selftests with clang, by > passing LLVM=1 or CC=clang to make, as well as CROSS_COMPILE. A single > clang toolchain can generate binaries for multiple architectures, so > instead of having prefixes such as aarch64-linux-gnu-gcc, clang uses the > -target parameter: `clang -target aarch64-linux-gnu'. > > Patch 1 adds the parameter in Makefile.include so tools can easily > support this. Patch 2 prepares for the libbpf change from patch 3 (keep > building resolve_btfids's libbpf in the host arch, when cross-building > the kernel with clang). Patches 3-6 enable cross-building BPF tools with > clang. The set looks good to me. I checked that the tools are still building (without cross-compiling). I currently have issues building the selftests on my setup, but they don't appear to be related to this patchset. Acked-by: Quentin Monnet <quentin@isovalent.com> Note that on bpf-next, patch 5 (runqslower) has a conflict with be79505caf3f ("tools/runqslower: Install libbpf headers when building"). Did you consider enabling cross-compiling for the BPF samples too? I'm asking because the build system is pretty similar to the BPF tools. Thanks, Quentin
On 11/26/21 9:36 PM, Quentin Monnet wrote: > On Mon, 22 Nov 2021 at 19:23, Jean-Philippe Brucker > <jean-philippe@linaro.org> wrote: >> >> Add support for cross-building BPF tools and selftests with clang, by >> passing LLVM=1 or CC=clang to make, as well as CROSS_COMPILE. A single >> clang toolchain can generate binaries for multiple architectures, so >> instead of having prefixes such as aarch64-linux-gnu-gcc, clang uses the >> -target parameter: `clang -target aarch64-linux-gnu'. >> >> Patch 1 adds the parameter in Makefile.include so tools can easily >> support this. Patch 2 prepares for the libbpf change from patch 3 (keep >> building resolve_btfids's libbpf in the host arch, when cross-building >> the kernel with clang). Patches 3-6 enable cross-building BPF tools with >> clang. > > The set looks good to me. I checked that the tools are still building > (without cross-compiling). I currently have issues building the > selftests on my setup, but they don't appear to be related to this > patchset. > > Acked-by: Quentin Monnet <quentin@isovalent.com> > > Note that on bpf-next, patch 5 (runqslower) has a conflict with > be79505caf3f ("tools/runqslower: Install libbpf headers when > building"). Jean-Philippe, please do one rebase spin for addressing the above. Thanks, Daniel
On Fri, Nov 26, 2021 at 08:36:24PM +0000, Quentin Monnet wrote: > On Mon, 22 Nov 2021 at 19:23, Jean-Philippe Brucker > <jean-philippe@linaro.org> wrote: > > > > Add support for cross-building BPF tools and selftests with clang, by > > passing LLVM=1 or CC=clang to make, as well as CROSS_COMPILE. A single > > clang toolchain can generate binaries for multiple architectures, so > > instead of having prefixes such as aarch64-linux-gnu-gcc, clang uses the > > -target parameter: `clang -target aarch64-linux-gnu'. > > > > Patch 1 adds the parameter in Makefile.include so tools can easily > > support this. Patch 2 prepares for the libbpf change from patch 3 (keep > > building resolve_btfids's libbpf in the host arch, when cross-building > > the kernel with clang). Patches 3-6 enable cross-building BPF tools with > > clang. > > The set looks good to me. I checked that the tools are still building > (without cross-compiling). I currently have issues building the > selftests on my setup, but they don't appear to be related to this > patchset. > > Acked-by: Quentin Monnet <quentin@isovalent.com> > > Note that on bpf-next, patch 5 (runqslower) has a conflict with > be79505caf3f ("tools/runqslower: Install libbpf headers when > building"). Ah right, I have the series on top of "tools/runqslower: Fix cross-build", which is in bpf/master but not yet in bpf-next. I'll wait for the branches to synchronize before resending, since the patches conflict either way. > Did you consider enabling cross-compiling for the BPF samples too? I'm > asking because the build system is pretty similar to the BPF tools. Right, the problems seem similar to the selftests (need to build two libbpfs, pass $(HOSTCC) etc). Samples aren't as crucial as tools but I can look into it when I find a bit of time. Thanks, Jean