Skip to content

Commit b8b0ddb

Browse files
authored
Rollup merge of rust-lang#72952 - pnkfelix:regression-test-for-issue-70924, r=nikomatsakis
run-make regression test for issue rust-lang#70924. Sometime after my PR rust-lang#72767 (to fix issue rust-lang#70924) landed, I realized that I *could* make a local regression test, thanks to `rustc --print sysroot`: I can make a fresh "copy" (really mostly symlinks) of the sysroot, and then modify it to recreate the terms of this bug.
2 parents 365847b + a9d5dff commit b8b0ddb

File tree

2 files changed

+47
-0
lines changed

2 files changed

+47
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
-include ../tools.mk
2+
3+
# rust-lang/rust#70924: Test that if we add rust-src component in between two
4+
# incremetnal compiles, the compiler does not ICE on the second.
5+
6+
# This test uses `ln -s` rather than copying to save testing time, but its
7+
# usage doesn't work on windows. So ignore windows.
8+
9+
# ignore-windows
10+
11+
SYSROOT:=$(shell $(RUSTC) --print sysroot)
12+
FAKEROOT=$(TMPDIR)/fakeroot
13+
INCR=$(TMPDIR)/incr
14+
15+
# Make a local copy of the sysroot; then remove the rust-src part of it, if
16+
# present, for the *first* build. Then put in a facsimile of the rust-src
17+
# component for the second build, in order to expose the ICE from issue #70924.
18+
#
19+
# Note that it is much easier to just do `cp -a $(SYSROOT)/* $(FAKEROOT)` as a
20+
# first step, but I am concerned that would be too expensive in a unit test
21+
# compared to making symbolic links.
22+
#
23+
# Anyway, the pattern you'll see here is: For every prefix in
24+
# root/lib/rustlib/src, link all of prefix parent content, then remove the
25+
# prefix, then loop on the next prefix. This way, we basically create a copy of
26+
# the context around root/lib/rustlib/src, and can freely add/remove the src
27+
# component itself.
28+
all:
29+
mkdir $(FAKEROOT)
30+
ln -s $(SYSROOT)/* $(FAKEROOT)
31+
rm -f $(FAKEROOT)/lib
32+
mkdir $(FAKEROOT)/lib
33+
ln -s $(SYSROOT)/lib/* $(FAKEROOT)/lib
34+
rm -f $(FAKEROOT)/lib/rustlib
35+
mkdir $(FAKEROOT)/lib/rustlib
36+
ln -s $(SYSROOT)/lib/rustlib/* $(FAKEROOT)/lib/rustlib
37+
rm -f $(FAKEROOT)/lib/rustlib/src
38+
mkdir $(FAKEROOT)/lib/rustlib/src
39+
ln -s $(SYSROOT)/lib/rustlib/src/* $(FAKEROOT)/lib/rustlib/src
40+
rm -f $(FAKEROOT)/lib/rustlib/src/rust
41+
$(RUSTC) --sysroot $(FAKEROOT) -C incremental=$(INCR) main.rs
42+
mkdir -p $(FAKEROOT)/lib/rustlib/src/rust/src/libstd
43+
touch $(FAKEROOT)/lib/rustlib/src/rust/src/libstd/lib.rs
44+
$(RUSTC) --sysroot $(FAKEROOT) -C incremental=$(INCR) main.rs
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
fn main() {
2+
println!("Hello World");
3+
}

0 commit comments

Comments
 (0)