From fe703f13312ada506c1f6ce65752f413a8336442 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Tue, 24 Apr 2018 08:34:14 -0700 Subject: [PATCH] linux-and-clang --- .travis.yml | 5 +- src/ci/docker/dist-x86_64-linux/Dockerfile | 26 +++++--- .../docker/dist-x86_64-linux/build-clang.sh | 64 +++++++++++++++++++ src/ci/docker/dist-x86_64-linux/build-gcc.sh | 1 - 4 files changed, 85 insertions(+), 11 deletions(-) create mode 100755 src/ci/docker/dist-x86_64-linux/build-clang.sh diff --git a/.travis.yml b/.travis.yml index 63831cd59612..b9151e1fcbed 100644 --- a/.travis.yml +++ b/.travis.yml @@ -230,7 +230,10 @@ install: travis_retry curl -fo /usr/local/bin/sccache https://s3-us-west-1.amazonaws.com/rust-lang-ci2/rust-ci-mirror/2018-04-02-sccache-x86_64-apple-darwin && chmod +x /usr/local/bin/sccache && travis_retry curl -fo /usr/local/bin/stamp https://s3-us-west-1.amazonaws.com/rust-lang-ci2/rust-ci-mirror/2017-03-17-stamp-x86_64-apple-darwin && - chmod +x /usr/local/bin/stamp + chmod +x /usr/local/bin/stamp && + travis_retry curl -O http://releases.llvm.org/6.0.0/clang+llvm-6.0.0-x86_64-apple-darwin.tar.xz | tar xJf - && + export CC=`pwd`/clang+llvm-6.0.0-x86_64-apple-darwin/bin/clang && + export CXX=`pwd`/clang+llvm-6.0.0-x86_64-apple-darwin/bin/clang++ ;; esac diff --git a/src/ci/docker/dist-x86_64-linux/Dockerfile b/src/ci/docker/dist-x86_64-linux/Dockerfile index 28c97e8c6dbf..25f20b9a48bd 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,9 @@ ENV RUST_CONFIGURE_ARGS \ --enable-full-tools \ --enable-sanitizers \ --enable-profiler \ - --enable-compiler-docs -ENV SCRIPT python2.7 ../x.py dist --host $HOSTS --target $HOSTS + --enable-compiler-docs \ + --set target.x86_64-unknown-linux-gnu.linker=clang +ENV SCRIPT python2.7 ../x.py dist --host $HOSTS --target $HOSTS -v # 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 000000000000..b0c27aa45bf9 --- /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 or the MIT license +# , 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 08020e533ff1..62ea2506f4ef 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