Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rollup of 29 pull requests #40089

Closed
wants to merge 74 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
74 commits
Select commit Hold shift + click to select a range
cbafac5
Fix compilation on Redox
jackpot51 Feb 9, 2017
0e45a5e
[rustbuild] add a way to run command after failure
nagisa Feb 16, 2017
047a215
Set rustdoc --test files' path relative to the current directory
GuillaumeGomez Feb 15, 2017
2e756e2
add solaris sparcv9 support
binarycrusader Feb 17, 2017
038a166
Properly display note/expected details
estebank Feb 17, 2017
6091330
Follow rename of mx_handle_wait Magenta syscalls
raphlinus Feb 17, 2017
5205e2f
Normalize labeled and unlabeled breaks
cramertj Feb 15, 2017
4d65622
Properly implement labeled breaks in while conditions
cramertj Feb 16, 2017
56e519d
Add tests for control flow in while condition
cramertj Feb 17, 2017
a611bbc
Rename hir::Label to hir::Destination
cramertj Feb 18, 2017
9322a38
Use ARM instead of SystemZ for testing not installed targets
petrochenkov Feb 18, 2017
e606a43
Fix rustdoc test with new file path
GuillaumeGomez Feb 19, 2017
df28569
bootstrap: stop trashing (DY)LD_LIBRARY_PATH
ishitatsuyuki Feb 19, 2017
a84eb95
check_match: don't treat privately uninhabited types as uninhabited
arielb1 Feb 20, 2017
25b1488
Simplify adaptive hashmap
arthurprs Feb 20, 2017
0b06db5
incr-comp: track the -Z sanitizer flag
Feb 21, 2017
7af3406
Set metadata for vtable-related loads
Aatch Feb 21, 2017
18b0f88
travis: Fuchsia builder
petrhosek Feb 17, 2017
d80cf80
Update codegen test with new attributes
Aatch Feb 21, 2017
305aca8
travis: Compile a more compatible libc.a for musl
alexcrichton Feb 21, 2017
9a08f40
travis: Move -mrelax-relocations to Docker config
alexcrichton Feb 21, 2017
347e1af
std: Relax UnwindSafe impl for Unique
alexcrichton Feb 21, 2017
163698c
Switch Fuchsia to readdir (instead of readdir_r)
raphlinus Feb 21, 2017
9ce8bb9
Add save-analysis data to nightly manifests.
nrc Feb 22, 2017
802a826
Stabilize static_recursion
cramertj Feb 22, 2017
f557e71
Ignore ASM tests on powerpc
er-1 Feb 22, 2017
ffc6ddd
add `-C overflow-checks` option
froydnj Feb 17, 2017
b576abd
detect "bootstrap outputs" when serializing the dep-graph
nikomatsakis Feb 22, 2017
81b9b3c
Update name_bytes, scoop up latest libc
raphlinus Feb 22, 2017
b3ee249
Merge branch 'master' of https://github.com/rust-lang/rust into readdir
raphlinus Feb 22, 2017
b7b58ff
Added test for inclusive_range_syntax in compile-fail test suite
nikhilshagri Feb 22, 2017
958fbc5
Make path separator replacement for subfiles as well
GuillaumeGomez Feb 22, 2017
6f0447b
Change break or continue with no label to error nmbr 590
cramertj Feb 23, 2017
4ecdc68
Move MacroKind into Def::Macro
keeperofdakeys Feb 23, 2017
da6dc53
Add macro suggestions for macros imported with `use`
keeperofdakeys Feb 23, 2017
ae32b6e
Better handling of lib defaults
wagenet Feb 21, 2017
4e2c993
trans: don't ICE when trying to create ADT trans-items
arielb1 Feb 23, 2017
69c5359
Add tests for lib defaults
wagenet Feb 23, 2017
87e544b
use a more conservative inhabitableness rule
arielb1 Feb 23, 2017
1b9b322
Implement non-capturing closure to fn coercion
est31 Feb 22, 2017
f753a6e
Feature gate
est31 Feb 23, 2017
21c3898
Two more tests
est31 Feb 23, 2017
77f131d
Review changes
est31 Feb 23, 2017
1f75085
Add Gankro's table to nomicon/src/phantom-data.md
Rufflewind Feb 24, 2017
07a8026
Move COMPILER_TESTS.md out of the root directory
danobi Feb 25, 2017
49a9b93
Rollup merge of #39859 - GuillaumeGomez:rustdoc-test-relative-path, r…
eddyb Feb 25, 2017
2cf3aa7
Rollup merge of #39864 - cramertj:normalize-breaks, r=nikomatsakis
eddyb Feb 25, 2017
6547e3d
Rollup merge of #39888 - nagisa:on-fail-bootstrap, r=alexcrichton
eddyb Feb 25, 2017
967357a
Rollup merge of #39903 - binarycrusader:issue-39901, r=alexcrichton
eddyb Feb 25, 2017
bed1113
Rollup merge of #39905 - estebank:useless-error, r=arielb1
eddyb Feb 25, 2017
8978248
Rollup merge of #39914 - raphlinus:mx_handle_wait, r=alexcrichton
eddyb Feb 25, 2017
30987d6
Rollup merge of #39918 - petrhosek:fuchsia-ci, r=alexcrichton
eddyb Feb 25, 2017
e62199a
Rollup merge of #39945 - petrochenkov:llvmtarg, r=alexcrichton
eddyb Feb 25, 2017
9273c89
Rollup merge of #39950 - ishitatsuyuki:stop-trashing-ldpath, r=alexcr…
eddyb Feb 25, 2017
fb3836a
Rollup merge of #39953 - keeperofdakeys:macro-error, r=jseyfried
eddyb Feb 25, 2017
6a0f654
Rollup merge of #39961 - redox-os:redox, r=alexcrichton
eddyb Feb 25, 2017
6446af5
Rollup merge of #39980 - arielb1:privately-uninhabited, r=nikomatsakis
eddyb Feb 25, 2017
045970f
Rollup merge of #39988 - arthurprs:hm-adapt2, r=alexcrichton
eddyb Feb 25, 2017
5e89830
Rollup merge of #39993 - japaric:incr-san, r=alexcrichton
eddyb Feb 25, 2017
e71db58
Rollup merge of #39995 - Aatch:vtable-ptr-metadata, r=arielb1
eddyb Feb 25, 2017
974151a
Rollup merge of #40019 - alexcrichton:fix-musl, r=brson
eddyb Feb 25, 2017
422979f
Rollup merge of #40020 - alexcrichton:fix-unwind-safe, r=sfackler
eddyb Feb 25, 2017
cf9e560
Rollup merge of #40022 - wagenet:lib-defaults, r=alexcrichton
eddyb Feb 25, 2017
a9a4f5a
Rollup merge of #40024 - raphlinus:readdir, r=alexcrichton
eddyb Feb 25, 2017
a7a349a
Rollup merge of #40025 - est31:master, r=eddyb
eddyb Feb 25, 2017
b0b29ef
Rollup merge of #40026 - nrc:analysis-manifest, r=alexcrichton
eddyb Feb 25, 2017
6b07e88
Rollup merge of #40027 - cramertj:stabilize_static_recursion, r=nrc
eddyb Feb 25, 2017
e7a9acb
Rollup merge of #40031 - cynicaldevil:master, r=est31
eddyb Feb 25, 2017
2d93019
Rollup merge of #40035 - er-1:master, r=alexcrichton
eddyb Feb 25, 2017
e69d234
Rollup merge of #40037 - froydnj:overflow-checks, r=alexcrichton
eddyb Feb 25, 2017
6251e95
Rollup merge of #40038 - nikomatsakis:issue-39828, r=michaelwoerister
eddyb Feb 25, 2017
f658ce4
Rollup merge of #40064 - arielb1:virtual-enum, r=nikomatsakis
eddyb Feb 25, 2017
d5f2371
Rollup merge of #40069 - Rufflewind:master, r=steveklabnik
eddyb Feb 25, 2017
9e919ad
Rollup merge of #40086 - danobi:move-compiler_tests, r=brson
eddyb Feb 25, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 15 additions & 3 deletions src/bootstrap/bin/rustc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ fn main() {
};
let stage = env::var("RUSTC_STAGE").expect("RUSTC_STAGE was not set");
let sysroot = env::var_os("RUSTC_SYSROOT").expect("RUSTC_SYSROOT was not set");
let mut on_fail = env::var_os("RUSTC_ON_FAIL").map(|of| Command::new(of));

