about summary refs log tree commit diff
path: root/src/ci
diff options
context:
space:
mode:
authorAlex Crichton <alex@alexcrichton.com>2018-04-24 08:34:14 -0700
committerAlex Crichton <alex@alexcrichton.com>2018-05-09 14:45:34 -0700
commit7e5b9ac41e36b29d5208f4e5455aade07d4d107d (patch)
tree089e6f1ef7eac8c624658ed2328d2cfbdc6cb41b /src/ci
parentac287ed167f07619409928008e4a50eecac4a285 (diff)
downloadrust-7e5b9ac41e36b29d5208f4e5455aade07d4d107d.tar.gz
rust-7e5b9ac41e36b29d5208f4e5455aade07d4d107d.zip
ci: Compile LLVM with Clang 6.0.0
Currently on CI we predominately compile LLVM with the default system compiler
which means gcc on Linux, some version of Clang on OSX, MSVC on Windows, and
gcc on MinGW. This commit switches Linux, OSX, and Windows to all use Clang
6.0.0 to build LLVM (aka the C/C++ compiler as part of the bootstrap). This
looks to generate faster code according to #49879 which translates to a faster
rustc (as LLVM internally is faster)

The major changes here were to the containers that build Linux releases,
basically adding a new step that uses the previous gcc 4.8 compiler to compile
the next Clang 6.0.0 compiler. Otherwise the OSX and Windows scripts have been
updated to download precompiled versions of Clang 6 and configure the build to
use them.

Note that `cc` was updated here to fix using `clang-cl` with `cc-rs` on MSVC, as
well as an update to `sccache` on Windows which was needed to correctly work
with `clang-cl`. Finally the MinGW compiler is entirely left out here
intentionally as it's currently thought that Clang can't generate C++ code for
MinGW and we need to use gcc, but this should be verified eventually.
Diffstat (limited to 'src/ci')
-rw-r--r--src/ci/docker/dist-i686-linux/Dockerfile49
-rwxr-xr-xsrc/ci/docker/dist-i686-linux/build-binutils.sh26
-rwxr-xr-xsrc/ci/docker/dist-i686-linux/build-cmake.sh25
-rwxr-xr-xsrc/ci/docker/dist-i686-linux/build-curl.sh43
-rwxr-xr-xsrc/ci/docker/dist-i686-linux/build-gcc.sh50
-rwxr-xr-xsrc/ci/docker/dist-i686-linux/build-git.sh24
-rwxr-xr-xsrc/ci/docker/dist-i686-linux/build-headers.sh25
-rwxr-xr-xsrc/ci/docker/dist-i686-linux/build-openssl.sh28
-rwxr-xr-xsrc/ci/docker/dist-i686-linux/build-python.sh30
-rw-r--r--src/ci/docker/dist-i686-linux/shared.sh25
-rw-r--r--src/ci/docker/dist-x86_64-linux/Dockerfile25
-rwxr-xr-xsrc/ci/docker/dist-x86_64-linux/build-clang.sh64
-rwxr-xr-xsrc/ci/docker/dist-x86_64-linux/build-gcc.sh1
13 files changed, 114 insertions, 301 deletions
diff --git a/src/ci/docker/dist-i686-linux/Dockerfile b/src/ci/docker/dist-i686-linux/Dockerfile
index 0ec57ee0886..d591fb28f36 100644
--- a/src/ci/docker/dist-i686-linux/Dockerfile
+++ b/src/ci/docker/dist-i686-linux/Dockerfile
@@ -29,13 +29,13 @@ ENV PATH=/rustroot/bin:$PATH
 ENV LD_LIBRARY_PATH=/rustroot/lib64:/rustroot/lib
 ENV PKG_CONFIG_PATH=/rustroot/lib/pkgconfig
 WORKDIR /tmp
