From d041e7d2bf3e25e09bd5850a8de15b6dbd0ffdc5 Mon Sep 17 00:00:00 2001 From: Rolf Neugebauer Date: Wed, 6 Mar 2019 00:37:31 +0000 Subject: [PATCH] kernel: Factor our perf build from main kernel build The build of the perf utility has been quite bothersome, with different arches and kernel versions failing. Since we now have the ful kernel source in the package, factor out the actual build into Dockerfile.perf Signed-off-by: Rolf Neugebauer --- kernel/Dockerfile | 10 ---------- kernel/Dockerfile.perf | 41 +++++++++++++++++++++++++++++++++++++---- 2 files changed, 37 insertions(+), 14 deletions(-) diff --git a/kernel/Dockerfile b/kernel/Dockerfile index fdcec0302..a625e1eb7 100644 --- a/kernel/Dockerfile +++ b/kernel/Dockerfile @@ -172,16 +172,6 @@ RUN DVER=$(basename $(find /tmp/kernel-modules/lib/modules/ -mindepth 1 -maxdept RUN printf "KERNEL_SOURCE=${KERNEL_SOURCE}\n" > /out/kernel-source-info -# perf -# Only build perf for the latest LTS and the latest stable kernel. -# Skip arm64 for now as perf for 4.19.x fails to build. -RUN if [ "${KERNEL_SERIES}" != 4.9.x ] && [ $(uname -m) != aarch64 ]; then \ - mkdir -p /build/perf && \ - make -C tools/perf LDFLAGS=-static O=/build/perf && \ - strip /build/perf/perf && \ - cp /build/perf/perf /out; \ - fi - # Download Intel ucode and create a CPIO archive for it ENV UCODE_URL=https://downloadmirror.intel.com/28039/eng/microcode-20180807.tgz RUN set -e && \ diff --git a/kernel/Dockerfile.perf b/kernel/Dockerfile.perf index 5f08e7a97..ee20a3637 100644 --- a/kernel/Dockerfile.perf +++ b/kernel/Dockerfile.perf @@ -1,10 +1,43 @@ -# This Dockerfile extracts the perf utility from a kernel package and -# places it into a scratch image +# This Dockerfile extracts the source code and headers from a kernel package, +# builds the perf utility, and places it into a scratch image ARG IMAGE -FROM ${IMAGE} AS kernel +FROM ${IMAGE} AS ksrc + +FROM linuxkit/alpine:518c2ed0f398c5508969ac5e033607201fb419ed AS build +RUN apk add \ + argp-standalone \ + bash \ + bc \ + binutils-dev \ + bison \ + build-base \ + diffutils \ + flex \ + gmp-dev \ + installkernel \ + kmod \ + libelf-dev \ + mpc1-dev \ + mpfr-dev \ + sed \ + tar \ + xz \ + xz-dev \ + zlib-dev + +COPY --from=ksrc /linux.tar.xz /kernel-headers.tar / +RUN tar xf linux.tar.xz && \ + tar xf kernel-headers.tar + +WORKDIR /linux + +RUN mkdir -p /out && \ + make -C tools/perf LDFLAGS=-static && \ + strip tools/perf/perf && \ + cp tools/perf/perf /out FROM scratch ENTRYPOINT [] CMD [] WORKDIR / -COPY --from=kernel /perf /usr/bin/perf +COPY --from=build /out/perf /usr/bin/perf