Skip to content

Commit dd1c546

Browse files
committed
Auto merge of #40045 - frewsxcv:rollup, r=frewsxcv
Rollup of 11 pull requests - Successful merges: #39859, #39886, #39892, #39903, #39914, #39918, #39988, #40010, #40027, #40030, #40035 - Failed merges:
2 parents bfe4597 + 8d9ef38 commit dd1c546

35 files changed

+424
-153
lines changed

src/bootstrap/bootstrap.py

+2
Original file line numberDiff line numberDiff line change
@@ -472,6 +472,8 @@ def build_triple(self):
472472
ostype += 'abi64'
473473
elif cputype in {'powerpc', 'ppc', 'ppc64'}:
474474
cputype = 'powerpc'
475+
elif cputype == 'sparcv9':
476+
pass
475477
elif cputype in {'amd64', 'x86_64', 'x86-64', 'x64'}:
476478
cputype = 'x86_64'
477479
else:

src/bootstrap/compile.rs

+21-13
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ use std::fs::{self, File};
2121
use std::path::{Path, PathBuf};
2222
use std::process::Command;
2323

24-
use build_helper::{output, mtime};
24+
use build_helper::{output, mtime, up_to_date};
2525
use filetime::FileTime;
2626

2727
use util::{exe, libdir, is_dylib, copy};
@@ -132,21 +132,29 @@ pub fn build_startup_objects(build: &Build, for_compiler: &Compiler, target: &st
132132

133133
let compiler = Compiler::new(0, &build.config.build);
134134
let compiler_path = build.compiler_path(&compiler);
135-
let into = build.sysroot_libdir(for_compiler, target);
136-
t!(fs::create_dir_all(&into));
137-
138-
for file in t!(fs::read_dir(build.src.join("src/rtstartup"))) {
139-
let file = t!(file);
140-
let mut cmd = Command::new(&compiler_path);
141-
build.run(cmd.env("RUSTC_BOOTSTRAP", "1")
142-
.arg("--target").arg(target)
143-
.arg("--emit=obj")
144-
.arg("--out-dir").arg(&into)
145-
.arg(file.path()));
135+
let src_dir = &build.src.join("src/rtstartup");
136+
let dst_dir = &build.native_dir(target).join("rtstartup");
137+
let sysroot_dir = &build.sysroot_libdir(for_compiler, target);
138+
t!(fs::create_dir_all(dst_dir));
139+
t!(fs::create_dir_all(sysroot_dir));
140+
141+
for file in &["rsbegin", "rsend"] {
142+
let src_file = &src_dir.join(file.to_string() + ".rs");
143+
let dst_file = &dst_dir.join(file.to_string() + ".o");
144+
if !up_to_date(src_file, dst_file) {
145+
let mut cmd = Command::new(&compiler_path);
146+
build.run(cmd.env("RUSTC_BOOTSTRAP", "1")
147+
.arg("--target").arg(target)
148+
.arg("--emit=obj")
149+
.arg("--out-dir").arg(dst_dir)
150+
.arg(src_file));
151+
}
152+
153+
copy(dst_file, &sysroot_dir.join(file.to_string() + ".o"));
146154
}
147155

148156
for obj in ["crt2.o", "dllcrt2.o"].iter() {
149-
copy(&compiler_file(build.cc(target), obj), &into.join(obj));
157+
copy(&compiler_file(build.cc(target), obj), &sysroot_dir.join(obj));
150158
}
151159
}
152160

src/ci/docker/cross/Dockerfile

+24-4
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@ FROM ubuntu:16.04
33
RUN apt-get update && apt-get install -y --no-install-recommends \
44
g++ \
55
make \
6+
ninja-build \
67
file \
78
curl \
89
ca-certificates \
9-
python2.7 \
10+
python2.7-dev \
1011
git \
11-
cmake \
1212
sudo \
1313
xz-utils \
1414
zlib1g-dev \
@@ -19,7 +19,15 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
1919
bzip2 \
2020
patch \
2121
libssl-dev \
22-
pkg-config
22+
pkg-config \
23+
swig \
24+
libedit-dev \
25+
libncurses5-dev
26+
27+
# CMake 3.8.0 is the first version with official support for Fuchsia,
28+
# which is needed to build the Fuchsia toolchain.
29+
RUN curl -L https://cmake.org/files/v3.8/cmake-3.8.0-rc1-Linux-x86_64.tar.gz | \
30+
tar xzf - -C /usr/local --strip-components=1
2331

2432
ENV SCCACHE_DIGEST=7237e38e029342fa27b7ac25412cb9d52554008b12389727320bd533fd7f05b6a96d55485f305caf95e5c8f5f97c3313e10012ccad3e752aba2518f3522ba783
2533
RUN curl -L https://api.pub.build.mozilla.org/tooltool/sha512/$SCCACHE_DIGEST | \
@@ -31,6 +39,10 @@ RUN curl -OL https://github.com/Yelp/dumb-init/releases/download/v1.2.0/dumb-ini
3139
ENTRYPOINT ["/usr/bin/dumb-init", "--"]
3240

3341
WORKDIR /tmp
42+
COPY shared.sh /tmp/
43+
44+
COPY build-fuchsia.sh /tmp/
45+
RUN ./build-fuchsia.sh
3446

3547
COPY build-rumprun.sh /tmp/
3648
RUN ./build-rumprun.sh
@@ -65,10 +77,18 @@ ENV TARGETS=$TARGETS,arm-unknown-linux-musleabi
6577
ENV TARGETS=$TARGETS,arm-unknown-linux-musleabihf
6678
ENV TARGETS=$TARGETS,armv7-unknown-linux-musleabihf
6779
ENV TARGETS=$TARGETS,sparc64-unknown-linux-gnu
80+
ENV TARGETS=$TARGETS,x86_64-unknown-fuchsia
81+
ENV TARGETS=$TARGETS,aarch64-unknown-fuchsia
6882

6983
ENV CC_mipsel_unknown_linux_musl=mipsel-openwrt-linux-gcc \
7084
CC_mips_unknown_linux_musl=mips-openwrt-linux-gcc \
71-
CC_sparc64_unknown_linux_gnu=sparc64-linux-gnu-gcc
85+
CC_sparc64_unknown_linux_gnu=sparc64-linux-gnu-gcc \
86+
AR_x86_64_unknown_fuchsia=x86_64-unknown-fuchsia-ar \
87+
CC_x86_64_unknown_fuchsia=x86_64-unknown-fuchsia-clang \
88+
CXX_x86_64_unknown_fuchsia=x86_64-unknown-fuchsia-clang++ \
89+
AR_aarch64_unknown_fuchsia=aarch64-unknown-fuchsia-ar \
90+
CC_aarch64_unknown_fuchsia=aarch64-unknown-fuchsia-clang \
91+
CXX_aarch64_unknown_fuchsia=aarch64-unknown-fuchsia-clang++
7292

7393
# Suppress some warnings in the openwrt toolchains we downloaded
7494
ENV STAGING_DIR=/tmp

src/ci/docker/cross/build-fuchsia.sh

+114
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
#!/bin/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+
source shared.sh
14+
15+
# Download sources
16+
SRCS=(
17+
"https://fuchsia.googlesource.com/magenta magenta 29f09e6"
18+
"https://fuchsia.googlesource.com/third_party/llvm llvm 0f6af23"
19+
"https://fuchsia.googlesource.com/third_party/clang llvm/tools/clang 71b73d0"
20+
"https://fuchsia.googlesource.com/third_party/lld llvm/tools/lld af25ab9"
21+
"https://fuchsia.googlesource.com/third_party/lldb llvm/tools/lldb 90fe975"
22+
"https://fuchsia.googlesource.com/third_party/compiler-rt llvm/runtimes/compiler-rt 2edda55"
23+
"https://fuchsia.googlesource.com/third_party/libcxx llvm/runtimes/libcxx b7fd0be"
24+
"https://fuchsia.googlesource.com/third_party/libcxxabi llvm/runtimes/libcxxabi 66c8647"
25+
"https://fuchsia.googlesource.com/third_party/libunwind llvm/runtimes/libunwind 43ce8ac"
26+
)
27+
28+
fetch() {
29+
mkdir -p $2
30+
pushd $2 > /dev/null
31+
curl -sL $1/+archive/$3.tar.gz | tar xzf -
32+
popd > /dev/null
33+
}
34+
35+
for i in "${SRCS[@]}"; do
36+
fetch $i
37+
done
38+
39+
# Build toolchain
40+
cd llvm
41+
mkdir build
42+
cd build
43+
hide_output cmake -GNinja \
44+
-DFUCHSIA_SYSROOT=${PWD}/../../magenta/third_party/ulib/musl \
45+
-C ../tools/clang/cmake/caches/Fuchsia.cmake \
46+
..
47+
hide_output ninja stage2-distribution
48+
hide_output ninja stage2-install-distribution
49+
cd ../..
50+
51+
# Build sysroot
52+
rm -rf llvm/runtimes/compiler-rt
53+
./magenta/scripts/download-toolchain
54+
55+
build_sysroot() {
56+
local arch="$1"
57+
58+
case "${arch}" in
59+
x86_64) tgt="magenta-pc-x86-64" ;;
60+
aarch64) tgt="magenta-qemu-arm64" ;;
61+
esac
62+
63+
hide_output make -C magenta -j$(getconf _NPROCESSORS_ONLN) $tgt
64+
dst=/usr/local/${arch}-unknown-fuchsia
65+
mkdir -p $dst
66+
cp -r magenta/build-${tgt}/sysroot/include $dst/
67+
cp -r magenta/build-${tgt}/sysroot/lib $dst/
68+
69+
cd llvm
70+
mkdir build-runtimes-${arch}
71+
cd build-runtimes-${arch}
72+
hide_output cmake -GNinja \
73+
-DCMAKE_C_COMPILER=clang \
74+
-DCMAKE_CXX_COMPILER=clang++ \
75+
-DCMAKE_AR=/usr/local/bin/llvm-ar \
76+
-DCMAKE_RANLIB=/usr/local/bin/llvm-ranlib \
77+
-DCMAKE_INSTALL_PREFIX= \
78+
-DLLVM_MAIN_SRC_DIR=${PWD}/.. \
79+
-DLLVM_BINARY_DIR=${PWD}/../build \
80+
-DLLVM_ENABLE_WERROR=OFF \
81+
-DCMAKE_BUILD_TYPE=Release \
82+
-DLLVM_INCLUDE_TESTS=ON \
83+
-DCMAKE_SYSTEM_NAME=Fuchsia \
84+
-DCMAKE_C_COMPILER_TARGET=${arch}-fuchsia \
85+
-DCMAKE_CXX_COMPILER_TARGET=${arch}-fuchsia \
86+
-DUNIX=1 \
87+
-DLIBCXX_HAS_MUSL_LIBC=ON \
88+
-DLIBCXXABI_USE_LLVM_UNWINDER=ON \
89+
-DCMAKE_SYSROOT=${dst} \
90+
-DCMAKE_C_COMPILER_FORCED=TRUE \
91+
-DCMAKE_CXX_COMPILER_FORCED=TRUE \
92+
-DLLVM_ENABLE_LIBCXX=ON \
93+
-DCMAKE_EXE_LINKER_FLAGS="-nodefaultlibs -lc" \
94+
-DCMAKE_SHARED_LINKER_FLAGS="$(clang --target=${arch}-fuchsia -print-libgcc-file-name)" \
95+
../runtimes
96+
hide_output env DESTDIR="${dst}" ninja install
97+
cd ../..
98+
}
99+
100+
build_sysroot "x86_64"
101+
build_sysroot "aarch64"
102+
103+
rm -rf magenta llvm
104+
105+
for arch in x86_64 aarch64; do
106+
for tool in clang clang++; do
107+
cat >/usr/local/bin/${arch}-unknown-fuchsia-${tool} <<EOF
108+
#!/bin/sh
109+
${tool} --target=${arch}-unknown-fuchsia --sysroot=/usr/local/${arch}-unknown-fuchsia "\$@"
110+
EOF
111+
chmod +x /usr/local/bin/${arch}-unknown-fuchsia-${tool}
112+
done
113+
ln -s /usr/local/bin/llvm-ar /usr/local/bin/${arch}-unknown-fuchsia-ar
114+
done