-COPY dist-i686-linux/shared.sh dist-i686-linux/build-binutils.sh /tmp/
+COPY dist-x86_64-linux/shared.sh /tmp/
 
 # We need a build of openssl which supports SNI to download artifacts from
 # static.rust-lang.org. This'll be used to link into libcurl below (and used
 # later as well), so build a copy of OpenSSL with dynamic libraries into our
 # generic root.
-COPY dist-i686-linux/build-openssl.sh /tmp/
+COPY dist-x86_64-linux/build-openssl.sh /tmp/
 RUN ./build-openssl.sh
 
 # The `curl` binary on CentOS doesn't support SNI which is needed for fetching
@@ -44,36 +44,43 @@ RUN ./build-openssl.sh
 #
 # Note that we also disable a bunch of optional features of curl that we don't
 # really need.
-COPY dist-i686-linux/build-curl.sh /tmp/
+COPY dist-x86_64-linux/build-curl.sh /tmp/
 RUN ./build-curl.sh
 
 # binutils < 2.22 has a bug where the 32-bit executables it generates
 # immediately segfault in Rust, so we need to install our own binutils.
 #
 # See https://github.com/rust-lang/rust/issues/20440 for more info
+COPY dist-x86_64-linux/build-binutils.sh /tmp/
 RUN ./build-binutils.sh
 
+# libssh2 (a dependency of Cargo) requires cmake 2.8.11 or higher but CentOS
+# only has 2.6.4, so build our own
+COPY dist-x86_64-linux/build-cmake.sh /tmp/
+RUN ./build-cmake.sh
+
 # Need a newer version of gcc than centos has to compile LLVM nowadays
-COPY dist-i686-linux/build-gcc.sh /tmp/
+COPY dist-x86_64-linux/build-gcc.sh /tmp/
 RUN ./build-gcc.sh
 
 # CentOS 5.5 has Python 2.4 by default, but LLVM needs 2.7+
-COPY dist-i686-linux/build-python.sh /tmp/
+COPY dist-x86_64-linux/build-python.sh /tmp/
 RUN ./build-python.sh
 
+# Now build LLVM+Clang 6, afterwards configuring further compilations to use the
+# clang/clang++ compilers.
+COPY dist-x86_64-linux/build-clang.sh /tmp/
+RUN ./build-clang.sh
+ENV CC=clang CXX=clang++
+
 # Apparently CentOS 5.5 desn't have `git` in yum, but we're gonna need it for
 # cloning, so download and build it here.
-COPY dist-i686-linux/build-git.sh /tmp/
+COPY dist-x86_64-linux/build-git.sh /tmp/
 RUN ./build-git.sh
 
-# libssh2 (a dependency of Cargo) requires cmake 2.8.11 or higher but CentOS
-# only has 2.6.4, so build our own
-COPY dist-i686-linux/build-cmake.sh /tmp/
-RUN ./build-cmake.sh
-
 # for sanitizers, we need kernel headers files newer than the ones CentOS ships
 # with so we install newer ones here
-COPY dist-i686-linux/build-headers.sh /tmp/
+COPY dist-x86_64-linux/build-headers.sh /tmp/
 RUN ./build-headers.sh
 
 COPY scripts/sccache.sh /scripts/
@@ -84,11 +91,21 @@ ENV HOSTS=i686-unknown-linux-gnu
 ENV RUST_CONFIGURE_ARGS \
       --enable-full-tools \
       --enable-sanitizers \
-      --enable-profiler
+      --enable-profiler \
+      --set target.i686-unknown-linux-gnu.linker=clang \
+      --build=i686-unknown-linux-gnu
 ENV SCRIPT python2.7 ../x.py dist --build $HOSTS --host $HOSTS --target $HOSTS
