Skip to content

Commit fe703f1

Browse files
committed
linux-and-clang
1 parent 4640615 commit fe703f1

File tree

4 files changed

+85
-11
lines changed

4 files changed

+85
-11
lines changed

.travis.yml

+4-1
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,10 @@ install:
230230
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 &&
231231
chmod +x /usr/local/bin/sccache &&
232232
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 &&
233-
chmod +x /usr/local/bin/stamp
233+
chmod +x /usr/local/bin/stamp &&
234+
travis_retry curl -O http://releases.llvm.org/6.0.0/clang+llvm-6.0.0-x86_64-apple-darwin.tar.xz | tar xJf - &&
235+
export CC=`pwd`/clang+llvm-6.0.0-x86_64-apple-darwin/bin/clang &&
236+
export CXX=`pwd`/clang+llvm-6.0.0-x86_64-apple-darwin/bin/clang++
234237
;;
235238
esac
236239

src/ci/docker/dist-x86_64-linux/Dockerfile

+17-9
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ ENV PATH=/rustroot/bin:$PATH
2929
ENV LD_LIBRARY_PATH=/rustroot/lib64:/rustroot/lib
3030
ENV PKG_CONFIG_PATH=/rustroot/lib/pkgconfig
3131
WORKDIR /tmp
32-
COPY dist-x86_64-linux/shared.sh dist-x86_64-linux/build-binutils.sh /tmp/
32+
COPY dist-x86_64-linux/shared.sh /tmp/
3333

3434
# We need a build of openssl which supports SNI to download artifacts from
3535
# static.rust-lang.org. This'll be used to link into libcurl below (and used
@@ -51,26 +51,33 @@ RUN ./build-curl.sh
5151
# immediately segfault in Rust, so we need to install our own binutils.
5252
#
5353
# See https://github.com/rust-lang/rust/issues/20440 for more info
54+
COPY dist-x86_64-linux/build-binutils.sh /tmp/
5455
RUN ./build-binutils.sh
5556

56-
# Need a newer version of gcc than centos has to compile LLVM nowadays
57+
# libssh2 (a dependency of Cargo) requires cmake 2.8.11 or higher but CentOS
58+
# only has 2.6.4, so build our own
59+
COPY dist-x86_64-linux/build-cmake.sh /tmp/
60+
RUN ./build-cmake.sh
61+
62+
# Build a version of gcc capable of building LLVM 6
5763
COPY dist-x86_64-linux/build-gcc.sh /tmp/
5864
RUN ./build-gcc.sh
5965

6066
# CentOS 5.5 has Python 2.4 by default, but LLVM needs 2.7+
6167
COPY dist-x86_64-linux/build-python.sh /tmp/
6268
RUN ./build-python.sh
6369

70+
# Now build LLVM+Clang 6, afterwards configuring further compilations to use the
71+
# clang/clang++ compilers.
72+
COPY dist-x86_64-linux/build-clang.sh /tmp/
73+
RUN ./build-clang.sh
74+
ENV CC=clang CXX=clang++
75+
6476
# Apparently CentOS 5.5 desn't have `git` in yum, but we're gonna need it for
6577
# cloning, so download and build it here.
6678
COPY dist-x86_64-linux/build-git.sh /tmp/
6779
RUN ./build-git.sh
6880

69-
# libssh2 (a dependency of Cargo) requires cmake 2.8.11 or higher but CentOS
70-
# only has 2.6.4, so build our own
71-
COPY dist-x86_64-linux/build-cmake.sh /tmp/
72-
RUN ./build-cmake.sh
73-
7481
# for sanitizers, we need kernel headers files newer than the ones CentOS ships
7582
# with so we install newer ones here
7683
COPY dist-x86_64-linux/build-headers.sh /tmp/
@@ -85,8 +92,9 @@ ENV RUST_CONFIGURE_ARGS \
8592
--enable-full-tools \
8693
--enable-sanitizers \
8794
--enable-profiler \
88-
--enable-compiler-docs
89-
ENV SCRIPT python2.7 ../x.py dist --host $HOSTS --target $HOSTS
95+
--enable-compiler-docs \
96+
--set target.x86_64-unknown-linux-gnu.linker=clang
97+
ENV SCRIPT python2.7 ../x.py dist --host $HOSTS --target $HOSTS -v
9098

9199
# This is the only builder which will create source tarballs
92100
ENV DIST_SRC 1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
#!/usr/bin/env bash
2+
# Copyright 2017 The Rust Project Developers. See the COPYRIGHT
3+
# file at the top-level directory of this distribution and at
4+
# http://rust-lang.org/COPYRIGHT.
5+
#
6+
# Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
7+
# http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
8+
# <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
9+
# option. This file may not be copied, modified, or distributed
10+
# except according to those terms.
11+
12+
set -ex
13+
14+
source shared.sh
15+
16+
LLVM=6.0.0
17+
18+
mkdir clang
19+
cd clang
20+
21+
curl https://releases.llvm.org/$LLVM/llvm-$LLVM.src.tar.xz | \
22+
xz -d | \
23+
tar xf -
24+
25+
cd llvm-$LLVM.src
26+
27+
mkdir -p tools/clang
28+
29+
curl https://releases.llvm.org/$LLVM/cfe-$LLVM.src.tar.xz | \
30+
xz -d | \
31+
tar xf - -C tools/clang --strip-components=1
32+
33+
mkdir ../clang-build
34+
cd ../clang-build
35+
36+
# For whatever reason the default set of include paths for clang is different
37+
# than that of gcc. As a result we need to manually include our sysroot's
38+
# include path, /rustroot/include, to clang's default include path.
39+
#
40+
# Alsow there's this weird oddity with gcc where there's an 'include-fixed'
41+
# directory that it generates. It turns out [1] that Centos 5's headers are so
42+
# old that they're incompatible with modern C semantics. While gcc automatically
43+
# fixes that clang doesn't account for this. Tell clang to manually include the
44+
# fixed headers so we can successfully compile code later on.
45+
#
46+
# [1]: https://sourceware.org/ml/crossgcc/2008-11/msg00028.html
47+
INC="/rustroot/include"
48+
INC="$INC:/rustroot/lib/gcc/x86_64-unknown-linux-gnu/4.8.5/include-fixed"
49+
INC="$INC:/usr/include"
50+
51+
hide_output \
52+
cmake ../llvm-$LLVM.src \
53+
-DCMAKE_C_COMPILER=/rustroot/bin/gcc \
54+
-DCMAKE_CXX_COMPILER=/rustroot/bin/g++ \
55+
-DCMAKE_BUILD_TYPE=Release \
56+
-DCMAKE_INSTALL_PREFIX=/rustroot \
57+
-DLLVM_TARGETS_TO_BUILD=X86 \
58+
-DC_INCLUDE_DIRS="$INC"
59+
60+
hide_output make -j10
61+
hide_output make install
62+
63+
cd ../..
64+
rm -rf clang

src/ci/docker/dist-x86_64-linux/build-gcc.sh

-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ hide_output ../gcc-$GCC/configure \
4242
--enable-languages=c,c++
4343
hide_output make -j10
4444
hide_output make install
45-
ln -nsf gcc /rustroot/bin/cc
4645

4746
cd ..
4847
rm -rf gcc-build

0 commit comments

Comments
 (0)