From d3ff718bd1433f6cdc360c97693ee1379551f024 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Storsj=C3=B6?= Date: Wed, 28 Feb 2018 11:52:00 +0200 Subject: [PATCH] Remove unnecessary llvm files at the end This doesn't help reduce the docker image size since it's done in a separate RUN step than the one that added the files. (compiler-rt and libunwind currently fail to build after stripping the llvm installation though.) --- Dockerfile | 5 +++++ strip-llvm.sh | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 40 insertions(+) create mode 100755 strip-llvm.sh diff --git a/Dockerfile b/Dockerfile index eea5dbd..c161f09 100644 --- a/Dockerfile +++ b/Dockerfile @@ -63,3 +63,8 @@ RUN cd test && \ $arch-w64-mingw32-clang++ $test.cpp -o $test-$arch.exe || exit 1; \ done; \ done + +# Strip the final toolchain. (This doesn't reduce the total docker image +# size as long as it is in a separate RUN layer though.) +COPY strip-llvm.sh . +RUN ./strip-llvm.sh $TOOLCHAIN_PREFIX diff --git a/strip-llvm.sh b/strip-llvm.sh new file mode 100755 index 0000000..870f295 --- /dev/null +++ b/strip-llvm.sh @@ -0,0 +1,35 @@ +#!/bin/sh + +set -e + +if [ $# -lt 1 ]; then + echo $0 dir + exit 1 +fi +PREFIX="$1" +cd "$PREFIX" + +cd bin +for i in bugpoint c-index-test clang-* dsymutil git-clang-format llc lli llvm-* obj2yaml opt sancov sanstats scan-build scan-view verify-uselistorder yaml2obj; do + case $i in + *.sh) + ;; + clang++|clang-*.*|clang-cpp) + ;; + llvm-ar|llvm-cvtres|llvm-dlltool|llvm-nm|llvm-objdump|llvm-ranlib|llvm-rc|llvm-readobj|llvm-strings) + ;; + *) + if [ -f $i ]; then + rm $i + fi + ;; + esac +done +cd .. +rm -rf share libexec +cd include +rm -rf clang clang-c lld llvm llvm-c +cd .. +cd lib +rm -rf lib*.a *.so* *.dylib* cmake +cd ..