src/ci/docker/cross/shared.sh

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Copyright 2017 The Rust Project Developers. See the COPYRIGHT
2+
# file at the top-level directory of this distribution and at
3+
# http://rust-lang.org/COPYRIGHT.
4+
#
5+
# Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
# http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
# <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
# option. This file may not be copied, modified, or distributed
9+
# except according to those terms.
10+
11+
hide_output() {
12+
set +x
13+
on_err="
14+
echo ERROR: An error was encountered with the build.
15+
cat /tmp/build.log
16+
exit 1
17+
"
18+
trap "$on_err" ERR
19+
bash -c "while true; do sleep 30; echo \$(date) - building ...; done" &
20+
PING_LOOP_PID=$!
21+
"$@" &> /tmp/build.log
22+
trap - ERR
23+
kill $PING_LOOP_PID
24+
set -x
25+
}

src/libcollections/string.rs

+42
Original file line numberDiff line numberDiff line change
@@ -1629,6 +1629,43 @@ impl hash::Hash for String {
16291629
}
16301630
}
16311631

1632+
/// Implements the `+` operator for concatenating two strings.
1633+
///
1634+
/// This consumes the `String` on the left-hand side and re-uses its buffer (growing it if
1635+
/// necessary). This is done to avoid allocating a new `String` and copying the entire contents on
1636+
/// every operation, which would lead to `O(n^2)` running time when building an `n`-byte string by
1637+
/// repeated concatenation.
1638+
///
1639+
/// The string on the right-hand side is only borrowed; its contents are copied into the returned
1640+
/// `String`.
1641+
///
1642+
/// # Examples
1643+
///
1644+
/// Concatenating two `String`s takes the first by value and borrows the second:
1645+
///
1646+
/// ```
1647+
/// let a = String::from("hello");
1648+
/// let b = String::from(" world");
1649+
/// let c = a + &b;
1650+
/// // `a` is moved and can no longer be used here.
1651+
/// ```
1652+
///
1653+
/// If you want to keep using the first `String`, you can clone it and append to the clone instead:
1654+
///
1655+
/// ```
1656+
/// let a = String::from("hello");
1657+
/// let b = String::from(" world");
1658+
/// let c = a.clone() + &b;
1659+
/// // `a` is still valid here.
1660+
/// ```
1661+
///
1662+
/// Concatenating `&str` slices can be done by converting the first to a `String`:
1663+
///
1664+
/// ```
1665+
/// let a = "hello";
1666+
/// let b = " world";
1667+
/// let c = a.to_string() + b;
1668+
/// ```
16321669
#[stable(feature = "rust1", since = "1.0.0")]
16331670
impl<'a> Add<&'a str> for String {
16341671
type Output = String;
@@ -1640,6 +1677,11 @@ impl<'a> Add<&'a str> for String {
16401677
}
16411678
}
16421679

