|
| 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 |
0 commit comments