Skip to content
2 changes: 1 addition & 1 deletion src/compiler-rt
Submodule compiler-rt updated 95 files
+8 −0 cmake/config-ix.cmake
+6 −0 include/sanitizer/common_interface_defs.h
+1 −1 lib/asan/asan_fake_stack.h
+4 −4 lib/asan/asan_mac.cc
+39 −336 lib/asan/asan_malloc_mac.cc
+16 −9 lib/asan/asan_poisoning.cc
+1 −0 lib/asan/asan_win.cc
+1 −0 lib/asan/asan_win_dynamic_runtime_thunk.cc
+2 −0 lib/asan/scripts/asan_device_setup
+1 −1 lib/asan/scripts/asan_symbolize.py
+4 −2 lib/builtins/CMakeLists.txt
+1 −1 lib/builtins/fp_fixuint_impl.inc
+47 −18 lib/builtins/gcc_personality_v0.c
+2 −2 lib/builtins/i386/chkstk.S
+40 −0 lib/builtins/i386/chkstk2.S
+2 −2 lib/builtins/x86_64/chkstk.S
+42 −0 lib/builtins/x86_64/chkstk2.S
+1 −0 lib/interception/interception_win.cc
+0 −2 lib/msan/msan.cc
+50 −36 lib/msan/msan.h
+1 −1 lib/msan/msan_allocator.h
+6 −0 lib/msan/msan_linux.cc
+2 −2 lib/sanitizer_common/sanitizer_bitvector.h
+3 −3 lib/sanitizer_common/sanitizer_common.cc
+1 −1 lib/sanitizer_common/sanitizer_common.h
+20 −5 lib/sanitizer_common/sanitizer_common_interceptors.inc
+4 −1 lib/sanitizer_common/sanitizer_interface_internal.h
+1 −1 lib/sanitizer_common/sanitizer_libignore.cc
+1 −42 lib/sanitizer_common/sanitizer_linux_libcdep.cc
+2 −0 lib/sanitizer_common/sanitizer_mac.cc
+350 −0 lib/sanitizer_common/sanitizer_malloc_mac.inc
+2 −2 lib/sanitizer_common/sanitizer_platform_interceptors.h
+20 −5 lib/sanitizer_common/sanitizer_platform_limits_posix.cc
+4 −1 lib/sanitizer_common/sanitizer_platform_limits_posix.h
+7 −11 lib/sanitizer_common/sanitizer_posix.cc
+2 −0 lib/sanitizer_common/sanitizer_posix.h
+43 −0 lib/sanitizer_common/sanitizer_posix_libcdep.cc
+4 −2 lib/sanitizer_common/sanitizer_symbolizer_posix_libcdep.cc
+1 −0 lib/sanitizer_common/sanitizer_symbolizer_win.cc
+1 −1 lib/sanitizer_common/sanitizer_win.cc
+65 −47 lib/tsan/CMakeLists.txt
+0 −2 lib/tsan/rtl/tsan_clock.cc
+2 −1 lib/tsan/rtl/tsan_clock.h
+2 −0 lib/tsan/rtl/tsan_defs.h
+126 −54 lib/tsan/rtl/tsan_interceptors.cc
+59 −0 lib/tsan/rtl/tsan_malloc_mac.cc
+1 −0 lib/tsan/rtl/tsan_mman.h
+3 −2 lib/tsan/rtl/tsan_mutex.cc
+8 −0 lib/tsan/rtl/tsan_new_delete.cc
+4 −0 lib/tsan/rtl/tsan_platform.h
+5 −88 lib/tsan/rtl/tsan_platform_linux.cc
+108 −17 lib/tsan/rtl/tsan_platform_mac.cc
+124 −0 lib/tsan/rtl/tsan_platform_posix.cc
+3 −2 lib/tsan/rtl/tsan_report.cc
+2 −1 lib/tsan/rtl/tsan_rtl.cc
+8 −2 lib/tsan/rtl/tsan_rtl.h
+8 −3 lib/tsan/rtl/tsan_rtl_thread.cc
+1 −1 lib/ubsan/ubsan_diag.h
+0 −8 test/asan/TestCases/Darwin/interface_symbols_darwin.c
+81 −12 test/asan/TestCases/Linux/ptrace.cc
+1 −0 test/asan/TestCases/Linux/stress_dtls.c
+1 −0 test/asan/TestCases/Posix/coverage-caller-callee.cc
+10 −2 test/asan/TestCases/contiguous_container.cc
+1 −1 test/asan/TestCases/coverage-levels.cc
+1 −0 test/asan/TestCases/coverage-order-pcs.cc
+3 −0 test/asan/TestCases/coverage-reset.cc
+1 −0 test/asan/TestCases/coverage-tracing.cc
+5 −2 test/asan/TestCases/throw_call_test.cc
+2 −2 test/asan/android_commands/android_run.py
+1 −1 test/asan/lit.cfg
+71 −0 test/builtins/Unit/fixtfdi_test.c
+1 −1 test/builtins/Unit/fixtfsi_test.c
+83 −0 test/builtins/Unit/fixtfti_test.c
+3 −0 test/builtins/Unit/fixunsdfdi_test.c
+2 −0 test/builtins/Unit/fixunsdfsi_test.c
+3 −0 test/builtins/Unit/fixunsdfti_test.c
+2 −0 test/builtins/Unit/fixunssfdi_test.c
+2 −0 test/builtins/Unit/fixunssfsi_test.c
+5 −3 test/builtins/Unit/fixunstfdi_test.c
+3 −0 test/builtins/Unit/fixunstfsi_test.c
+103 −0 test/builtins/Unit/fixunstfti_test.c
+1 −1 test/builtins/Unit/multf3_test.c
+8 −7 test/msan/Linux/process_vm_readv.cc
+0 −4 test/msan/chained_origin_limits.cc
+21 −11 test/msan/mmap.cc
+1 −15 test/msan/strlen_of_shadow.cc
+15 −4 test/sanitizer_common/TestCases/Linux/ptrace.cc
+1 −1 test/tsan/CMakeLists.txt
+1 −1 test/tsan/atomic_free3.cc
+9 −3 test/tsan/lit.cfg
+1 −1 test/tsan/real_deadlock_detector_stress_test.cc
+1 −1 test/tsan/signal_errno.cc
+17 −20 test/tsan/test.h
+1 −1 test/tsan/thread_name2.cc
+1 −1 test/ubsan/TestCases/Misc/coverage-levels.cc
12 changes: 8 additions & 4 deletions src/doc/trpl/concurrency.md
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ languages. It will not compile:

```ignore
use std::thread;
use std::time::Duration;

fn main() {
let mut data = vec![1, 2, 3];
Expand All @@ -131,7 +132,7 @@ fn main() {
});
}

thread::sleep_ms(50);
thread::sleep(Duration::from_millis(50));
}
```

Expand Down Expand Up @@ -165,6 +166,7 @@ indivisible operations which can't have data races.
```ignore
use std::thread;
use std::sync::Arc;
use std::time::Duration;

fn main() {
let mut data = Arc::new(vec![1, 2, 3]);
Expand All @@ -176,7 +178,7 @@ fn main() {
});
}

thread::sleep_ms(50);
thread::sleep(Duration::from_millis(50));
}
```

Expand Down Expand Up @@ -207,6 +209,7 @@ Here's the working version:
```rust
use std::sync::{Arc, Mutex};
use std::thread;
use std::time::Duration;

fn main() {
let data = Arc::new(Mutex::new(vec![1, 2, 3]));
Expand All @@ -219,7 +222,7 @@ fn main() {
});
}

thread::sleep_ms(50);
thread::sleep(Duration::from_millis(50));
}
```

Expand All @@ -241,6 +244,7 @@ Let's examine the body of the thread more closely:
```rust
# use std::sync::{Arc, Mutex};
# use std::thread;
# use std::time::Duration;
# fn main() {
# let data = Arc::new(Mutex::new(vec![1, 2, 3]));
# for i in 0..3 {
Expand All @@ -250,7 +254,7 @@ thread::spawn(move || {
data[i] += 1;
});
# }
# thread::sleep_ms(50);
# thread::sleep(Duration::from_millis(50));
# }
```