1680+
/// Implements the `+=` operator for appending to a `String`.
1681+
///
1682+
/// This has the same behavior as the [`push_str()`] method.
1683+
///
1684+
/// [`push_str()`]: struct.String.html#method.push_str
16431685
#[stable(feature = "stringaddassign", since = "1.12.0")]
16441686
impl<'a> AddAssign<&'a str> for String {
16451687
#[inline]

src/libcollections/vec.rs

+2
Original file line numberDiff line numberDiff line change
@@ -1776,6 +1776,7 @@ array_impls! {
17761776
30 31 32
17771777
}
17781778

1779+
/// Implements comparison of vectors, lexicographically.
17791780
#[stable(feature = "rust1", since = "1.0.0")]
17801781
impl<T: PartialOrd> PartialOrd for Vec<T> {
17811782
#[inline]
@@ -1787,6 +1788,7 @@ impl<T: PartialOrd> PartialOrd for Vec<T> {
17871788
#[stable(feature = "rust1", since = "1.0.0")]
17881789
impl<T: Eq> Eq for Vec<T> {}
17891790

1791+
/// Implements ordering of vectors, lexicographically.
17901792
#[stable(feature = "rust1", since = "1.0.0")]
17911793
impl<T: Ord> Ord for Vec<T> {
17921794
#[inline]

src/libcompiler_builtins/build.rs

+9-1
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,15 @@ fn main() {
9292
// compiler-rt's build system already
9393
cfg.flag("-fno-builtin");
9494
cfg.flag("-fvisibility=hidden");
95-
cfg.flag("-fomit-frame-pointer");
95+
// Accepted practice on Solaris is to never omit frame pointer so that
96+
// system observability tools work as expected. In addition, at least
97+
// on Solaris, -fomit-frame-pointer on sparcv9 appears to generate
98+
// references to data outside of the current stack frame. A search of
99+
// the gcc bug database provides a variety of issues surrounding
100+
// -fomit-frame-pointer on non-x86 platforms.
101+
if !target.contains("solaris") && !target.contains("sparc") {
102+
cfg.flag("-fomit-frame-pointer");
103+
}
96104
cfg.flag("-ffreestanding");
97105
cfg.define("VISIBILITY_HIDDEN", None);
98106
}

src/libcore/slice.rs

+2
Original file line numberDiff line numberDiff line change
@@ -2202,13 +2202,15 @@ impl<A, B> PartialEq<[B]> for [A] where A: PartialEq<B> {
22022202
#[stable(feature = "rust1", since = "1.0.0")]
22032203
impl<T: Eq> Eq for [T] {}
22042204

2205+
/// Implements comparison of vectors lexicographically.
22052206
#[stable(feature = "rust1", since = "1.0.0")]
22062207
impl<T: Ord> Ord for [T] {
22072208
fn cmp(&self, other: &[T]) -> Ordering {
22082209
SliceOrd::compare(self, other)
22092210
}
22102211
}
22112212

2213+
/// Implements comparison of vectors lexicographically.
22122214
#[stable(feature = "rust1", since = "1.0.0")]
22132215
impl<T: PartialOrd> PartialOrd for [T] {
22142216
fn partial_cmp(&self, other: &[T]) -> Option<Ordering> {

src/libcore/str/mod.rs

+14
Original file line numberDiff line numberDiff line change
@@ -1366,6 +1366,13 @@ mod traits {
13661366
use ops;
13671367
use str::eq_slice;
13681368

1369+
/// Implements ordering of strings.
1370+
///
1371+
/// Strings are ordered lexicographically by their byte values. This orders Unicode code
1372+
/// points based on their positions in the code charts. This is not necessarily the same as
1373+
/// "alphabetical" order, which varies by language and locale. Sorting strings according to
1374+
/// culturally-accepted standards requires locale-specific data that is outside the scope of
1375+
/// the `str` type.
13691376
#[stable(feature = "rust1", since = "1.0.0")]
13701377
impl Ord for str {
13711378
#[inline]
@@ -1387,6 +1394,13 @@ mod traits {
13871394
#[stable(feature = "rust1", since = "1.0.0")]
13881395
impl Eq for str {}
13891396

1397+
/// Implements comparison operations on strings.
1398+
///
1399+
/// Strings are compared lexicographically by their byte values. This compares Unicode code
1400+
/// points based on their positions in the code charts. This is not necessarily the same as
1401+
/// "alphabetical" order, which varies by language and locale. Comparing strings according to
1402+
/// culturally-accepted standards requires locale-specific data that is outside the scope of
1403+
/// the `str` type.
13901404
#[stable(feature = "rust1", since = "1.0.0")]
13911405
impl PartialOrd for str {
13921406
#[inline]

0 commit comments

Comments
 (0)