let rustc = env::var_os(rustc).unwrap_or_else(|| panic!("{:?} was not set", rustc));
let libdir = env::var_os(libdir).unwrap_or_else(|| panic!("{:?} was not set", libdir));
Expand Down Expand Up @@ -217,9 +218,20 @@ fn main() {
}

// Actually run the compiler!
std::process::exit(match exec_cmd(&mut cmd) {
Ok(s) => s.code().unwrap_or(0xfe),
Err(e) => panic!("\n\nfailed to run {:?}: {}\n\n", cmd, e),
std::process::exit(if let Some(ref mut on_fail) = on_fail {
match cmd.status() {
Ok(s) if s.success() => 0,
_ => {
println!("\nDid not run successfully:\n{:?}\n-------------", cmd);
exec_cmd(on_fail).expect("could not run the backup command");
1
}
}
} else {
std::process::exit(match exec_cmd(&mut cmd) {
Ok(s) => s.code().unwrap_or(0xfe),
Err(e) => panic!("\n\nfailed to run {:?}: {}\n\n", cmd, e),
})
})
}

Expand Down
10 changes: 8 additions & 2 deletions src/bootstrap/bootstrap.py
Original file line number Diff line number Diff line change
Expand Up @@ -355,8 +355,12 @@ def build_bootstrap(self):
env = os.environ.copy()
env["CARGO_TARGET_DIR"] = build_dir
env["RUSTC"] = self.rustc()
env["LD_LIBRARY_PATH"] = os.path.join(self.bin_root(), "lib")
env["DYLD_LIBRARY_PATH"] = os.path.join(self.bin_root(), "lib")
env["LD_LIBRARY_PATH"] = os.path.join(self.bin_root(), "lib") + \
(os.pathsep + env["LD_LIBRARY_PATH"]) \
if "LD_LIBRARY_PATH" in env else ""
env["DYLD_LIBRARY_PATH"] = os.path.join(self.bin_root(), "lib") + \
(os.pathsep + env["DYLD_LIBRARY_PATH"]) \
if "DYLD_LIBRARY_PATH" in env else ""
env["PATH"] = os.path.join(self.bin_root(), "bin") + \
os.pathsep + env["PATH"]
if not os.path.isfile(self.cargo()):
Expand Down Expand Up @@ -485,6 +489,8 @@ def build_triple(self):
ostype += 'abi64'
elif cputype in {'powerpc', 'ppc', 'ppc64'}:
cputype = 'powerpc'
elif cputype == 'sparcv9':
pass
elif cputype in {'amd64', 'x86_64', 'x86-64', 'x64'}:
cputype = 'x86_64'
else:
Expand Down
3 changes: 3 additions & 0 deletions src/bootstrap/flags.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ use step;
/// Deserialized version of all flags for this compile.
pub struct Flags {
pub verbose: usize, // verbosity level: 0 == not verbose, 1 == verbose, 2 == very verbose
pub on_fail: Option<String>,
pub stage: Option<u32>,
pub keep_stage: Option<u32>,
pub build: String,
Expand Down Expand Up @@ -81,6 +82,7 @@ impl Flags {
opts.optopt("", "build", "build target of the stage0 compiler", "BUILD");
opts.optmulti("", "host", "host targets to build", "HOST");
opts.optmulti("", "target", "target targets to build", "TARGET");
opts.optopt("", "on-fail", "command to run on failure", "CMD");
opts.optopt("", "stage", "stage to build", "N");
opts.optopt("", "keep-stage", "stage to keep without recompiling", "N");
opts.optopt("", "src", "path to the root of the rust checkout", "DIR");
Expand Down Expand Up @@ -283,6 +285,7 @@ To learn more about a subcommand, run `./x.py <command> -h`
Flags {
verbose: m.opt_count("v"),
stage: stage,
on_fail: m.opt_str("on-fail"),
keep_stage: m.opt_str("keep-stage").map(|j| j.parse().unwrap()),
build: m.opt_str("build").unwrap_or_else(|| {
env::var("BUILD").unwrap()
Expand Down
15 changes: 4 additions & 11 deletions src/bootstrap/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -499,6 +499,10 @@ impl Build {
cargo.env("RUSTC_INCREMENTAL", incr_dir);
}

if let Some(ref on_fail) = self.flags.on_fail {
cargo.env("RUSTC_ON_FAIL", on_fail);
}

let verbose = cmp::max(self.config.verbose, self.flags.verbose);
cargo.env("RUSTC_VERBOSE", format!("{}", verbose));

Expand Down Expand Up @@ -828,17 +832,6 @@ impl Build {
if target.contains("apple-darwin") {
base.push("-stdlib=libc++".into());
}
// This is a hack, because newer binutils broke things on some vms/distros
// (i.e., linking against unknown relocs disabled by the following flag)
// See: https://github.com/rust-lang/rust/issues/34978
match target {
"i586-unknown-linux-gnu" |
"i686-unknown-linux-musl" |
"x86_64-unknown-linux-musl" => {
base.push("-Wa,-mrelax-relocations=no".into());
},
_ => {},
}
return base
}

Expand Down
28 changes: 24 additions & 4 deletions src/ci/docker/cross/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ FROM ubuntu:16.04
RUN apt-get update && apt-get install -y --no-install-recommends \
g++ \
make \
ninja-build \
file \
curl \
ca-certificates \
python2.7 \
python2.7-dev \
git \
cmake \
sudo \
xz-utils \
zlib1g-dev \
Expand All @@ -19,7 +19,15 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
bzip2 \
patch \
libssl-dev \
pkg-config
pkg-config \
swig \
libedit-dev \
libncurses5-dev

# CMake 3.8.0 is the first version with official support for Fuchsia,
# which is needed to build the Fuchsia toolchain.
RUN curl -L https://cmake.org/files/v3.8/cmake-3.8.0-rc1-Linux-x86_64.tar.gz | \
tar xzf - -C /usr/local --strip-components=1

RUN curl -o /usr/local/bin/sccache \
https://s3.amazonaws.com/rust-lang-ci/rust-ci-mirror/2017-02-24-sccache-x86_64-unknown-linux-gnu && \
Expand All @@ -31,6 +39,10 @@ RUN curl -OL https://github.com/Yelp/dumb-init/releases/download/v1.2.0/dumb-ini
ENTRYPOINT ["/usr/bin/dumb-init", "--"]

WORKDIR /tmp
COPY shared.sh /tmp/

COPY build-fuchsia.sh /tmp/
RUN ./build-fuchsia.sh

COPY build-rumprun.sh /tmp/
RUN ./build-rumprun.sh
Expand Down Expand Up @@ -65,10 +77,18 @@ ENV TARGETS=$TARGETS,arm-unknown-linux-musleabi
ENV TARGETS=$TARGETS,arm-unknown-linux-musleabihf
ENV TARGETS=$TARGETS,armv7-unknown-linux-musleabihf
ENV TARGETS=$TARGETS,sparc64-unknown-linux-gnu
ENV TARGETS=$TARGETS,x86_64-unknown-fuchsia
ENV TARGETS=$TARGETS,aarch64-unknown-fuchsia

ENV CC_mipsel_unknown_linux_musl=mipsel-openwrt-linux-gcc \
CC_mips_unknown_linux_musl=mips-openwrt-linux-gcc \
CC_sparc64_unknown_linux_gnu=sparc64-linux-gnu-gcc
CC_sparc64_unknown_linux_gnu=sparc64-linux-gnu-gcc \
AR_x86_64_unknown_fuchsia=x86_64-unknown-fuchsia-ar \
CC_x86_64_unknown_fuchsia=x86_64-unknown-fuchsia-clang \
CXX_x86_64_unknown_fuchsia=x86_64-unknown-fuchsia-clang++ \
AR_aarch64_unknown_fuchsia=aarch64-unknown-fuchsia-ar \
CC_aarch64_unknown_fuchsia=aarch64-unknown-fuchsia-clang \
CXX_aarch64_unknown_fuchsia=aarch64-unknown-fuchsia-clang++

# Suppress some warnings in the openwrt toolchains we downloaded
ENV STAGING_DIR=/tmp
Expand Down
114 changes: 114 additions & 0 deletions src/ci/docker/cross/build-fuchsia.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
#!/bin/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

# Download sources
SRCS=(
"https://fuchsia.googlesource.com/magenta magenta 29f09e6"
"https://fuchsia.googlesource.com/third_party/llvm llvm 0f6af23"
"https://fuchsia.googlesource.com/third_party/clang llvm/tools/clang 71b73d0"
"https://fuchsia.googlesource.com/third_party/lld llvm/tools/lld af25ab9"
"https://fuchsia.googlesource.com/third_party/lldb llvm/tools/lldb 90fe975"
"https://fuchsia.googlesource.com/third_party/compiler-rt llvm/runtimes/compiler-rt 2edda55"
"https://fuchsia.googlesource.com/third_party/libcxx llvm/runtimes/libcxx b7fd0be"
"https://fuchsia.googlesource.com/third_party/libcxxabi llvm/runtimes/libcxxabi 66c8647"
"https://fuchsia.googlesource.com/third_party/libunwind llvm/runtimes/libunwind 43ce8ac"
)

fetch() {
mkdir -p $2
pushd $2 > /dev/null
curl -sL $1/+archive/$3.tar.gz | tar xzf -
popd > /dev/null
}

for i in "${SRCS[@]}"; do
fetch $i
done

# Build toolchain
cd llvm
mkdir build
cd build
hide_output cmake -GNinja \
-DFUCHSIA_SYSROOT=${PWD}/../../magenta/third_party/ulib/musl \
-C ../tools/clang/cmake/caches/Fuchsia.cmake \
..
hide_output ninja stage2-distribution
hide_output ninja stage2-install-distribution
cd ../..

# Build sysroot
rm -rf llvm/runtimes/compiler-rt
./magenta/scripts/download-toolchain

build_sysroot() {
local arch="$1"

case "${arch}" in
x86_64) tgt="magenta-pc-x86-64" ;;
aarch64) tgt="magenta-qemu-arm64" ;;
esac

hide_output make -C magenta -j$(getconf _NPROCESSORS_ONLN) $tgt
dst=/usr/local/${arch}-unknown-fuchsia
mkdir -p $dst
cp -r magenta/build-${tgt}/sysroot/include $dst/
cp -r magenta/build-${tgt}/sysroot/lib $dst/

cd llvm
mkdir build-runtimes-${arch}
cd build-runtimes-${arch}
hide_output cmake -GNinja \
-DCMAKE_C_COMPILER=clang \
-DCMAKE_CXX_COMPILER=clang++ \
-DCMAKE_AR=/usr/local/bin/llvm-ar \
-DCMAKE_RANLIB=/usr/local/bin/llvm-ranlib \
-DCMAKE_INSTALL_PREFIX= \
-DLLVM_MAIN_SRC_DIR=${PWD}/.. \
-DLLVM_BINARY_DIR=${PWD}/../build \
-DLLVM_ENABLE_WERROR=OFF \
-DCMAKE_BUILD_TYPE=Release \
-DLLVM_INCLUDE_TESTS=ON \
-DCMAKE_SYSTEM_NAME=Fuchsia \
-DCMAKE_C_COMPILER_TARGET=${arch}-fuchsia \
-DCMAKE_CXX_COMPILER_TARGET=${arch}-fuchsia \
-DUNIX=1 \
-DLIBCXX_HAS_MUSL_LIBC=ON \
-DLIBCXXABI_USE_LLVM_UNWINDER=ON \
-DCMAKE_SYSROOT=${dst} \
-DCMAKE_C_COMPILER_FORCED=TRUE \
-DCMAKE_CXX_COMPILER_FORCED=TRUE \
-DLLVM_ENABLE_LIBCXX=ON \
-DCMAKE_EXE_LINKER_FLAGS="-nodefaultlibs -lc" \
-DCMAKE_SHARED_LINKER_FLAGS="$(clang --target=${arch}-fuchsia -print-libgcc-file-name)" \
../runtimes
hide_output env DESTDIR="${dst}" ninja install
cd ../..
}

build_sysroot "x86_64"
build_sysroot "aarch64"

rm -rf magenta llvm

for arch in x86_64 aarch64; do
for tool in clang clang++; do
cat >/usr/local/bin/${arch}-unknown-fuchsia-${tool} <<EOF
#!/bin/sh
${tool} --target=${arch}-unknown-fuchsia --sysroot=/usr/local/${arch}-unknown-fuchsia "\$@"
EOF
chmod +x /usr/local/bin/${arch}-unknown-fuchsia-${tool}
done
ln -s /usr/local/bin/llvm-ar /usr/local/bin/${arch}-unknown-fuchsia-ar
done
25 changes: 25 additions & 0 deletions src/ci/docker/cross/shared.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# 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
}
8 changes: 8 additions & 0 deletions src/ci/docker/linux-tested-targets/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,14 @@ ENV RUST_CONFIGURE_ARGS \
--musl-root-x86_64=/musl-x86_64 \
--musl-root-i686=/musl-i686

# Newer binutils broke things on some vms/distros (i.e., linking against
# unknown relocs disabled by the following flag), so we need to go out of our
# way to produce "super compatible" binaries.
#
# See: https://github.com/rust-lang/rust/issues/34978
ENV CFLAGS_i686_unknown_linux_gnu=-Wa,-mrelax-relocations=no \
CFLAGS_x86_64_unknown_linux_gnu=-Wa,-mrelax-relocations=no

ENV SCRIPT \
python2.7 ../x.py test \
--target x86_64-unknown-linux-musl \
Expand Down
5 changes: 4 additions & 1 deletion src/ci/docker/linux-tested-targets/build-musl.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@

set -ex

export CFLAGS="-fPIC"
# We need to mitigate rust-lang/rust#34978 when compiling musl itself as well
export CFLAGS="-fPIC -Wa,-mrelax-relocations=no"
export CXXFLAGS="-Wa,-mrelax-relocations=no"

MUSL=musl-1.1.14
curl https://www.musl-libc.org/releases/$MUSL.tar.gz | tar xzf -
cd $MUSL
Expand Down
22 changes: 20 additions & 2 deletions src/doc/nomicon/src/phantom-data.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,5 +82,23 @@ standard library made a utility for itself called `Unique<T>` which:

* wraps a `*const T` for variance
* includes a `PhantomData<T>`
* auto-derives Send/Sync as if T was contained
* marks the pointer as NonZero for the null-pointer optimization
* auto-derives `Send`/`Sync` as if T was contained
* marks the pointer as `NonZero` for the null-pointer optimization

## Table of `PhantomData` patterns

Here’s a table of all the wonderful ways `PhantomData` could be used:

| Phantom type | `'a` | `T` |
|-----------------------------|-----------|---------------------------|
| `PhantomData<T>` | - | variant (with drop check) |
| `PhantomData<&'a T>` | variant | variant |
| `PhantomData<&'a mut T>` | variant | invariant |
| `PhantomData<*const T>` | - | variant |
| `PhantomData<*mut T>` | - | invariant |
| `PhantomData<fn(T)>` | - | contravariant (*) |
| `PhantomData<fn() -> T>` | - | variant |
| `PhantomData<fn(T) -> T>` | - | invariant |
| `PhantomData<Cell<&'a ()>>` | invariant | - |

(*) If contravariance gets scrapped, this would be invariant.
10 changes: 9 additions & 1 deletion src/libcompiler_builtins/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,15 @@ fn main() {
// compiler-rt's build system already
cfg.flag("-fno-builtin");
cfg.flag("-fvisibility=hidden");
cfg.flag("-fomit-frame-pointer");
// Accepted practice on Solaris is to never omit frame pointer so that
// system observability tools work as expected. In addition, at least
// on Solaris, -fomit-frame-pointer on sparcv9 appears to generate
// references to data outside of the current stack frame. A search of
// the gcc bug database provides a variety of issues surrounding
// -fomit-frame-pointer on non-x86 platforms.
if !target.contains("solaris") && !target.contains("sparc") {
cfg.flag("-fomit-frame-pointer");
}
cfg.flag("-ffreestanding");
cfg.define("VISIBILITY_HIDDEN", None);
}
Expand Down
Loading