llvm.org GIT mirror llvm / 83aa9ad
Added Dockerfiles to build clang from sources. Reviewers: klimek, chandlerc, mehdi_amini Reviewed By: klimek, mehdi_amini Subscribers: mehdi_amini, jlebar, llvm-commits Differential Revision: https://reviews.llvm.org/D34197 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@306810 91177308-0d34-0410-b5e6-96231b3b80d8 Ilya Biryukov 2 years ago
11 changed file(s) with 654 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
0 =========================================
1 A guide to Dockerfiles for building LLVM
2 =========================================
3
4 Introduction
5 ============
6 You can find a number of sources to build docker images with LLVM components in
7 ``llvm/utils/docker``. They can be used by anyone who wants to build the docker
8 images for their own use, or as a starting point for someone who wants to write
9 their own Dockerfiles.
10
11 We currently provide Dockerfiles with ``debian8`` and ``nvidia-cuda`` base images.
12 We also provide an ``example`` image, which contains placeholders that one would need
13 to fill out in order to produce Dockerfiles for a new docker image.
14
15 Why?
16 ----
17 Docker images provide a way to produce binary distributions of
18 software inside a controlled environment. Having Dockerfiles to builds docker images
19 inside LLVM repo makes them much more discoverable than putting them into any other
20 place.
21
22 Docker basics
23 -------------
24 If you've never heard about Docker before, you might find this section helpful
25 to get a very basic explanation of it.
26 `Docker `_ is a popular solution for running programs in
27 an isolated and reproducible environment, especially to maintain releases for
28 software deployed to large distributed fleets.
29 It uses linux kernel namespaces and cgroups to provide a lightweight isolation
30 inside currently running linux kernel.
31 A single active instance of dockerized environment is called a *docker
32 container*.
33 A snapshot of a docker container filesystem is called a *docker image*.
34 One can start a container from a prebuilt docker image.
35
36 Docker images are built from a so-called *Dockerfile*, a source file written in
37 a specialized language that defines instructions to be used when build
38 the docker image (see `official
39 documentation `_ for more
40 details). A minimal Dockerfile typically contains a base image and a number
41 of RUN commands that have to be executed to build the image. When building a new
42 image, docker will first download your base image, mount its filesystem as
43 read-only and then add a writable overlay on top of it to keep track of all
44 filesystem modifications, performed while building your image. When the build
45 process is finished, a diff between your image's final filesystem state and the
46 base image's filesystem is stored in the resulting image.
47
48 Overview
49 ========
50 The ``llvm/utils/docker`` folder contains Dockerfiles and simple bash scripts to
51 serve as a basis for anyone who wants to create their own Docker image with
52 LLVM components, compiled from sources. The sources are checked out from the
53 upstream svn repository when building the image.
54
55 Inside each subfolder we host Dockerfiles for two images:
56
57 - ``build/`` image is used to compile LLVM, it installs a system compiler and all
58 build dependencies of LLVM. After the build process is finished, the build
59 image will have an archive with compiled components at ``/tmp/clang.tar.gz``.
60 - ``release/`` image usually only contains LLVM components, compiled by the
61 ``build/`` image, and also libstdc++ and binutils to make image minimally
62 useful for C++ development. The assumption is that you usually want clang to
63 be one of the provided components.
64
65 To build both of those images, use ``build_docker_image.sh`` script.
66 It will checkout LLVM sources and build clang in the ``build`` container, copy results
67 of the build to the local filesystem and then build the ``release`` container using
68 those. The ``build_docker_image.sh`` accepts a list of LLVM repositories to
69 checkout, and arguments for CMake invocation.
70
71 If you want to write your own docker image, start with an ``example/`` subfolder.
72 It provides incomplete Dockerfiles with (very few) FIXMEs explaining the steps
73 you need to take in order to make your Dockerfiles functional.
74
75 Usage
76 =====
77 The ``llvm/utils/build_docker_image.sh`` script provides a rather high degree of
78 control on how to run the build. It allows you to specify the projects to
79 checkout from svn and provide a list of CMake arguments to use during when
80 building LLVM inside docker container.
81
82 Here's a very simple example of getting a docker image with clang binary,
83 compiled by the system compiler in the debian8 image:
84
85 .. code-block:: bash
86
87 ./llvm/utils/docker/build_docker_image.sh \
88 --source debian8 \
89 --docker-repository clang-debian8 --docker-tag "staging" \
90 -- \
91 -p clang -i install-clang -i install-clang-headers \
92 -- \
93 -DCMAKE_BUILD_TYPE=Release
94
95 Note there are two levels of ``--`` indirection. First one separates
96 ``build_docker_image.sh`` arguments from ``llvm/utils/build_install_llvm.sh``
97 arguments. Second one separates CMake arguments from ``build_install_llvm.sh``
98 arguments. Note that build like that doesn't use a 2-stage build process that
99 you probably want for clang. Running a 2-stage build is a little more intricate,
100 this command will do that:
101
102 .. code-block:: bash
103
104 # Run a 2-stage build.
105 # LLVM_TARGETS_TO_BUILD=Native is to reduce stage1 compile time.
106 # Options, starting with BOOTSTRAP_* are passed to stage2 cmake invocation.
107 ./build_docker_image.sh \
108 --source debian8 \
109 --docker-repository clang-debian8 --docker-tag "staging" \
110 -- \
111 -p clang -i stage2-install-clang -i stage2-install-clang-headers \
112 -- \
113 -DLLVM_TARGETS_TO_BUILD=Native -DCMAKE_BUILD_TYPE=Release \
114 -DBOOTSTRAP_CMAKE_BUILD_TYPE=Release \
115 -DCLANG_ENABLE_BOOTSTRAP=ON -DCLANG_BOOTSTRAP_TARGETS="install-clang;install-clang-headers"
116
117 This will produce two images, a release image ``clang-debian8:staging`` and a
118 build image ``clang-debian8-build:staging`` from the latest upstream revision.
119 After the image is built you can run bash inside a container based on your
120 image like this:
121
122 .. code-block:: bash
123
124 docker run -ti clang-debian8:staging bash
125
126 Now you can run bash commands as you normally would:
127
128 .. code-block:: bash
129
130 root@80f351b51825:/# clang -v
131 clang version 5.0.0 (trunk 305064)
132 Target: x86_64-unknown-linux-gnu
133 Thread model: posix
134 InstalledDir: /bin
135 Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.8
136 Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.8.4
137 Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.9
138 Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.9.2
139 Selected GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.9
140 Candidate multilib: .;@m64
141 Selected multilib: .;@m64
142
143
144 Which image should I choose?
145 ============================
146 We currently provide two images: debian8-based and nvidia-cuda-based. They
147 differ in the base image that they use, i.e. they have a different set of
148 preinstalled binaries. Debian8 is very minimal, nvidia-cuda is larger, but has
149 preinstalled CUDA libraries and allows to access a GPU, installed on your
150 machine.
151
152 If you need a minimal linux distribution with only clang and libstdc++ included,
153 you should try debian8-based image.
154
155 If you want to use CUDA libraries and have access to a GPU on your machine,
156 you should choose nvidia-cuda-based image and use `nvidia-docker
157 `_ to run your docker containers. Note
158 that you don't need nvidia-docker to build the images, but you need it in order
159 to have an access to GPU from a docker container that is running the built
160 image.
161
162 If you have a different use-case, you could create your own image based on
163 ``example/`` folder.
164
165 Any docker image can be built and run using only the docker binary, i.e. you can
166 run debian8 build on Fedora or any other Linux distribution. You don't need to
167 install CMake, compilers or any other clang dependencies. It is all handled
168 during the build process inside Docker's isolated environment.
169
170 Stable build
171 ============
172 If you want a somewhat recent and somewhat stable build, use the
173 ``branches/google/stable`` branch, i.e. the following command will produce a
174 debian8-based image using the latest ``google/stable`` sources for you:
175
176 .. code-block:: bash
177
178 ./llvm/utils/docker/build_docker_image.sh \
179 -s debian8 --d clang-debian8 -t "staging" \
180 -- \
181 --branch branches/google/stable \
182 -p clang -i install-clang -i install-clang-headers \
183 -- \
184 -DCMAKE_BUILD_TYPE=Release
185
186
187 Minimizing docker image size
188 ============================
189 Due to Docker restrictions we use two images (i.e., build and release folders)
190 for the release image to be as small as possible. It's much easier to achieve
191 that using two images, because Docker would store a filesystem layer for each
192 command in the Dockerfile, i.e. if you install some packages in one command,
193 then remove those in a separate command, the size of the resulting image will
194 still be proportinal to the size of an image with installed packages.
195 Therefore, we strive to provide a very simple release image which only copies
196 compiled clang and does not do anything else.
197
198 Docker 1.13 added a ``--squash`` flag that allows to flatten the layers of the
199 image, i.e. remove the parts that were actually deleted. That is an easier way
200 to produce the smallest images possible by using just a single image. We do not
201 use it because as of today the flag is in experimental stage and not everyone
202 may have the latest docker version available. When the flag is out of
203 experimental stage, we should investigate replacing two images approach with
204 just a single image, built using ``--squash`` flag.
9090 CompileCudaWithLLVM
9191 ReportingGuide
9292 Benchmarking
93 Docker
9394
9495 :doc:`GettingStarted`
9596 Discusses how to get up and running quickly with the LLVM infrastructure.
159160 :doc:`Frontend/PerformanceTips`
160161 A collection of tips for frontend authors on how to generate IR
161162 which LLVM is able to effectively optimize.
163
164 :doc:`Docker`
165 A reference for using Dockerfiles provided with LLVM.
162166
163167
164168 Programming Documentation
0 See llvm/docs/Docker.rst for details
0 #!/bin/bash
1 #===- llvm/utils/docker/build_docker_image.sh ----------------------------===//
2 #
3 # The LLVM Compiler Infrastructure
4 #
5 # This file is distributed under the University of Illinois Open Source
6 # License. See LICENSE.TXT for details.
7 #
8 #===----------------------------------------------------------------------===//
9 set -e
10
11 IMAGE_SOURCE=""
12 DOCKER_REPOSITORY=""
13 DOCKER_TAG=""
14 BUILDSCRIPT_ARGS=""
15
16 function show_usage() {
17 usage=$(cat << EOF
18 Usage: build_docker_image.sh [options] [-- [buildscript_args]...]
19
20 Available options:
21 -s|--source image source dir (i.e. debian8, nvidia-cuda, etc)
22 -d|--docker-repository docker repository for the image
23 -t|--docker-tag docker tag for the image
24 Required options: --source and --docker-repository.
25
26 All options after '--' are passed to buildscript (see
27 scripts/build_install_llvm.sh).
28
29 For example, running:
30 $ build_docker_image.sh -s debian8 -d mydocker/debian8-clang -t latest \
31 -- -p clang -i install-clang -i install-clang-headers
32 will produce two docker images:
33 mydocker/debian8-clang-build:latest - an intermediate image used to compile
34 clang.
35 mydocker/clang-debian8:latest - a small image with preinstalled clang.
36 Please note that this example produces a not very useful installation, since it
37 doesn't override CMake defaults, which produces a Debug and non-boostrapped
38 version of clang.
39 For an example of a somewhat more useful build, see build_clang_image.sh.
40 EOF
41 )
42 echo "$usage"
43 }
44
45 while [[ $# -gt 0 ]]; do
46 case "$1" in
47 -h|--help)
48 show_usage
49 exit 0
50 ;;
51 -s|--source)
52 shift
53 IMAGE_SOURCE="$1"
54 shift
55 ;;
56 -d|--docker-repository)
57 shift
58 DOCKER_REPOSITORY="$1"
59 shift
60 ;;
61 -t|--docker-tag)
62 shift
63 DOCKER_TAG="$1"
64 shift
65 ;;
66 --)
67 shift
68 BUILDSCRIPT_ARGS="$*"
69 shift $#
70 ;;
71 *)
72 echo "Unknown argument $1"
73 exit 1
74 ;;
75 esac
76 done
77
78 command -v docker >/dev/null ||
79 {
80 echo "Docker binary cannot be found. Please install Docker to use this script."
81 exit 1
82 }
83
84 if [ "$IMAGE_SOURCE" == "" ]; then
85 echo "Required argument missing: --source"
86 exit 1
87 fi
88
89 if [ "$DOCKER_REPOSITORY" == "" ]; then
90 echo "Required argument missing: --docker-repository"
91 exit 1
92 fi
93
94 cd $(dirname $0)
95 if [ ! -d $IMAGE_SOURCE ]; then
96 echo "No sources for '$IMAGE_SOURCE' were found in $PWD"
97 exit 1
98 fi
99
100 echo "Building from $IMAGE_SOURCE"
101
102 if [ "$DOCKER_TAG" != "" ]; then
103 DOCKER_TAG=":$DOCKER_TAG"
104 fi
105
106 echo "Building $DOCKER_REPOSITORY-build$DOCKER_TAG"
107 docker build -t "$DOCKER_REPOSITORY-build$DOCKER_TAG" \
108 --build-arg "buildscript_args=$BUILDSCRIPT_ARGS" \
109 -f "$IMAGE_SOURCE/build/Dockerfile" .
110
111 echo "Copying clang installation to release image sources"
112 docker run -v "$PWD/$IMAGE_SOURCE:/workspace" "$DOCKER_REPOSITORY-build$DOCKER_TAG" \
113 cp /tmp/clang.tar.gz /workspace/release
114 trap "rm -f $PWD/$IMAGE_SOURCE/release/clang.tar.gz" EXIT
115
116 echo "Building release image"
117 docker build -t "${DOCKER_REPOSITORY}${DOCKER_TAG}" \
118 "$IMAGE_SOURCE/release"
119
120 echo "Done"
0 #===- llvm/utils/docker/debian8/build/Dockerfile -------------------------===//
1 #
2 # The LLVM Compiler Infrastructure
3 #
4 # This file is distributed under the University of Illinois Open Source
5 # License. See LICENSE.TXT for details.
6 #
7 #===----------------------------------------------------------------------===//
8 # Produces an image that compiles and archives clang, based on debian8.
9 FROM launcher.gcr.io/google/debian8:latest
10
11 LABEL maintainer "LLVM Developers"
12
13 # Install build dependencies of llvm.
14 # First, Update the apt's source list and include the sources of the packages.
15 RUN grep deb /etc/apt/sources.list | \
16 sed 's/^deb/deb-src /g' >> /etc/apt/sources.list
17
18 # Install compiler, python and subversion.
19 RUN apt-get update && \
20 apt-get install -y --no-install-recommends build-essential python2.7 wget \
21 subversion ninja-build && \
22 rm -rf /var/lib/apt/lists/*
23
24 # Install cmake version that can compile clang into /usr/local.
25 # (Version in debian8 repos is is too old)
26 RUN wget -O - "https://cmake.org/files/v3.7/cmake-3.7.2-Linux-x86_64.tar.gz" | \
27 tar xzf - -C /usr/local --strip-components=1
28
29 # Arguments passed to build_install_clang.sh.
30 ARG buildscript_args
31
32 # Run the build. Results of the build will be available as /tmp/clang.tar.gz.
33 ADD scripts/build_install_llvm.sh /tmp
34 RUN /tmp/build_install_llvm.sh ${buildscript_args}
0 #===- llvm/utils/docker/debian8/release/Dockerfile -----------------------===//
1 #
2 # The LLVM Compiler Infrastructure
3 #
4 # This file is distributed under the University of Illinois Open Source
5 # License. See LICENSE.TXT for details.
6 #
7 #===----------------------------------------------------------------------===//
8 # A release image, containing clang installation, produced by the 'build/' image
9 # and adding libstdc++ and binutils.
10 FROM launcher.gcr.io/google/debian8:latest
11
12 LABEL maintainer "LLVM Developers"
13
14 # Install packages for minimal usefull image.
15 RUN apt-get update && \
16 apt-get install -y --no-install-recommends libstdc++-4.9-dev binutils && \
17 rm -rf /var/lib/apt/lists/*
18
19 # Unpack clang installation into this image.
20 ADD clang.tar.gz /
0 #===- llvm/utils/docker/example/build/Dockerfile -------------------------===//
1 #
2 # The LLVM Compiler Infrastructure
3 #
4 # This file is distributed under the University of Illinois Open Source
5 # License. See LICENSE.TXT for details.
6 #
7 #===----------------------------------------------------------------------===//
8 # This is an example Dockerfile to build an image that compiles clang.
9 # Replace FIXMEs to prepare your own image.
10
11 # FIXME: Replace 'ubuntu' with your base image
12 FROM ubuntu
13
14 # FIXME: Change maintainer name
15 LABEL maintainer "Maintainer "
16
17 # FIXME: Install llvm/clang build dependencies. Including compiler to
18 # build stage1, cmake, subversion, ninja, etc.
19
20 # Arguments to pass to build_install_clang.sh.
21 ARG buildscript_args
22
23 # Run the build. Results of the build will be available as /tmp/clang.tar.gz.
24 ADD scripts/build_install_llvm.sh /tmp
25 RUN /tmp/build_install_llvm.sh ${buildscript_args}
0 #===- llvm/utils/docker/example/release/Dockerfile -----------------------===//
1 #
2 # The LLVM Compiler Infrastructure
3 #
4 # This file is distributed under the University of Illinois Open Source
5 # License. See LICENSE.TXT for details.
6 #
7 #===----------------------------------------------------------------------===//
8 # An image that unpacks a clang installation, compiled by the 'build/'
9 # container.
10 # Replace FIXMEs to prepare your own image.
11
12 # FIXME: Replace 'ubuntu' with your base image.
13 FROM ubuntu
14
15 # FIXME: Change maintainer name.
16 LABEL maintainer "Maintainer "
17
18 # FIXME: Install all packages you want to have in your release container.
19 # A minimal usefull installation must include libstdc++ and binutils.
20
21 # Unpack clang installation into this container.
22 # It is copied to this directory by build_docker_image.sh script.
23 ADD clang.tar.gz /
0 #===- llvm/utils/docker/nvidia-cuda/build/Dockerfile ---------------------===//
1 #
2 # The LLVM Compiler Infrastructure
3 #
4 # This file is distributed under the University of Illinois Open Source
5 # License. See LICENSE.TXT for details.
6 #
7 #===----------------------------------------------------------------------===//
8 # Produces an image that compiles and archives clang, based on nvidia/cuda
9 # image.
10 FROM nvidia/cuda:8.0-devel
11
12 LABEL maintainer "LLVM Developers"
13
14 # Arguments to pass to build_install_clang.sh.
15 ARG buildscript_args
16
17 # Install llvm build dependencies.
18 RUN apt-get update && \
19 apt-get install -y --no-install-recommends cmake python2.7 subversion ninja-build && \
20 rm -rf /var/lib/apt/lists/*
21
22 # Run the build. Results of the build will be available as /tmp/clang.tar.gz.
23 ADD scripts/build_install_llvm.sh /tmp
24 RUN /tmp/build_install_llvm.sh ${buildscript_args}
0 #===- llvm/utils/docker/nvidia-cuda/release/Dockerfile -------------------===//
1 #
2 # The LLVM Compiler Infrastructure
3 #
4 # This file is distributed under the University of Illinois Open Source
5 # License. See LICENSE.TXT for details.
6 #
7 #===----------------------------------------------------------------------===//
8 # This is an example Dockerfile that copies a clang installation, compiled
9 # by the 'build/' container into a fresh docker image to get a container of
10 # minimal size.
11 # Replace FIXMEs to prepare a new Dockerfile.
12
13 # FIXME: Replace 'ubuntu' with your base image.
14 FROM nvidia/cuda:8.0-devel
15
16 # FIXME: Change maintainer name.
17 LABEL maintainer "LLVM Developers"
18
19 # Unpack clang installation into this container.
20 ADD clang.tar.gz /
21
22 # C++ standard library and binutils are already included in the base package.
0 #!/usr/bin/env bash
1 #===- llvm/utils/docker/scripts/build_install_llvm.sh ---------------------===//
2 #
3 # The LLVM Compiler Infrastructure
4 #
5 # This file is distributed under the University of Illinois Open Source
6 # License. See LICENSE.TXT for details.
7 #
8 #===-----------------------------------------------------------------------===//
9
10 set -e
11
12 function show_usage() {
13 usage=$(cat << EOF
14 Usage: build_install_llvm.sh [options] -- [cmake-args]
15
16 Checkout svn sources and run cmake with the specified arguments. Used
17 inside docker container.
18 Passes additional -DCMAKE_INSTALL_PREFIX and archives the contents of
19 the directory to /tmp/clang.tar.gz.
20
21 Available options:
22 -h|--help show this help message
23 -b|--branch svn branch to checkout, i.e. 'trunk',
24 'branches/release_40'
25 (default: 'trunk')
26 -r|--revision svn revision to checkout
27 -p|--llvm-project name of an svn project to checkout. Will also add the
28 project to a list LLVM_ENABLE_PROJECTS, passed to CMake.
29 For clang, please use 'clang', not 'cfe'.
30 Project 'llvm' is always included and ignored, if
31 specified.
32 Can be specified multiple times.
33 -i|--install-target name of a cmake install target to build and include in
34 the resulting archive. Can be specified multiple times.
35 Required options: At least one --install-target.
36
37 All options after '--' are passed to CMake invocation.
38 EOF
39 )
40 echo "$usage"
41 }
42
43 LLVM_SVN_REV=""
44 LLVM_BRANCH=""
45 CMAKE_ARGS=""
46 CMAKE_INSTALL_TARGETS=""
47 # We always checkout llvm
48 LLVM_PROJECTS="llvm"
49 CMAKE_LLVM_ENABLE_PROJECTS=""
50
51 function contains_project() {
52 local TARGET_PROJ="$1"
53 local PROJ
54 for PROJ in $LLVM_PROJECTS; do
55 if [ "$PROJ" == "$TARGET_PROJ" ]; then
56 return 0
57 fi
58 done
59 return 1
60 }
61
62 while [[ $# -gt 0 ]]; do
63 case "$1" in
64 -r|--revision)
65 shift
66 LLVM_SVN_REV="$1"
67 ;;
68 -b|--branch)
69 shift
70 LLVM_BRANCH="$1"
71 shift
72 ;;
73 -p|--llvm-project)
74 shift
75 PROJ="$1"
76 if [ "$PROJ" == "cfe" ]; then
77 PROJ="clang"
78 fi
79 if ! contains_project "$PROJ" ; then
80 LLVM_PROJECTS="$LLVM_PROJECTS $PROJ"
81 CMAKE_LLVM_ENABLE_PROJECTS="$CMAKE_LLVM_ENABLED_PROJECTS;$PROJ"
82 else
83 echo "Project '$PROJ' is already enabled, ignoring extra occurences."
84 fi
85 shift
86 ;;
87 -i|--install-target)
88 shift
89 CMAKE_INSTALL_TARGETS="$CMAKE_INSTALL_TARGETS $1"
90 shift
91 ;;
92 --)
93 shift
94 CMAKE_ARGS="$*"
95 shift $#
96 ;;
97 -h|--help)
98 show_usage
99 exit 0
100 ;;
101 *)
102 echo "Unknown option: $1"
103 exit 1
104 esac
105 done
106
107 if [ "$CMAKE_INSTALL_TARGETS" == "" ]; then
108 echo "No install targets. Please pass one or more --install-target."
109 exit 1
110 fi
111
112 if [ "$LLVM_BRANCH" == "" ]; then
113 LLVM_BRANCH="trunk"
114 fi
115
116 if [ "$LLVM_SVN_REVISION" != "" ]; then
117 SVN_REV_ARG="-r$LLVM_SVN_REVISION"
118 else
119 SVN_REV_ARG=""
120 fi
121
122 CLANG_BUILD_DIR=/tmp/clang-build
123 CLANG_INSTALL_DIR=/tmp/clang-install
124
125 mkdir "$CLANG_BUILD_DIR"
126
127 # Get the sources from svn.
128 echo "Checking out sources from svn"
129 mkdir "$CLANG_BUILD_DIR/src"
130 for LLVM_PROJECT in $LLVM_PROJECTS; do
131 if [ "$LLVM_PROJECT" == "clang" ]; then
132 SVN_PROJECT="cfe"
133 else
134 SVN_PROJECT="$LLVM_PROJECT"
135 fi
136
137 echo "Checking out http://llvm.org/svn/llvm-project/$SVN_PROJECT to $CLANG_BUILD_DIR/src/$LLVM_PROJECT"
138 # FIXME: --trust-server-cert is required to workaround 'SSL issuer is not
139 # trusted' error. Using https seems preferable to http either way,
140 # albeit this is not secure.
141 svn co -q $SVN_REV_ARG --trust-server-cert \
142 "https://llvm.org/svn/llvm-project/$SVN_PROJECT/$LLVM_BRANCH" \
143 "$CLANG_BUILD_DIR/src/$LLVM_PROJECT"
144 done
145
146 pushd "$CLANG_BUILD_DIR"
147
148 # Run the build as specified in the build arguments.
149 echo "Running build"
150 mkdir "$CLANG_BUILD_DIR/build"
151 cmake -GNinja \
152 -DCMAKE_INSTALL_PREFIX="$CLANG_INSTALL_DIR" \
153 -DLLVM_ENABLE_PROJECTS="$CMAKE_LLVM_ENABLE_PROJECTS" \
154 $CMAKE_ARGS \
155 "$CLANG_BUILD_DIR/src/llvm"
156 ninja $CMAKE_INSTALL_TARGETS
157
158 popd
159
160 # Pack the installed clang into an archive.
161 echo "Archiving clang installation to /tmp/clang.tar.gz"
162 cd "$CLANG_INSTALL_DIR"
163 tar -czf /tmp/clang.tar.gz *
164
165 # Cleanup.
166 rm -rf "$CLANG_BUILD_DIR" "$CLANG_INSTALL_DIR"
167
168 echo "Done"