From 3381d5fdc034747f789f840757e44d1c4983a4af Mon Sep 17 00:00:00 2001 From: "Harper, Jason M" Date: Tue, 10 Dec 2024 07:56:49 -0800 Subject: [PATCH] put perf build in its own Dockerfile stage --- tools/Makefile | 9 +++++---- tools/build.Dockerfile | 44 +++++++++++++++++++++++++++--------------- 2 files changed, 33 insertions(+), 20 deletions(-) diff --git a/tools/Makefile b/tools/Makefile index 8b878b1..3f96e59 100644 --- a/tools/Makefile +++ b/tools/Makefile @@ -7,7 +7,7 @@ default: tools .PHONY: default tools async-profiler avx-turbo cpuid dmidecode ethtool flamegraph ipmitool lshw lspci msr-tools pcm perf spectre-meltdown-checker sshpass stress-ng sysstat tsc turbostat -tools: async-profiler avx-turbo cpuid dmidecode ethtool flamegraph ipmitool lshw lspci msr-tools pcm perf spectre-meltdown-checker sshpass stress-ng sysstat tsc turbostat +tools: async-profiler avx-turbo cpuid dmidecode ethtool flamegraph ipmitool lshw lspci msr-tools pcm spectre-meltdown-checker sshpass stress-ng sysstat tsc turbostat mkdir -p bin cp -R async-profiler bin/ cp avx-turbo/avx-turbo bin/ @@ -23,7 +23,6 @@ tools: async-profiler avx-turbo cpuid dmidecode ethtool flamegraph ipmitool lshw cp msr-tools/wrmsr bin/ cp pcm/build/bin/pcm-tpmi bin/ cp pcm/scripts/bhs-power-mode.sh bin/ - cp linux_perf/tools/perf/perf bin/ cp spectre-meltdown-checker/spectre-meltdown-checker.sh bin/ cp sshpass/sshpass bin/ cp stress-ng/stress-ng bin/ @@ -147,6 +146,9 @@ perf: wget https://cdn.kernel.org/pub/linux/kernel/v6.x/linux-$(PERF_LINUX_VERSION).tar.xz tar -xf linux-$(PERF_LINUX_VERSION).tar.xz && mv linux-$(PERF_LINUX_VERSION)/ linux_perf/ cd linux_perf/tools/perf && make LDFLAGS="-static --static" BUILD_BPF_SKEL=1 NO_JVMTI=1 + mkdir -p bin + cp linux_perf/tools/perf/perf bin/ + strip --strip-unneeded bin/perf spectre-meltdown-checker: ifeq ("$(wildcard spectre-meltdown-checker)","") @@ -208,7 +210,6 @@ reset: cd lspci && git clean -fdx && git reset --hard cd pcm && git clean -fdx && git reset --hard cd msr-tools && git clean -fdx && git reset --hard - cd linux_perf/tools/perf && make clean cd spectre-meltdown-checker cd sshpass && make clean cd stress-ng && git clean -fdx && git reset --hard @@ -226,5 +227,5 @@ libcrypt.tar.gz: libs: glibc-2.19.tar.bz2 zlib.tar.gz libcrypt.tar.gz oss-source: reset libs - tar --exclude-vcs -czf oss_source.tgz async-profiler/ cpuid/ dmidecode/ ethtool/ flamegraph/ ipmitool/ lshw/ lspci/ msr-tools/ pcm/ linux_perf/tools/perf spectre-meltdown-checker/ sshpass/ stress-ng/ sysstat/ linux_turbostat/tools/power/x86/turbostat glibc-2.19.tar.bz2 zlib.tar.gz libcrypt.tar.gz + tar --exclude-vcs -czf oss_source.tgz async-profiler/ cpuid/ dmidecode/ ethtool/ flamegraph/ ipmitool/ lshw/ lspci/ msr-tools/ pcm/ spectre-meltdown-checker/ sshpass/ stress-ng/ sysstat/ linux_turbostat/tools/power/x86/turbostat glibc-2.19.tar.bz2 zlib.tar.gz libcrypt.tar.gz md5sum oss_source.tgz > oss_source.tgz.md5 diff --git a/tools/build.Dockerfile b/tools/build.Dockerfile index 2e34c8c..dd1e975 100644 --- a/tools/build.Dockerfile +++ b/tools/build.Dockerfile @@ -6,7 +6,8 @@ # build output oss_source* will be in workdir # build image (from project root directory): # $ docker build -f tools/build.Dockerfile --tag perfspect-tools:$TAG ./tools -FROM ubuntu:22.04 AS builder + +FROM ubuntu:18.04 AS builder ENV http_proxy=${http_proxy} ENV https_proxy=${https_proxy} ENV LANG=en_US.UTF-8 @@ -14,34 +15,45 @@ ARG DEBIAN_FRONTEND=noninteractive RUN apt-get update && apt-get install -y apt-utils locales wget curl git netcat-openbsd software-properties-common jq zip unzip RUN locale-gen en_US.UTF-8 && echo "LANG=en_US.UTF-8" > /etc/default/locale RUN add-apt-repository ppa:git-core/ppa -y -RUN apt-get update && apt-get install -y \ - automake autotools-dev binutils-dev bison build-essential clang cmake debuginfod \ - default-jdk default-jre docbook-utils flex gawk git libaio-dev libaio1 \ - libbabeltrace-dev libbpf-dev libc6 libcap-dev libdw-dev libdwarf-dev libelf-dev \ - libiberty-dev liblzma-dev libnuma-dev libperl-dev libpfm4-dev libreadline-dev \ - libslang2-dev libssl-dev libtool libtraceevent-dev libunwind-dev libzstd-dev \ - libzstd1 llvm-13 pandoc pkgconf python-setuptools python2-dev python3 python3-dev \ - python3-pip systemtap-sdt-dev zlib1g-dev - -RUN bash -c "$(wget -O - https://apt.llvm.org/llvm.sh)" -ENV PATH="${PATH}:/usr/lib/llvm-18/bin" - +RUN apt-get update && apt-get install -y git build-essential autotools-dev automake \ + gawk zlib1g-dev libtool libaio-dev libaio1 pandoc pkgconf libcap-dev docbook-utils \ + libreadline-dev default-jre default-jdk cmake flex bison libssl-dev ENV JAVA_HOME=/usr/lib/jvm/java-1.11.0-openjdk-amd64 - # need golang to build go tools RUN rm -rf /usr/local/go && wget -qO- https://go.dev/dl/go1.23.0.linux-amd64.tar.gz | tar -C /usr/local -xz ENV PATH="${PATH}:/usr/local/go/bin" - # need up-to-date zlib (used by stress-ng static build) to fix security vulnerabilities RUN git clone https://github.com/madler/zlib.git && cd zlib && ./configure && make install RUN cp /usr/local/lib/libz.a /usr/lib/x86_64-linux-gnu/libz.a - # Build third-party components RUN mkdir workdir ADD . /workdir WORKDIR /workdir RUN make tools && make oss-source +FROM ubuntu:22.04 AS perf-builder +ENV http_proxy=${http_proxy} +ENV https_proxy=${https_proxy} +ENV LANG=en_US.UTF-8 +ARG DEBIAN_FRONTEND=noninteractive +RUN apt-get update && apt-get install -y apt-utils locales wget curl git netcat-openbsd software-properties-common jq zip unzip +RUN locale-gen en_US.UTF-8 && echo "LANG=en_US.UTF-8" > /etc/default/locale +RUN add-apt-repository ppa:git-core/ppa -y +RUN apt-get update && apt-get install -y \ + automake autotools-dev binutils-dev bison build-essential clang cmake debuginfod \ + default-jdk default-jre docbook-utils flex gawk git libaio-dev libaio1 \ + libbabeltrace-dev libbpf-dev libc6 libcap-dev libdw-dev libdwarf-dev libelf-dev \ + libiberty-dev liblzma-dev libnuma-dev libperl-dev libpfm4-dev libreadline-dev \ + libslang2-dev libssl-dev libtool libtraceevent-dev libunwind-dev libzstd-dev \ + libzstd1 llvm-13 pandoc pkgconf python-setuptools python2-dev python3 python3-dev \ + python3-pip systemtap-sdt-dev zlib1g-dev +ENV PATH="${PATH}:/usr/lib/llvm-13/bin" +RUN mkdir workdir +ADD . /workdir +WORKDIR /workdir +RUN make perf + FROM scratch AS output COPY --from=builder workdir/bin /bin COPY --from=builder workdir/oss_source* / +COPY --from=perf-builder workdir/bin/ /bin