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 7 pull requests #60087

Closed
wants to merge 20 commits into from
Closed
Show file tree
Hide file tree
Changes from 6 commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
cc2689a
implement nth_back for Bytes
koalatux Apr 16, 2019
fae2a68
implement nth_back for Fuse
koalatux Apr 16, 2019
2605537
implement nth_back for Enumerate
koalatux Apr 16, 2019
ca19ffe
Update rustfmt to 1.2.1
topecongiro Apr 17, 2019
365a48a
whitelist rtm x86 cpu feature
mtak- Apr 17, 2019
379c541
Simplify the returning of a Result a bit
janhohenheim Apr 17, 2019
553ec5d
Update run-make PGO test to new commandline syntax.
michaelwoerister Apr 17, 2019
4269be3
Prefix PROFILER_SUPPORT and SANITIZER_SUPPORT test env vars with RUST…
michaelwoerister Apr 18, 2019
227be65
compiletest: Allow for tests requiring profiler-rt or sanitizer-rt su…
michaelwoerister Apr 18, 2019
e2acaee
Add codegen test that makes sure PGO instrumentation is emitted as ex…
michaelwoerister Apr 16, 2019
d98afc5
Fix small errors in docs for `rchunks_exact` and `rchunks_exact_mut`.
nathankleyn Apr 18, 2019
cc77087
Use new `needs-(profiler|sanitizer)-support` compiletest directive to…
michaelwoerister Apr 18, 2019
08efbac
Implement event filtering for self-profiler.
michaelwoerister Apr 12, 2019
c058122
Rollup merge of #59915 - michaelwoerister:sp-event-filters-1, r=wesle…
Centril Apr 18, 2019
f41ed55
Rollup merge of #60023 - koalatux:nth-back, r=scottmcm
Centril Apr 18, 2019
cf9e27f
Rollup merge of #60038 - michaelwoerister:pgo-updates-2, r=alexcrichton
Centril Apr 18, 2019
c37eccc
Rollup merge of #60041 - jnferner:patch-1, r=shepmaster
Centril Apr 18, 2019
38b51a3
Rollup merge of #60056 - topecongiro:rustfmt-1.2.1, r=alexcrichton
Centril Apr 18, 2019
38a30f4
Rollup merge of #60060 - mtak-:rtm-x86-feature, r=petrochenkov
Centril Apr 18, 2019
aecf059
Rollup merge of #60080 - nathankleyn:fix-issue-60068, r=Centril
Centril Apr 18, 2019
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
4 changes: 2 additions & 2 deletions src/bootstrap/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1268,11 +1268,11 @@ impl Step for Compiletest {
builder.add_rust_test_threads(&mut cmd);

if builder.config.sanitizers {
cmd.env("SANITIZER_SUPPORT", "1");
cmd.env("RUSTC_SANITIZER_SUPPORT", "1");
}

if builder.config.profiler {
cmd.env("PROFILER_SUPPORT", "1");
cmd.env("RUSTC_PROFILER_SUPPORT", "1");
}

cmd.env("RUST_TEST_TMPDIR", builder.out.join("tmp"));
Expand Down
20 changes: 20 additions & 0 deletions src/test/codegen/pgo-instrumentation.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// Test that `-Zpgo-gen` creates expected instrumentation artifacts in LLVM IR.

// needs-profiler-support
// compile-flags: -Z pgo-gen -Ccodegen-units=1

// CHECK: @__llvm_profile_raw_version =
// CHECK: @__profc_{{.*}}pgo_instrumentation{{.*}}some_function{{.*}} = private global
// CHECK: @__profd_{{.*}}pgo_instrumentation{{.*}}some_function{{.*}} = private global
// CHECK: @__profc_{{.*}}pgo_instrumentation{{.*}}main{{.*}} = private global
// CHECK: @__profd_{{.*}}pgo_instrumentation{{.*}}main{{.*}} = private global
// CHECK: @__llvm_profile_filename = {{.*}}"default_%m.profraw\00"{{.*}}

#[inline(never)]
fn some_function() {

}

fn main() {
some_function();
}
4 changes: 2 additions & 2 deletions src/test/run-make-fulldeps/pgo-gen-lto/Makefile
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# needs-profiler-support

-include ../tools.mk

all:
ifeq ($(PROFILER_SUPPORT),1)
$(RUSTC) -Copt-level=3 -Clto=fat -Z pgo-gen="$(TMPDIR)" test.rs
$(call RUN,test) || exit 1
[ -e "$(TMPDIR)"/default_*.profraw ] || (echo "No .profraw file"; exit 1)
endif
6 changes: 3 additions & 3 deletions src/test/run-make-fulldeps/pgo-gen-no-imp-symbols/Makefile
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# needs-profiler-support

-include ../tools.mk

all:
ifeq ($(PROFILER_SUPPORT),1)
$(RUSTC) -O -Ccodegen-units=1 -Z pgo-gen="$(TMPDIR)/test.profraw" --emit=llvm-ir test.rs
$(RUSTC) -O -Ccodegen-units=1 -Z pgo-gen="$(TMPDIR)" --emit=llvm-ir test.rs
# We expect symbols starting with "__llvm_profile_".
$(CGREP) "__llvm_profile_" < $(TMPDIR)/test.ll
# We do NOT expect the "__imp_" version of these symbols.
$(CGREP) -v "__imp___llvm_profile_" < $(TMPDIR)/test.ll # 64 bit
$(CGREP) -v "__imp____llvm_profile_" < $(TMPDIR)/test.ll # 32 bit
endif
4 changes: 2 additions & 2 deletions src/test/run-make-fulldeps/pgo-gen/Makefile
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# needs-profiler-support

-include ../tools.mk

all:
ifeq ($(PROFILER_SUPPORT),1)
$(RUSTC) -g -Z pgo-gen="$(TMPDIR)" test.rs
$(call RUN,test) || exit 1
[ -e "$(TMPDIR)"/default_*.profraw ] || (echo "No .profraw file"; exit 1)
endif
4 changes: 2 additions & 2 deletions src/test/run-make-fulldeps/profile/Makefile
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# needs-profiler-support

-include ../tools.mk

all:
ifeq ($(PROFILER_SUPPORT),1)
$(RUSTC) -g -Z profile test.rs
$(call RUN,test) || exit 1
[ -e "$(TMPDIR)/test.gcno" ] || (echo "No .gcno file"; exit 1)
[ -e "$(TMPDIR)/test.gcda" ] || (echo "No .gcda file"; exit 1)
endif
6 changes: 2 additions & 4 deletions src/test/run-make-fulldeps/sanitizer-address/Makefile
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
# needs-sanitizer-support

-include ../tools.mk

LOG := $(TMPDIR)/log.txt

# NOTE the address sanitizer only supports x86_64 linux and macOS

ifeq ($(TARGET),x86_64-apple-darwin)
ASAN_SUPPORT=$(SANITIZER_SUPPORT)
EXTRA_RUSTFLAG=-C rpath
else
ifeq ($(TARGET),x86_64-unknown-linux-gnu)
ASAN_SUPPORT=$(SANITIZER_SUPPORT)

# Apparently there are very specific Linux kernels, notably the one that's
# currently on Travis CI, which contain a buggy commit that triggers failures in
Expand All @@ -23,7 +23,5 @@ endif
endif

all:
ifeq ($(ASAN_SUPPORT),1)
$(RUSTC) -g -Z sanitizer=address -Z print-link-args $(EXTRA_RUSTFLAG) overflow.rs | $(CGREP) librustc_asan
$(TMPDIR)/overflow 2>&1 | $(CGREP) stack-buffer-overflow
endif
5 changes: 2 additions & 3 deletions src/test/run-make-fulldeps/sanitizer-cdylib-link/Makefile
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# needs-sanitizer-support

-include ../tools.mk

LOG := $(TMPDIR)/log.txt
Expand All @@ -8,15 +10,12 @@ LOG := $(TMPDIR)/log.txt
# is correctly detected.

ifeq ($(TARGET),x86_64-unknown-linux-gnu)
ASAN_SUPPORT=$(SANITIZER_SUPPORT)

# See comment in sanitizer-address/Makefile for why this is here
EXTRA_RUSTFLAG=-C relocation-model=dynamic-no-pic
endif

all:
ifeq ($(ASAN_SUPPORT),1)
$(RUSTC) -g -Z sanitizer=address --crate-type cdylib --target $(TARGET) $(EXTRA_RUSTFLAG) library.rs
$(RUSTC) -g -Z sanitizer=address --crate-type bin --target $(TARGET) $(EXTRA_RUSTFLAG) -llibrary program.rs
LD_LIBRARY_PATH=$(TMPDIR) $(TMPDIR)/program 2>&1 | $(CGREP) stack-buffer-overflow
endif
6 changes: 2 additions & 4 deletions src/test/run-make-fulldeps/sanitizer-dylib-link/Makefile
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# needs-sanitizer-support

-include ../tools.mk

LOG := $(TMPDIR)/log.txt
Expand All @@ -8,15 +10,11 @@ LOG := $(TMPDIR)/log.txt
# is correctly detected.

ifeq ($(TARGET),x86_64-unknown-linux-gnu)
ASAN_SUPPORT=$(SANITIZER_SUPPORT)

# See comment in sanitizer-address/Makefile for why this is here
EXTRA_RUSTFLAG=-C relocation-model=dynamic-no-pic
endif

all:
ifeq ($(ASAN_SUPPORT),1)
$(RUSTC) -g -Z sanitizer=address --crate-type dylib --target $(TARGET) $(EXTRA_RUSTFLAG) library.rs
$(RUSTC) -g -Z sanitizer=address --crate-type bin --target $(TARGET) $(EXTRA_RUSTFLAG) -llibrary program.rs
LD_LIBRARY_PATH=$(TMPDIR) $(TMPDIR)/program 2>&1 | $(CGREP) stack-buffer-overflow
endif
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
# needs-sanitizer-support

-include ../tools.mk

# NOTE the address sanitizer only supports x86_64 linux and macOS

ifeq ($(TARGET),x86_64-apple-darwin)
ASAN_SUPPORT=$(SANITIZER_SUPPORT)
EXTRA_RUSTFLAG=-C rpath
else
ifeq ($(TARGET),x86_64-unknown-linux-gnu)
ASAN_SUPPORT=$(SANITIZER_SUPPORT)
EXTRA_RUSTFLAG=
endif
endif

all:
ifeq ($(ASAN_SUPPORT),1)
$(RUSTC) -Z sanitizer=address --crate-type proc-macro --target $(TARGET) hello.rs 2>&1 | $(CGREP) '-Z sanitizer'
endif
3 changes: 1 addition & 2 deletions src/test/run-make-fulldeps/sanitizer-leak/Makefile
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
-include ../tools.mk

# needs-sanitizer-support
# only-linux
# only-x86_64
# ignore-test
# FIXME(#46126) ThinLTO for libstd broke this test

all:
ifdef SANITIZER_SUPPORT
$(RUSTC) -C opt-level=1 -g -Z sanitizer=leak -Z print-link-args leak.rs | $(CGREP) librustc_lsan
$(TMPDIR)/leak 2>&1 | $(CGREP) 'detected memory leaks'
endif
3 changes: 1 addition & 2 deletions src/test/run-make-fulldeps/sanitizer-memory/Makefile
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
-include ../tools.mk

# needs-sanitizer-support
# only-linux
# only-x86_64

all:
ifdef SANITIZER_SUPPORT
$(RUSTC) -g -Z sanitizer=memory -Z print-link-args uninit.rs | $(CGREP) librustc_msan
$(TMPDIR)/uninit 2>&1 | $(CGREP) use-of-uninitialized-value
endif
7 changes: 3 additions & 4 deletions src/test/run-make-fulldeps/sanitizer-staticlib-link/Makefile
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
# needs-sanitizer-support

-include ../tools.mk

# This test builds a staticlib, then an executable that links to it.
# The staticlib and executable both are compiled with address sanitizer,
# The staticlib and executable both are compiled with address sanitizer,
# and we assert that a fault in the staticlib is correctly detected.

ifeq ($(TARGET),x86_64-unknown-linux-gnu)
ASAN_SUPPORT=$(SANITIZER_SUPPORT)
EXTRA_RUSTFLAG=
endif

all:
ifeq ($(ASAN_SUPPORT),1)
$(RUSTC) -g -Z sanitizer=address --crate-type staticlib --target $(TARGET) library.rs
$(CC) program.c $(call STATICLIB,library) $(call OUT_EXE,program) $(EXTRACFLAGS) $(EXTRACXXFLAGS)
LD_LIBRARY_PATH=$(TMPDIR) $(TMPDIR)/program 2>&1 | $(CGREP) stack-buffer-overflow
endif

21 changes: 21 additions & 0 deletions src/tools/compiletest/src/header.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,9 @@ impl EarlyProps {
}
}

