1 # needs-profiler-support
3 # ISSUE(76038): When targeting MSVC, Rust binaries built with both `-Z instrument-coverage` and
4 # `-C link-dead-code` typically crash (with a seg-fault) or at best generate an empty `*.profraw`.
5 # See ../coverage/coverage_tools.mk for more information.
7 -include ../coverage/coverage_tools.mk
9 BASEDIR=../coverage-spanview-base
12 all: $(patsubst $(SOURCEDIR)/%.rs,%,$(wildcard $(SOURCEDIR)/*.rs))
14 # Ensure there are no `expected` results for tests that may have been removed or renamed
15 .PHONY: clear_expected_if_blessed
16 clear_expected_if_blessed:
17 ifdef RUSTC_BLESS_TEST
18 rm -rf expected_mir_dump.*/
21 -include clear_expected_if_blessed
24 # Compile the test program with coverage instrumentation and generate relevant MIR.
25 $(RUSTC) $(SOURCEDIR)/$@.rs \
26 -Zinstrument-coverage \
27 -Clink-dead-code=$(LINK_DEAD_CODE) \
28 -Zdump-mir=InstrumentCoverage \
30 -Zdump-mir-dir="$(TMPDIR)"/mir_dump.$@
32 for path in "$(TMPDIR)"/mir_dump.$@/*; do \
34 file="$$(basename "$$path")"; \
36 urlescaped="$$("$(PYTHON)" $(BASEDIR)/escape_url.py $$file)" || exit $$?; \
41 Preview this file as rendered HTML from the github source at:\
42 https://htmlpreview.github.io/?https://github.com/rust-lang/rust/blob/master/src/test/run-make-fulldeps/coverage-spanview-base/expected_mir_dump.$@/'"$$urlescaped"'\
44 For revisions in Pull Requests (PR):\
45 * Replace "rust-lang" with the github PR author\
46 * Replace "master" with the PR branch name\
49 done && true # for/done ends in non-zero status
51 ifdef RUSTC_BLESS_TEST
52 mkdir -p expected_mir_dump.$@
53 cp "$(TMPDIR)"/mir_dump.$@/*InstrumentCoverage.0.html expected_mir_dump.$@/
55 # Check that the selected `mir_dump` files match what we expect (`--bless` refreshes `expected`)
56 mkdir -p "$(TMPDIR)"/actual_mir_dump.$@
57 rm -f "$(TMPDIR)"/actual_mir_dump.$@/*
58 cp "$(TMPDIR)"/mir_dump.$@/*InstrumentCoverage.0.html "$(TMPDIR)"/actual_mir_dump.$@/
59 $(DIFF) -r expected_mir_dump.$@/ "$(TMPDIR)"/actual_mir_dump.$@/