From bdbac006dc27d75202fea5ccb1141b3bcae3a9dd Mon Sep 17 00:00:00 2001
From: Michael Sullivan <sully@msully.net>
Date: Thu, 21 Jul 2011 16:11:35 -0700
Subject: [PATCH] Build the stage1 compiler against the newly built librustrt.

---
 mk/stage0.mk            | 17 +++++------------
 mk/stageN.mk            | 18 ++++++++++--------
 src/etc/get-snapshot.py |  2 +-
 src/etc/snapshot.py     |  8 --------
 src/snapshots.txt       |  5 +++++
 5 files changed, 21 insertions(+), 29 deletions(-)

diff --git a/mk/stage0.mk b/mk/stage0.mk
index c125e4a9faf..2d0b9fe3c6c 100644
--- a/mk/stage0.mk
+++ b/mk/stage0.mk
@@ -1,5 +1,5 @@
-# FIXME: temporary hack: stdlib comes in the lib/ directory, but we want it in
-# the base directory, so we move it out.
+# FIXME: temporary hack: stdlib and rustrt come in the lib/ directory,
+# but we want them in the base directory, so we move them out.
 stage0/rustc$(X): $(S)src/snapshots.txt $(S)src/etc/get-snapshot.py $(MKFILES)
 	@$(call E, fetch: $@)
 	$(Q)$(S)src/etc/get-snapshot.py
@@ -8,11 +8,8 @@ stage0/rustc$(X): $(S)src/snapshots.txt $(S)src/etc/get-snapshot.py $(MKFILES)
 
 # Host libs will be made in the process of making rustc above.
 
-# FIXME: temporary hack: the runtime is currently carried in
-# lib/ directory only, so we copy it out.
-
-stage0/$(CFG_RUNTIME): stage0/lib/$(CFG_RUNTIME)
-	$(Q)cp $< $@
+stage0/$(CFG_RUNTIME): stage0/rustc$(X)
+	$(Q)touch $@
 
 stage0/$(CFG_STDLIB): stage0/rustc$(X)
 	$(Q)touch $@
@@ -31,12 +28,8 @@ stage0/lib/glue.o: stage0/rustc$(X)
 stage0/lib/main.o: rt/main.o
 	$(Q)cp $< $@
 
-
-stage0/lib/$(CFG_RUNTIME): stage0/rustc$(X)
-	$(Q)touch $@
-
 # Instantiate template (in stageN.mk) for building
 # stage0/lib/$(CFG_STDLIB) and stage0/lib/libstd.rlib.
 SREQpre = stage0/lib/main.o $(MKFILES)
-$(eval $(call STDLIBGEN,pre,0))
+$(eval $(call LIBGEN,pre,0))
 
diff --git a/mk/stageN.mk b/mk/stageN.mk
index eda991722dc..1338f1ae30f 100644
--- a/mk/stageN.mk
+++ b/mk/stageN.mk
@@ -3,10 +3,11 @@
 # The easiest way to read this template is to assume we're building stage2
 # using stage1, and mentally gloss $(1) as 1, $(2) as 2.
 #
-# STDLIBGEN is pulled out seperately because we need to specially invoke
-# it to build stage0/lib/libstd using stage0/rustc.
+# LIBGEN is pulled out seperately because we need to specially invoke
+# it to build stage0/lib/libstd using stage0/rustc and to use the
+# new rustrt in stage0/lib/.
 
-define STDLIBGEN
+define LIBGEN
 stage$(2)/lib/$$(CFG_STDLIB): $$(STDLIB_CRATE) $$(STDLIB_INPUTS) \
                               stage$(2)/rustc$$(X)               \
                               stage$(2)/$$(CFG_RUNTIME)          \
@@ -24,6 +25,11 @@ stage$(2)/lib/libstd.rlib: $$(STDLIB_CRATE) $$(STDLIB_INPUTS) \
                            $$(SREQ$(1))
 	@$$(call E, compile_and_link: $$@)
 	$$(STAGE$(2)) --lib --static -o $$@ $$<
+
+stage$(2)/lib/$$(CFG_RUNTIME): rt/$$(CFG_RUNTIME)
+	@$$(call E, cp: $$@)
+	$$(Q)cp $$< $$@
+
 endef
 
 define STAGEN
@@ -79,16 +85,12 @@ stage$(2)/lib/glue.o: stage$(2)/rustc$$(X)        \
 	@$$(call E, generate: $$@)
 	$$(STAGE$(2)) -c -o $$@ --glue
 
-$(eval $(call STDLIBGEN,$(1),$(2)))
+$(eval $(call LIBGEN,$(1),$(2)))
 
 stage$(2)/lib/main.o: rt/main.o
 	@$$(call E, cp: $$@)
 	$$(Q)cp $$< $$@
 
-stage$(2)/lib/$$(CFG_RUNTIME): rt/$$(CFG_RUNTIME)
-	@$$(call E, cp: $$@)
-	$$(Q)cp $$< $$@
-
 stage$(2)/lib/$$(CFG_LIBRUSTC): $$(COMPILER_CRATE) $$(COMPILER_INPUTS) \
                                 $$(SREQ$(2))
 	@$$(call E, compile_and_link: $$@)
diff --git a/src/etc/get-snapshot.py b/src/etc/get-snapshot.py
index aa64a4fb49a..98e480defda 100755
--- a/src/etc/get-snapshot.py
+++ b/src/etc/get-snapshot.py
@@ -9,7 +9,7 @@ def unpack_snapshot(snap):
   print("opening snapshot " + dl_path)
   tar = tarfile.open(dl_path)
   kernel = get_kernel()
-  for name in old_snapshot_files[kernel]:
+  for name in snapshot_files[kernel]:
     p = "rust-stage0/" + name
     fp = os.path.join("stage0", name)
     print("extracting " + fp)
diff --git a/src/etc/snapshot.py b/src/etc/snapshot.py
index 43742fddecf..88caf2789b1 100644
--- a/src/etc/snapshot.py
+++ b/src/etc/snapshot.py
@@ -23,14 +23,6 @@ snapshot_files = {
     "winnt": ["rustc.exe", "lib/glue.o", "lib/std.dll",
               "rustrt.dll", "rustllvm.dll", "lib/intrinsics.bc"]
     }
-old_snapshot_files = {
-    "linux": ["rustc", "lib/glue.o", "lib/libstd.so",
-              "lib/librustrt.so", "librustllvm.so", "lib/intrinsics.bc"],
-    "macos": ["rustc", "lib/glue.o", "lib/libstd.dylib",
-              "lib/librustrt.dylib", "librustllvm.dylib", "lib/intrinsics.bc"],
-    "winnt": ["rustc.exe", "lib/glue.o", "lib/std.dll",
-              "lib/rustrt.dll", "rustllvm.dll", "lib/intrinsics.bc"]
-    }
 
 def parse_line(n, line):
   global snapshotfile
diff --git a/src/snapshots.txt b/src/snapshots.txt
index b3a89a824ca..6e991d97e23 100644
--- a/src/snapshots.txt
+++ b/src/snapshots.txt
@@ -1,3 +1,8 @@
+S 2011-07-21 c62a9fe
+  linux-i386 3c8f658093adea1cb0e5b84150d3d342571013b4
+  macos-i386 1833b475fd1adec3df02ab3dd2fb7c6f280a33a5
+  winnt-i386 f6b6b42d00f25d82603b9466229d3229bfce3317
+
 S 2011-07-20 8a7f2e0
   linux-i386 c4881df0302a4a1e126a7ea847e1d7b4de49b943
   macos-i386 d5d486af50fade251fd04a24062385d67cfff30a