-
-# This is the only builder which will create source tarballs
-ENV DIST_SRC 1
+ENV CARGO_TARGET_I686_UNKNOWN_LINUX_GNU_LINKER=clang
+
+# This was added when we switched from gcc to clang. It's not clear why this is
+# needed unfortunately, but without this the stage1 bootstrap segfaults
+# somewhere inside of a build script. The build ends up just hanging instead of
+# actually killing the process that segfaulted, but if the process is run
+# manually in a debugger the segfault is immediately seen as well as the
+# misaligned stack access.
+#
+# Added in #50200 there's some more logs there
+ENV CFLAGS -mstackrealign
 
 # When we build cargo in this container, we don't want it to use the system
 # libcurl, instead it should compile its own.
diff --git a/src/ci/docker/dist-i686-linux/build-binutils.sh b/src/ci/docker/dist-i686-linux/build-binutils.sh
deleted file mode 100755
index f4bdbd80d0e..00000000000
--- a/src/ci/docker/dist-i686-linux/build-binutils.sh
+++ /dev/null
@@ -1,26 +0,0 @@
-#!/usr/bin/env bash
-# Copyright 2017 The Rust Project Developers. See the COPYRIGHT
-# file at the top-level directory of this distribution and at
-# http://rust-lang.org/COPYRIGHT.
-#
-# Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-# http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-# <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-# option. This file may not be copied, modified, or distributed
-# except according to those terms.
-
-set -ex
-
-source shared.sh
-
-curl https://ftp.gnu.org/gnu/binutils/binutils-2.25.1.tar.bz2 | tar xfj -
-
-mkdir binutils-build
-cd binutils-build
-hide_output ../binutils-2.25.1/configure --prefix=/rustroot
-hide_output make -j10
-hide_output make install
-
-cd ..
-rm -rf binutils-build
-rm -rf binutils-2.25.1
diff --git a/src/ci/docker/dist-i686-linux/build-cmake.sh b/src/ci/docker/dist-i686-linux/build-cmake.sh
deleted file mode 100755
index 9a3763d421a..00000000000
--- a/src/ci/docker/dist-i686-linux/build-cmake.sh
+++ /dev/null
@@ -1,25 +0,0 @@
-#!/usr/bin/env bash
-# Copyright 2017 The Rust Project Developers. See the COPYRIGHT
-# file at the top-level directory of this distribution and at
-# http://rust-lang.org/COPYRIGHT.
-#
-# Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-# http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-# <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-# option. This file may not be copied, modified, or distributed
-# except according to those terms.
-
-set -ex
-source shared.sh
-
-curl https://cmake.org/files/v3.6/cmake-3.6.3.tar.gz | tar xzf -
-
-mkdir cmake-build
-cd cmake-build
-hide_output ../cmake-3.6.3/configure --prefix=/rustroot
-hide_output make -j10
-hide_output make install
-
-cd ..
-rm -rf cmake-build
-rm -rf cmake-3.6.3
diff --git a/src/ci/docker/dist-i686-linux/build-curl.sh b/src/ci/docker/dist-i686-linux/build-curl.sh
deleted file mode 100755
index edf3175b81c..00000000000
--- a/src/ci/docker/dist-i686-linux/build-curl.sh
+++ /dev/null
@@ -1,43 +0,0 @@
-#!/usr/bin/env bash
-# Copyright 2017 The Rust Project Developers. See the COPYRIGHT
-# file at the top-level directory of this distribution and at
-# http://rust-lang.org/COPYRIGHT.
-#
-# Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-# http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-# <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-# option. This file may not be copied, modified, or distributed
-# except according to those terms.
-
-set -ex
-source shared.sh
-
-VERSION=7.51.0
-
-curl http://cool.haxx.se/download/curl-$VERSION.tar.bz2 | tar xjf -
-
-mkdir curl-build
-cd curl-build
-hide_output ../curl-$VERSION/configure \
-      --prefix=/rustroot \
-      --with-ssl=/rustroot \
-      --disable-sspi \
-      --disable-gopher \
-      --disable-smtp \
-      --disable-smb \
-      --disable-imap \
-      --disable-pop3 \
-      --disable-tftp \
-      --disable-telnet \
-      --disable-manual \
-      --disable-dict \
-      --disable-rtsp \
-      --disable-ldaps \
-      --disable-ldap
-hide_output make -j10
-hide_output make install
-
-cd ..
-rm -rf curl-build
-rm -rf curl-$VERSION
-yum erase -y curl
diff --git a/src/ci/docker/dist-i686-linux/build-gcc.sh b/src/ci/docker/dist-i686-linux/build-gcc.sh
deleted file mode 100755
index 08020e533ff..00000000000
--- a/src/ci/docker/dist-i686-linux/build-gcc.sh
+++ /dev/null
@@ -1,50 +0,0 @@
-#!/usr/bin/env bash
-# Copyright 2017 The Rust Project Developers. See the COPYRIGHT
-# file at the top-level directory of this distribution and at
-# http://rust-lang.org/COPYRIGHT.
-#
-# Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-# http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-# <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-# option. This file may not be copied, modified, or distributed
-# except according to those terms.
-
-set -ex
-
-source shared.sh
-
-GCC=4.8.5
-
-curl https://ftp.gnu.org/gnu/gcc/gcc-$GCC/gcc-$GCC.tar.bz2 | tar xjf -
-cd gcc-$GCC
-
-# FIXME(#49246): Remove the `sed` below.
-#
-# On 2018 March 21st, two Travis builders' cache for Docker are suddenly invalidated. Normally this
-# is fine, because we just need to rebuild the Docker image. However, it reveals a network issue:
-# downloading from `ftp://gcc.gnu.org/` from Travis (using passive mode) often leads to "Connection
-# timed out" error, and even when the download completed, the file is usually corrupted. This causes
-# nothing to be landed that day.
-#
-# We observed that the `gcc-4.8.5.tar.bz2` above can be downloaded successfully, so as a stability
-# improvement we try to download from the HTTPS mirror instead. Turns out this uncovered the third
-# bug: the host `gcc.gnu.org` and `cygwin.com` share the same IP, and the TLS certificate of the
-# latter host is presented to `wget`! Therefore, we choose to download from the insecure HTTP server
-# instead here.
-#
-sed -i'' 's|ftp://gcc\.gnu\.org/|http://gcc.gnu.org/|g' ./contrib/download_prerequisites
-
-./contrib/download_prerequisites
-mkdir ../gcc-build
-cd ../gcc-build
-hide_output ../gcc-$GCC/configure \
-    --prefix=/rustroot \
-    --enable-languages=c,c++
-hide_output make -j10
-hide_output make install
-ln -nsf gcc /rustroot/bin/cc
-
-cd ..
-rm -rf gcc-build
-rm -rf gcc-$GCC
-yum erase -y gcc gcc-c++ binutils
diff --git a/src/ci/docker/dist-i686-linux/build-git.sh b/src/ci/docker/dist-i686-linux/build-git.sh
deleted file mode 100755
index aa31f50ba03..00000000000
--- a/src/ci/docker/dist-i686-linux/build-git.sh
+++ /dev/null
@@ -1,24 +0,0 @@
-#!/usr/bin/env bash
-# Copyright 2017 The Rust Project Developers. See the COPYRIGHT
-# file at the top-level directory of this distribution and at
-# http://rust-lang.org/COPYRIGHT.
-#
-# Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-# http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-# <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-# option. This file may not be copied, modified, or distributed
-# except according to those terms.
-
-set -ex
-source shared.sh
-
-curl -L https://www.kernel.org/pub/software/scm/git/git-2.10.0.tar.gz | tar xzf -
-
-cd git-2.10.0
-make configure
-hide_output ./configure --prefix=/rustroot
-hide_output make -j10
-hide_output make install
-
-cd ..
-rm -rf git-2.10.0
diff --git a/src/ci/docker/dist-i686-linux/build-headers.sh b/src/ci/docker/dist-i686-linux/build-headers.sh
deleted file mode 100755
index 2f15114d6f9..00000000000
--- a/src/ci/docker/dist-i686-linux/build-headers.sh
+++ /dev/null
@@ -1,25 +0,0 @@
-#!/usr/bin/env bash
-# Copyright 2017 The Rust Project Developers. See the COPYRIGHT
-# file at the top-level directory of this distribution and at
-# http://rust-lang.org/COPYRIGHT.
-#
-# Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-# http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-# <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-# option. This file may not be copied, modified, or distributed
-# except according to those terms.
-
-set -ex
-source shared.sh
-
-curl https://cdn.kernel.org/pub/linux/kernel/v3.x/linux-3.2.84.tar.xz | unxz | tar x
-
-cd linux-3.2.84
-hide_output make mrproper
-hide_output make INSTALL_HDR_PATH=dest headers_install
-
-find dest/include \( -name .install -o -name ..install.cmd \) -delete
-yes | cp -fr dest/include/* /usr/include
-
-cd ..
-rm -rf linux-3.2.84
diff --git a/src/ci/docker/dist-i686-linux/build-openssl.sh b/src/ci/docker/dist-i686-linux/build-openssl.sh
deleted file mode 100755
index e7226ace020..00000000000
--- a/src/ci/docker/dist-i686-linux/build-openssl.sh
+++ /dev/null
@@ -1,28 +0,0 @@
-#!/usr/bin/env bash
-# Copyright 2017 The Rust Project Developers. See the COPYRIGHT
-# file at the top-level directory of this distribution and at
-# http://rust-lang.org/COPYRIGHT.
-#
-# Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-# http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-# <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-# option. This file may not be copied, modified, or distributed
-# except according to those terms.
-
-set -ex
-source shared.sh
-
-VERSION=1.0.2k
-URL=https://s3-us-west-1.amazonaws.com/rust-lang-ci2/rust-ci-mirror/openssl-$VERSION.tar.gz
-
-curl $URL | tar xzf -
-
-cd openssl-$VERSION
-hide_output ./config --prefix=/rustroot shared -fPIC
-hide_output make -j10
-hide_output make install
-cd ..
-rm -rf openssl-$VERSION
-
-# Make the system cert collection available to the new install.
-ln -nsf /etc/pki/tls/cert.pem /rustroot/ssl/
diff --git a/src/ci/docker/dist-i686-linux/build-python.sh b/src/ci/docker/dist-i686-linux/build-python.sh
deleted file mode 100755
index c6b8cdde4b9..00000000000
--- a/src/ci/docker/dist-i686-linux/build-python.sh
+++ /dev/null
@@ -1,30 +0,0 @@
-#!/usr/bin/env bash
-# Copyright 2017 The Rust Project Developers. See the COPYRIGHT
-# file at the top-level directory of this distribution and at
-# http://rust-lang.org/COPYRIGHT.
-#
-# Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-# http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-# <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-# option. This file may not be copied, modified, or distributed
-# except according to those terms.
-
-set -ex
-source shared.sh
-
-curl https://www.python.org/ftp/python/2.7.12/Python-2.7.12.tgz | \
-  tar xzf -
-
-mkdir python-build
-cd python-build
-
-# Gotta do some hackery to tell python about our custom OpenSSL build, but other
-# than that fairly normal.
-CFLAGS='-I /rustroot/include' LDFLAGS='-L /rustroot/lib -L /rustroot/lib64' \
-    hide_output ../Python-2.7.12/configure --prefix=/rustroot
-hide_output make -j10
-hide_output make install
-
-cd ..
-rm -rf python-build
-rm -rf Python-2.7.12
diff --git a/src/ci/docker/dist-i686-linux/shared.sh b/src/ci/docker/dist-i686-linux/shared.sh
deleted file mode 100644
index 97e6d2908cf..00000000000
--- a/src/ci/docker/dist-i686-linux/shared.sh
+++ /dev/null
@@ -1,25 +0,0 @@
-# Copyright 2017 The Rust Project Developers. See the COPYRIGHT
-# file at the top-level directory of this distribution and at
-# http://rust-lang.org/COPYRIGHT.
-#
-# Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-# http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-# <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-# option. This file may not be copied, modified, or distributed
-# except according to those terms.
-
-hide_output() {
-  set +x
-  on_err="
-echo ERROR: An error was encountered with the build.
-cat /tmp/build.log
-exit 1
-"
-  trap "$on_err" ERR
-  bash -c "while true; do sleep 30; echo \$(date) - building ...; done" &
-  PING_LOOP_PID=$!
-  $@ &> /tmp/build.log
-  trap - ERR
-  kill $PING_LOOP_PID
-  set -x
-}
diff --git a/src/ci/docker/dist-x86_64-linux/Dockerfile b/src/ci/docker/dist-x86_64-linux/Dockerfile
index 28c97e8c6db..5726fab7524 100644
--- a/src/ci/docker/dist-x86_64-linux/Dockerfile
+++ b/src/ci/docker/dist-x86_64-linux/Dockerfile
@@ -29,7 +29,7 @@ ENV PATH=/rustroot/bin:$PATH
 ENV LD_LIBRARY_PATH=/rustroot/lib64:/rustroot/lib
 ENV PKG_CONFIG_PATH=/rustroot/lib/pkgconfig
 WORKDIR /tmp
-COPY dist-x86_64-linux/shared.sh dist-x86_64-linux/build-binutils.sh /tmp/
+COPY dist-x86_64-linux/shared.sh /tmp/
 
 # We need a build of openssl which supports SNI to download artifacts from
 # static.rust-lang.org. This'll be used to link into libcurl below (and used
@@ -51,9 +51,15 @@ RUN ./build-curl.sh
 # immediately segfault in Rust, so we need to install our own binutils.
 #
 # See https://github.com/rust-lang/rust/issues/20440 for more info
+COPY dist-x86_64-linux/build-binutils.sh /tmp/
 RUN ./build-binutils.sh
 
-# Need a newer version of gcc than centos has to compile LLVM nowadays
+# libssh2 (a dependency of Cargo) requires cmake 2.8.11 or higher but CentOS
+# only has 2.6.4, so build our own
+COPY dist-x86_64-linux/build-cmake.sh /tmp/
+RUN ./build-cmake.sh
+
+# Build a version of gcc capable of building LLVM 6
 COPY dist-x86_64-linux/build-gcc.sh /tmp/
 RUN ./build-gcc.sh
 
@@ -61,16 +67,17 @@ RUN ./build-gcc.sh
 COPY dist-x86_64-linux/build-python.sh /tmp/
 RUN ./build-python.sh
 
+# Now build LLVM+Clang 6, afterwards configuring further compilations to use the
+# clang/clang++ compilers.
+COPY dist-x86_64-linux/build-clang.sh /tmp/
+RUN ./build-clang.sh
+ENV CC=clang CXX=clang++
+
 # Apparently CentOS 5.5 desn't have `git` in yum, but we're gonna need it for
 # cloning, so download and build it here.
 COPY dist-x86_64-linux/build-git.sh /tmp/
 RUN ./build-git.sh
 
-# libssh2 (a dependency of Cargo) requires cmake 2.8.11 or higher but CentOS
-# only has 2.6.4, so build our own
-COPY dist-x86_64-linux/build-cmake.sh /tmp/
-RUN ./build-cmake.sh
-
 # for sanitizers, we need kernel headers files newer than the ones CentOS ships
 # with so we install newer ones here
 COPY dist-x86_64-linux/build-headers.sh /tmp/
@@ -85,8 +92,10 @@ ENV RUST_CONFIGURE_ARGS \
       --enable-full-tools \
       --enable-sanitizers \
       --enable-profiler \
-      --enable-compiler-docs
+      --enable-compiler-docs \
+      --set target.x86_64-unknown-linux-gnu.linker=clang
 ENV SCRIPT python2.7 ../x.py dist --host $HOSTS --target $HOSTS
+ENV CARGO_TARGET_X86_64_UNKNOWN_LINUX_GNU_LINKER=clang
 
 # This is the only builder which will create source tarballs
 ENV DIST_SRC 1
diff --git a/src/ci/docker/dist-x86_64-linux/build-clang.sh b/src/ci/docker/dist-x86_64-linux/build-clang.sh
new file mode 100755
index 00000000000..b0c27aa45bf
--- /dev/null
+++ b/src/ci/docker/dist-x86_64-linux/build-clang.sh
@@ -0,0 +1,64 @@
+#!/usr/bin/env bash
+# Copyright 2017 The Rust Project Developers. See the COPYRIGHT
+# file at the top-level directory of this distribution and at
+# http://rust-lang.org/COPYRIGHT.
+#
+# Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+# http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+# <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+# option. This file may not be copied, modified, or distributed
+# except according to those terms.
+
+set -ex
+
+source shared.sh
+
+LLVM=6.0.0
+
+mkdir clang
+cd clang
+
+curl https://releases.llvm.org/$LLVM/llvm-$LLVM.src.tar.xz | \
+  xz -d | \
+  tar xf -
+
+cd llvm-$LLVM.src
+
+mkdir -p tools/clang
+
+curl https://releases.llvm.org/$LLVM/cfe-$LLVM.src.tar.xz | \
+  xz -d | \
+  tar xf - -C tools/clang --strip-components=1
+
+mkdir ../clang-build
+cd ../clang-build
+
+# For whatever reason the default set of include paths for clang is different
+# than that of gcc. As a result we need to manually include our sysroot's
+# include path, /rustroot/include, to clang's default include path.
+#
+# Alsow there's this weird oddity with gcc where there's an 'include-fixed'
+# directory that it generates. It turns out [1] that Centos 5's headers are so
+# old that they're incompatible with modern C semantics. While gcc automatically
+# fixes that clang doesn't account for this. Tell clang to manually include the
+# fixed headers so we can successfully compile code later on.
+#
+# [1]: https://sourceware.org/ml/crossgcc/2008-11/msg00028.html
+INC="/rustroot/include"
+INC="$INC:/rustroot/lib/gcc/x86_64-unknown-linux-gnu/4.8.5/include-fixed"
+INC="$INC:/usr/include"
+
+hide_output \
+    cmake ../llvm-$LLVM.src \
+      -DCMAKE_C_COMPILER=/rustroot/bin/gcc \
+      -DCMAKE_CXX_COMPILER=/rustroot/bin/g++ \
+      -DCMAKE_BUILD_TYPE=Release \
+      -DCMAKE_INSTALL_PREFIX=/rustroot \
+      -DLLVM_TARGETS_TO_BUILD=X86 \
+      -DC_INCLUDE_DIRS="$INC"
+
+hide_output make -j10
+hide_output make install
+
+cd ../..
+rm -rf clang
diff --git a/src/ci/docker/dist-x86_64-linux/build-gcc.sh b/src/ci/docker/dist-x86_64-linux/build-gcc.sh
index 08020e533ff..62ea2506f4e 100755
--- a/src/ci/docker/dist-x86_64-linux/build-gcc.sh
+++ b/src/ci/docker/dist-x86_64-linux/build-gcc.sh
@@ -42,7 +42,6 @@ hide_output ../gcc-$GCC/configure \
     --enable-languages=c,c++
 hide_output make -j10
 hide_output make install
-ln -nsf gcc /rustroot/bin/cc
 
 cd ..
 rm -rf gcc-build