Skip to content

Commit 77b708e

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 96ca604 + 94605b9 commit 77b708e

File tree

2 files changed

+42
-0
lines changed

2 files changed

+42
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
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+
SYSROOT:=$(shell $(RUSTC) --print sysroot)
7+
FAKEROOT=$(TMPDIR)/fakeroot
8+
INCR=$(TMPDIR)/incr
9+
10+
# Make a local copy of the sysroot; then remove the rust-src part of it, if
11+
# present, for the *first* build. Then put in a facsimile of the rust-src
12+
# component for the second build, in order to expose the ICE from issue #70924.
13+
#
14+
# Note that it is much easier to just do `cp -a $(SYSROOT)/* $(FAKEROOT)` as a
15+
# first step, but I am concerned that would be too expensive in a unit test
16+
# compared to making symbolic links.
17+
#
18+
# Anyway, the pattern you'll see here is: For every prefix in
19+
# root/lib/rustlib/src, link all of prefix parent content, then remove the
20+
# prefix, then loop on the next prefix. This way, we basically create a copy of
21+
# the context around root/lib/rustlib/src, and can freely add/remove the src
22+
# component itself.
23+
all:
24+
mkdir $(FAKEROOT)
25+
ln -s $(SYSROOT)/* $(FAKEROOT)
26+
rm -f $(FAKEROOT)/lib
27+
mkdir $(FAKEROOT)/lib
28+
ln -s $(SYSROOT)/lib/* $(FAKEROOT)/lib
29+
rm -f $(FAKEROOT)/lib/rustlib
30+
mkdir $(FAKEROOT)/lib/rustlib
31+
ln -s $(SYSROOT)/lib/rustlib/* $(FAKEROOT)/lib/rustlib
32+
rm -f $(FAKEROOT)/lib/rustlib/src
33+
mkdir $(FAKEROOT)/lib/rustlib/src
34+
ln -s $(SYSROOT)/lib/rustlib/src/* $(FAKEROOT)/lib/rustlib/src
35+
rm -f $(FAKEROOT)/lib/rustlib/src/rust
36+
$(RUSTC) --sysroot $(FAKEROOT) -C incremental=$(INCR) main.rs
37+
mkdir -p $(FAKEROOT)/lib/rustlib/src/rust/src/libstd
38+
touch $(FAKEROOT)/lib/rustlib/src/rust/src/libstd/lib.rs
39+
$(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)