about summary refs log tree commit diff
path: root/src/doc
diff options
context:
space:
mode:
authorTomasz Miąsko <tomasz.miasko@gmail.com>2020-01-16 00:00:00 +0000
committerTomasz Miąsko <tomasz.miasko@gmail.com>2020-01-25 19:48:02 +0100
commit7e3c51d085d9eaa2204cc18763bc7d98b66435fd (patch)
treee2f9c74f84d906aff24aa6afc4e78eac10f0b0c4 /src/doc
parent3bf71b3d5c07afc0908881a0868080ed399ca6ca (diff)
downloadrust-7e3c51d085d9eaa2204cc18763bc7d98b66435fd.tar.gz
rust-7e3c51d085d9eaa2204cc18763bc7d98b66435fd.zip
Instrument C / C++ in MemorySanitizer example
Modify the example to instrument C / C++ in addition to Rust, since it
will be generally required (e.g., when using libbacktrace for symbolication).

Additionally use rustc specific flag to track the origins of unitialized
memory rather than LLVM one.
Diffstat (limited to 'src/doc')
-rw-r--r--src/doc/unstable-book/src/compiler-flags/sanitizer.md12
1 files changed, 10 insertions, 2 deletions
diff --git a/src/doc/unstable-book/src/compiler-flags/sanitizer.md b/src/doc/unstable-book/src/compiler-flags/sanitizer.md
index cbb90bd3bb3..c799374354b 100644
--- a/src/doc/unstable-book/src/compiler-flags/sanitizer.md
+++ b/src/doc/unstable-book/src/compiler-flags/sanitizer.md
@@ -96,7 +96,7 @@ Shadow byte legend (one shadow byte represents 8 application bytes):
 ## MemorySanitizer
 
 Use of uninitialized memory. Note that we are using `-Zbuild-std` to instrument
-standard library, and passing `-msan-track-origins=2` to the LLVM to track
+the standard library, and passing `-Zsanitizer-track-origins` to track the
 origins of uninitialized memory:
 
 ```shell
@@ -111,7 +111,15 @@ fn main() {
     }
 }
 
-$ env RUSTFLAGS="-Zsanitizer=memory -Cllvm-args=-msan-track-origins=2" cargo -Zbuild-std run --target x86_64-unknown-linux-gnu
+$ export \
+  CC=clang \
+  CXX=clang++ \
+  CFLAGS='-fsanitize=memory -fsanitize-memory-track-origins' \
+  CXXFLAGS='-fsanitize=memory -fsanitize-memory-track-origins' \
+  RUSTFLAGS='-Zsanitizer=memory -Zsanitizer-memory-track-origins' \
+  RUSTDOCFLAGS='-Zsanitizer=memory -Zsanitizer-memory-track-origins'
+$ cargo clean
+$ cargo -Zbuild-std run --target x86_64-unknown-linux-gnu
 ==9416==WARNING: MemorySanitizer: use-of-uninitialized-value
     #0 0x560c04f7488a in core::fmt::num::imp::fmt_u64::haa293b0b098501ca $RUST/build/x86_64-unknown-linux-gnu/stage1/lib/rustlib/src/rust/src/libcore/fmt/num.rs:202:16
 ...