let rustc_has_profiler_support = env::var_os("RUSTC_PROFILER_SUPPORT").is_some();
let rustc_has_sanitizer_support = env::var_os("RUSTC_SANITIZER_SUPPORT").is_some();

iter_header(testfile, None, &mut |ln| {
// we should check if any only-<platform> exists and if it exists
// and does not matches the current platform, skip the test
Expand Down Expand Up @@ -116,6 +119,16 @@ impl EarlyProps {
config.parse_needs_matching_clang(ln) {
props.ignore = Ignore::Ignore;
}

if !rustc_has_profiler_support &&
config.parse_needs_profiler_support(ln) {
props.ignore = Ignore::Ignore;
}

if !rustc_has_sanitizer_support &&
config.parse_needs_sanitizer_support(ln) {
props.ignore = Ignore::Ignore;
}
}

if (config.mode == common::DebugInfoGdb || config.mode == common::DebugInfoBoth) &&
Expand Down Expand Up @@ -748,6 +761,14 @@ impl Config {
self.parse_name_directive(line, "needs-matching-clang")
}

fn parse_needs_profiler_support(&self, line: &str) -> bool {
self.parse_name_directive(line, "needs-profiler-support")
}

fn parse_needs_sanitizer_support(&self, line: &str) -> bool {
self.parse_name_directive(line, "needs-sanitizer-support")
}

/// Parses a name-value directive which contains config-specific information, e.g., `ignore-x86`
/// or `normalize-stderr-32bit`.
fn parse_cfg_name_directive(&self, line: &str, prefix: &str) -> ParsedNameDirective {
Expand Down