Expand Down
23 changes: 13 additions & 10 deletions src/doc/trpl/dining-philosophers.md
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,7 @@ eat. Here’s the next version:

```rust
use std::thread;
use std::time::Duration;

struct Philosopher {
name: String,
Expand All @@ -279,7 +280,7 @@ impl Philosopher {
fn eat(&self) {
println!("{} is eating.", self.name);

thread::sleep_ms(1000);
thread::sleep(Duration::from_millis(1000));

println!("{} is done eating.", self.name);
}
Expand Down Expand Up @@ -313,13 +314,13 @@ from the standard library, and so we need to `use` it.
fn eat(&self) {
println!("{} is eating.", self.name);

thread::sleep_ms(1000);
thread::sleep(Duration::from_millis(1000));

println!("{} is done eating.", self.name);
}
```

We now print out two messages, with a `sleep_ms()` in the middle. This will
We now print out two messages, with a `sleep` in the middle. This will
simulate the time it takes a philosopher to eat.

If you run this program, you should see each philosopher eat in turn:
Expand All @@ -345,6 +346,7 @@ Here’s the next iteration:

```rust
use std::thread;
use std::time::Duration;

struct Philosopher {
name: String,
Expand All @@ -360,7 +362,7 @@ impl Philosopher {
fn eat(&self) {
println!("{} is eating.", self.name);

thread::sleep_ms(1000);
thread::sleep(Duration::from_millis(1000));

println!("{} is done eating.", self.name);
}
Expand Down Expand Up @@ -493,6 +495,7 @@ Let’s modify the program to use the `Table`:

```rust
use std::thread;
use std::time::Duration;
use std::sync::{Mutex, Arc};

