-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclang_stage3_train.Dockerfile
34 lines (26 loc) · 1.62 KB
/
clang_stage3_train.Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
ARG LLVM_VERSION
ARG PROJECT
FROM clang_stage2_pgo_lto:${PROJECT}_${LLVM_VERSION} AS stage3-bolt
ARG LINUX_KERNEL_VERSION=v6.6.10
ARG PROJECT
# Get prerequisites for perf
RUN apt-get update && apt-get install -y wget pkg-config \
git curl make bison flex elfutils libelf-dev libdw-dev libaudit-dev xz-utils \
systemtap-sdt-dev libunwind-dev libssl-dev libslang2-dev python3-dev libzstd-dev \
libzstd-dev libbabeltrace-ctf-dev libcap-dev python3-setuptools libpfm4-dev \
libperl-dev libtraceevent-dev libbfd-dev gcc g++ \
&& rm -rf /var/lib/apt/lists/*
# Build perf
RUN mkdir /perf && mkdir /src && cd /src && git clone --depth 1 --branch=$LINUX_KERNEL_VERSION git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable.git && \
cd linux-stable/tools/perf && make O=/perf/ && rm -rf /src
# Run a typical workload, eg. compiling clang itself again
COPY build_scripts/build_${PROJECT}.sh build_${PROJECT}.sh
RUN chmod +x build_${PROJECT}.sh && sysctl kernel.perf_event_paranoid=-1 && /perf/perf record -e cycles:u -j any,u -- ./build_${PROJECT}.sh
RUN export MAJOR=$(echo $LLVM_VERSION | cut -f1 -d.)
# Merge profiling data
RUN cd stage3 && ../stage1/install/bin/perf2bolt ../stage2-prof-use-lto/install/bin/clang-$MAJOR -p perf.data -o clang-$MAJOR.fdata -w clang-$MAJOR.yaml
# Rebuild clang pgo here; can be used as drop-in replacement for stage2-prof-use-lto
RUN cd stage3 && ../stage1/install/bin/llvm-bolt \
-o ../stage2-prof-use-lto/install/bin/clang-$MAJOR.bolt -b clang-$MAJOR.yaml \
-reorder-blocks=ext-tsp -reorder-functions=hfsort+ -split-functions \
-split-all-cold -dyno-stats -icf=1 -use-gnu-stack