Skip to content

Commit 0f9d9f1

Browse files
committed
Check out llvm sources using the new llvm git monorepo
This updates compiler-rt, libunwind, libcxxabi and libcxx to a newer version, matching the compiler. This will be the official, canonical repo in the future. For the non-dev Dockerfile build, this means that all the llvm based subprojects need to be built in one RUN to avoid storing the llvm checkout in the docker layers.
1 parent 51da9d1 commit 0f9d9f1

File tree

5 files changed

+34
-105
lines changed

5 files changed

+34
-105
lines changed

Dockerfile

Lines changed: 10 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ FROM ubuntu:16.04
22

33
RUN apt-get update -qq && apt-get install -qqy --no-install-recommends \
44
git wget bzip2 file unzip libtool pkg-config cmake build-essential \
5-
automake yasm gettext autopoint vim python git-svn ninja-build \
6-
subversion ca-certificates && \
5+
automake yasm gettext autopoint vim python ninja-build subversion \
6+
ca-certificates && \
77
apt-get clean -y && \
88
rm -rf /var/lib/apt/lists/*
99

@@ -15,35 +15,19 @@ WORKDIR /build
1515

1616
ENV TOOLCHAIN_PREFIX=/opt/llvm-mingw
1717

18-
# Build and strip the LLVM installation
19-
COPY build-llvm.sh strip-llvm.sh ./
20-
RUN ./build-llvm.sh $TOOLCHAIN_PREFIX && \
21-
./strip-llvm.sh $TOOLCHAIN_PREFIX && \
22-
rm -rf /build/*
23-
2418
ARG TOOLCHAIN_ARCHS="i686 x86_64 armv7 aarch64"
2519

26-
# Install the usual $TUPLE-clang binaries
20+
# Build everything that uses the llvm monorepo. We need to build the mingw runtime before the compiler-rt/libunwind/libcxxabi/libcxx runtimes.
21+
COPY build-llvm.sh strip-llvm.sh install-wrappers.sh build-mingw-w64.sh build-compiler-rt.sh build-mingw-w64-libraries.sh build-libcxx.sh ./
2722
COPY wrappers/*.sh wrappers/*.c wrappers/*.h ./wrappers/
28-
COPY install-wrappers.sh ./
29-
RUN ./install-wrappers.sh $TOOLCHAIN_PREFIX && \
30-
rm -rf /build/*
31-
32-
# Build MinGW-w64, compiler-rt and mingw-w64's extra libraries
33-
COPY build-mingw-w64.sh build-compiler-rt.sh build-mingw-w64-libraries.sh ./
34-
RUN ./build-mingw-w64.sh $TOOLCHAIN_PREFIX && \
23+
RUN ./build-llvm.sh $TOOLCHAIN_PREFIX && \
24+
./strip-llvm.sh $TOOLCHAIN_PREFIX && \
25+
./install-wrappers.sh $TOOLCHAIN_PREFIX && \
26+
./build-mingw-w64.sh $TOOLCHAIN_PREFIX && \
3527
./build-compiler-rt.sh $TOOLCHAIN_PREFIX && \
3628
./build-mingw-w64-libraries.sh $TOOLCHAIN_PREFIX && \
37-
rm -rf /build/*
38-
39-
# Build libunwind/libcxxabi/libcxx
40-
COPY build-libcxx.sh ./
41-
RUN ./build-libcxx.sh $TOOLCHAIN_PREFIX && \
42-
rm -rf /build/*
43-
44-
# Build sanitizers
45-
COPY build-compiler-rt.sh ./
46-
RUN ./build-compiler-rt.sh $TOOLCHAIN_PREFIX --build-sanitizers && \
29+
./build-libcxx.sh $TOOLCHAIN_PREFIX && \
30+
./build-compiler-rt.sh $TOOLCHAIN_PREFIX --build-sanitizers && \
4731
rm -rf /build/*
4832

4933
# Build libssp

Dockerfile.dev

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ FROM ubuntu:16.04
22

33
RUN apt-get update -qq && apt-get install -qqy --no-install-recommends \
44
git wget bzip2 file unzip libtool pkg-config cmake build-essential \
5-
automake yasm gettext autopoint vim python git-svn ninja-build \
6-
subversion ca-certificates && \
5+
automake yasm gettext autopoint vim python ninja-build subversion \
6+
ca-certificates && \
77
apt-get clean -y && \
88
rm -rf /var/lib/apt/lists/*
99

build-compiler-rt.sh

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,8 @@ export PATH=$PREFIX/bin:$PATH
3131

3232
CLANG_VERSION=$(basename $(dirname $(dirname $(dirname $($PREFIX/bin/clang --print-libgcc-file-name -rtlib=compiler-rt)))))
3333

34-
if [ ! -d compiler-rt ]; then
35-
git clone -b master https://github.com/llvm-mirror/compiler-rt.git
36-
CHECKOUT=1
34+
if [ ! -d llvm-project/compiler-rt ] || [ -n "$SYNC" ]; then
35+
CHECKOUT_ONLY=1 ./build-llvm.sh
3736
fi
3837

3938
# Add a symlink for i386 -> i686; we normally name the toolchain
@@ -43,12 +42,7 @@ if [ ! -e $PREFIX/i386-w64-mingw32 ]; then
4342
ln -sfn i686-w64-mingw32 $PREFIX/i386-w64-mingw32 || true
4443
fi
4544

46-
cd compiler-rt
47-
48-
if [ -n "$SYNC" ] || [ -n "$CHECKOUT" ]; then
49-
[ -z "$SYNC" ] || git fetch
50-
git checkout 806498c6546a07c65bb5c808a7d8964216cc24ca
51-
fi
45+
cd llvm-project/compiler-rt
5246

5347
for arch in $ARCHS; do
5448
buildarchname=$arch

build-libcxx.sh

Lines changed: 4 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -34,37 +34,12 @@ export PATH=$PREFIX/bin:$PATH
3434
: ${CORES:=4}
3535
: ${ARCHS:=${TOOLCHAIN_ARCHS-i686 x86_64 armv7 aarch64}}
3636

37-
if [ ! -d libunwind ]; then
38-
git clone -b master https://github.com/llvm-mirror/libunwind.git
39-
CHECKOUT_LIBUNWIND=1
40-
fi
41-
if [ ! -d libcxxabi ]; then
42-
git clone -b master https://github.com/llvm-mirror/libcxxabi.git
43-
CHECKOUT_LIBCXXABI=1
44-
fi
45-
if [ ! -d libcxx ]; then
46-
git clone -b master https://github.com/llvm-mirror/libcxx.git
47-
CHECKOUT_LIBCXX=1
48-
fi
49-
if [ -n "$SYNC" ] || [ -n "$CHECKOUT_LIBUNWIND" ]; then
50-
cd libunwind
51-
[ -z "$SYNC" ] || git fetch
52-
git checkout df9c0cfd896524ae16dd7283cdf722f300c2b45d
53-
cd ..
54-
fi
55-
if [ -n "$SYNC" ] || [ -n "$CHECKOUT_LIBCXXABI" ]; then
56-
cd libcxxabi
57-
[ -z "$SYNC" ] || git fetch
58-
git checkout cac80b29da529d44ceb63930679e3a1af9cace37
59-
cd ..
60-
fi
61-
if [ -n "$SYNC" ] || [ -n "$CHECKOUT_LIBCXX" ]; then
62-
cd libcxx
63-
[ -z "$SYNC" ] || git fetch
64-
git checkout f16a595ec76a383f08380c81af3e21a3065364c1
65-
cd ..
37+
if [ ! -d llvm-project/libunwind ] || [ -n "$SYNC" ]; then
38+
CHECKOUT_ONLY=1 ./build-llvm.sh
6639
fi
6740

41+
cd llvm-project
42+
6843
LIBCXX=$(pwd)/libcxx
6944

7045
case $(uname) in

build-llvm.sh

Lines changed: 15 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -31,46 +31,21 @@ PREFIX="$(cd "$PREFIX" && pwd)"
3131
: ${CORES:=$(sysctl -n hw.ncpu 2>/dev/null)}
3232
: ${CORES:=4}
3333

34-
if [ ! -d llvm ]; then
34+
if [ ! -d llvm-project ]; then
3535
# When cloning master and checking out a pinned old hash, we can't use --depth=1.
36-
git clone -b master https://github.com/llvm-mirror/llvm.git
37-
cd llvm/tools
38-
git clone -b master https://github.com/llvm-mirror/clang.git
39-
git clone -b master https://github.com/llvm-mirror/lld.git
40-
cd ..
41-
set +e
42-
# Do the git-svn rebase to populate git-svn information, to make
43-
# "clang --version" produce SVN based version numbers.
44-
# This is optional - don't error out here if git-svn is unavailable.
45-
git svn init https://llvm.org/svn/llvm-project/llvm/trunk
46-
git config svn-remote.svn.fetch :refs/remotes/origin/master
47-
git svn rebase -l
48-
cd tools/clang
49-
git svn init https://llvm.org/svn/llvm-project/cfe/trunk
50-
git config svn-remote.svn.fetch :refs/remotes/origin/master
51-
git svn rebase -l
52-
cd ../lld
53-
git svn init https://llvm.org/svn/llvm-project/lld/trunk
54-
git config svn-remote.svn.fetch :refs/remotes/origin/master
55-
git svn rebase -l
56-
cd ../../..
57-
set -e
36+
git clone -b master https://github.com/llvm/llvm-project.git
5837
CHECKOUT=1
5938
fi
6039

6140
if [ -n "$SYNC" ] || [ -n "$CHECKOUT" ]; then
62-
cd llvm
63-
[ -z "$SYNC" ] || git fetch
64-
git checkout 66495492c0af53c4597cace26c50f0dce44033fc
65-
cd tools/clang
66-
[ -z "$SYNC" ] || git fetch
67-
git checkout 6fddf7789c74ae74d695dd571024915ad319db1b
68-
cd ../lld
41+
cd llvm-project
6942
[ -z "$SYNC" ] || git fetch
70-
git checkout 1e90cb9d20d4fcdb5d1448853370e969035d8014
71-
cd ../../..
43+
git checkout e698958ad8031e0f17202e06f5de53989852bb66
44+
cd ..
7245
fi
7346

47+
[ -z "$CHECKOUT_ONLY" ] || exit 0
48+
7449
if [ -n "$(which ninja)" ]; then
7550
CMAKE_GENERATOR="Ninja"
7651
NINJA=1
@@ -86,12 +61,12 @@ fi
8661

8762
if [ -n "$HOST" ]; then
8863
find_native_tools() {
89-
if [ -d llvm/build/bin ]; then
90-
echo $(pwd)/llvm/build/bin
91-
elif [ -d llvm/build-asserts/bin ]; then
92-
echo $(pwd)/llvm/build-asserts/bin
93-
elif [ -d llvm/build-noasserts/bin ]; then
94-
echo $(pwd)/llvm/build-noasserts/bin
64+
if [ -d llvm-project/llvm/build/bin ]; then
65+
echo $(pwd)/llvm-project/llvm/build/bin
66+
elif [ -d llvm-project/llvm/build-asserts/bin ]; then
67+
echo $(pwd)/llvm-project/llvm/build-asserts/bin
68+
elif [ -d llvm-project/llvm/build-noasserts/bin ]; then
69+
echo $(pwd)/llvm-project/llvm/build-noasserts/bin
9570
elif [ -n "$(which llvm-tblgen)" ]; then
9671
echo $(dirname $(which llvm-tblgen))
9772
fi
@@ -130,14 +105,15 @@ if [ -n "$FULL_LLVM" ]; then
130105
TOOLCHAIN_ONLY=OFF
131106
fi
132107

133-
cd llvm
108+
cd llvm-project/llvm
134109
mkdir -p $BUILDDIR
135110
cd $BUILDDIR
136111
cmake \
137112
${CMAKE_GENERATOR+-G} "$CMAKE_GENERATOR" \
138113
-DCMAKE_INSTALL_PREFIX="$PREFIX" \
139114
-DCMAKE_BUILD_TYPE=Release \
140115
-DLLVM_ENABLE_ASSERTIONS=$ASSERTS \
116+
-DLLVM_ENABLE_PROJECTS="clang;lld" \
141117
-DLLVM_TARGETS_TO_BUILD="ARM;AArch64;X86" \
142118
-DLLVM_INSTALL_TOOLCHAIN_ONLY=$TOOLCHAIN_ONLY \
143119
-DLLVM_TOOLCHAIN_TOOLS="llvm-ar;llvm-ranlib;llvm-objdump;llvm-rc;llvm-cvtres;llvm-nm;llvm-strings;llvm-readobj;llvm-dlltool;llvm-pdbutil;llvm-objcopy;llvm-strip;llvm-cov;llvm-profdata;llvm-addr2line" \

0 commit comments

Comments
 (0)