struct Philosopher {
Expand All @@ -512,12 +515,12 @@ impl Philosopher {

fn eat(&self, table: &Table) {
let _left = table.forks[self.left].lock().unwrap();
thread::sleep_ms(150);
thread::sleep(Duration::from_millis(150));
let _right = table.forks[self.right].lock().unwrap();

println!("{} is eating.", self.name);

thread::sleep_ms(1000);
thread::sleep(Duration::from_millis(1000));

println!("{} is done eating.", self.name);
}
Expand Down Expand Up @@ -598,12 +601,12 @@ We now need to construct those `left` and `right` values, so we add them to
```rust,ignore
fn eat(&self, table: &Table) {
let _left = table.forks[self.left].lock().unwrap();
thread::sleep_ms(150);
thread::sleep(Duration::from_millis(150));
let _right = table.forks[self.right].lock().unwrap();

println!("{} is eating.", self.name);

thread::sleep_ms(1000);
thread::sleep(Duration::from_millis(1000));

println!("{} is done eating.", self.name);
}
Expand All @@ -614,8 +617,8 @@ We have three new lines. We’ve added an argument, `table`. We access the
the fork at that particular index. That gives us access to the `Mutex` at that
index, and we call `lock()` on it. If the mutex is currently being accessed by
someone else, we’ll block until it becomes available. We have also a call to
`thread::sleep_ms` between the moment first fork is picked and the moment the
second forked is picked, as the process of picking up the fork is not
`thread::sleep` between the moment the first fork is picked and the moment the
second forked is picked, as the process of picking up the fork is not
immediate.

The call to `lock()` might fail, and if it does, we want to crash. In this
Expand Down
26 changes: 23 additions & 3 deletions src/doc/trpl/strings.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,29 @@ compiled program, and exists for the entire duration it runs. The `greeting`
binding is a reference to this statically allocated string. String slices
have a fixed size, and cannot be mutated.

A `String`, on the other hand, is a heap-allocated string. This string is
growable, and is also guaranteed to be UTF-8. `String`s are commonly created by
converting from a string slice using the `to_string` method.
String literals can span multiple lines. There are two forms. The first will
include the newline and the leading spaces:

```rust
let s = "foo
bar";

assert_eq!("foo\n bar", s);
```

The second, with a `\`, does not trim the spaces:

```rust
let s = "foo\
bar";

assert_eq!("foobar", s);
```

Rust has more than just `&str`s though. A `String`, is a heap-allocated string.
This string is growable, and is also guaranteed to be UTF-8. `String`s are
commonly created by converting from a string slice using the `to_string`
method.

```rust
let mut s = "Hello".to_string(); // mut s: String
Expand Down
4 changes: 3 additions & 1 deletion src/doc/trpl/the-stack-and-the-heap.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,9 @@ visualize what’s going on with memory. Your operating system presents a view o
memory to your program that’s pretty simple: a huge list of addresses, from 0
to a large number, representing how much RAM your computer has. For example, if
you have a gigabyte of RAM, your addresses go from `0` to `1,073,741,823`. That
number comes from 2<sup>30</sup>, the number of bytes in a gigabyte.
number comes from 2<sup>30</sup>, the number of bytes in a gigabyte. [^gigabyte]

[^gigabyte]: ‘Gigabyte’ can mean two things: 10^9, or 2^30. The SI standard resolved this by stating that ‘gigabyte’ is 10^9, and ‘gibibyte’ is 2^30. However, very few people use this terminology, and rely on context to differentiate. We follow in that tradition here.

This memory is kind of like a giant array: addresses start at zero and go
up to the final number. So here’s a diagram of our first stack frame:
Expand Down
5 changes: 5 additions & 0 deletions src/librustc/metadata/csearch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,11 @@ pub fn is_const_fn(cstore: &cstore::CStore, did: DefId) -> bool {
decoder::is_const_fn(&*cdata, did.index)
}

pub fn is_static(cstore: &cstore::CStore, did: DefId) -> bool {
let cdata = cstore.get_crate_data(did.krate);
decoder::is_static(&*cdata, did.index)
}

pub fn is_impl(cstore: &cstore::CStore, did: DefId) -> bool {
let cdata = cstore.get_crate_data(did.krate);
decoder::is_impl(&*cdata, did.index)
Expand Down
8 changes: 8 additions & 0 deletions src/librustc/metadata/decoder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1425,6 +1425,14 @@ pub fn is_const_fn(cdata: Cmd, id: DefIndex) -> bool {
}
}

pub fn is_static(cdata: Cmd, id: DefIndex) -> bool {
let item_doc = cdata.lookup_item(id);
match item_family(item_doc) {
ImmStatic | MutStatic => true,
_ => false,
}
}

pub fn is_impl(cdata: Cmd, id: DefIndex) -> bool {
let item_doc = cdata.lookup_item(id);
match item_family(item_doc) {
Expand Down
3 changes: 2 additions & 1 deletion src/librustc_trans/trans/base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2875,7 +2875,8 @@ pub fn trans_crate<'tcx>(tcx: &ty::ctxt<'tcx>,
sess.cstore.iter_crate_data(|cnum, _| {
let syms = csearch::get_reachable_ids(&sess.cstore, cnum);
reachable_symbols.extend(syms.into_iter().filter(|did| {
csearch::is_extern_fn(&sess.cstore, *did, shared_ccx.tcx())
csearch::is_extern_fn(&sess.cstore, *did, shared_ccx.tcx()) ||
csearch::is_static(&sess.cstore, *did)
}).map(|did| {
csearch::get_symbol(&sess.cstore, did)
}));
Expand Down
3 changes: 2 additions & 1 deletion src/test/run-make/issue-14500/foo.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@
// except according to those terms.

extern void foo();
extern char FOO_STATIC;

int main() {
foo();
return 0;
return (int)FOO_STATIC;
}
3 changes: 3 additions & 0 deletions src/test/run-make/issue-14500/foo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,6 @@

#[no_mangle]
pub extern fn foo() {}

#[no_mangle]
pub static FOO_STATIC: u8 = 0;