From 243c5c34790eaba815c2786009b10c31bc04c63d Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Thu, 20 Oct 2011 10:55:53 +0200 Subject: [PATCH] Use snap runtime, and the old main.o, for stage1 This is intended to be reverted again after I register the next snapshot. --- mk/rt.mk | 6 ++++++ mk/target.mk | 18 ++++++++++++++---- src/rt/main0.ll.in | 43 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 63 insertions(+), 4 deletions(-) create mode 100644 src/rt/main0.ll.in diff --git a/mk/rt.mk b/mk/rt.mk index 414384f0821..3adb27d82e3 100644 --- a/mk/rt.mk +++ b/mk/rt.mk @@ -106,10 +106,16 @@ ifdef CFG_WINDOWSY rt/main.ll: rt/main.ll.in @$(call E, sed: $@) $(Q)sed 's/MAIN/WinMain@16/' < $^ > $@ +rt/main0.ll: rt/main0.ll.in + @$(call E, sed: $@) + $(Q)sed 's/MAIN/WinMain@16/' < $^ > $@ else rt/main.ll: rt/main.ll.in @$(call E, sed: $@) $(Q)sed 's/MAIN/main/' < $^ > $@ +rt/main0.ll: rt/main0.ll.in + @$(call E, sed: $@) + $(Q)sed 's/MAIN/main/' < $^ > $@ endif rt/%.o: rt/%.ll $(MKFILES) diff --git a/mk/target.mk b/mk/target.mk index ccbfba24383..f52d72f75e2 100644 --- a/mk/target.mk +++ b/mk/target.mk @@ -11,10 +11,6 @@ $$(TARGET_LIB$(1)$(2))/intrinsics.bc: $$(INTRINSICS_BC) @$$(call E, cp: $$@) $$(Q)cp $$< $$@ -$$(TARGET_LIB$(1)$(2))/main.o: rt/main.o - @$$(call E, cp: $$@) - $$(Q)cp $$< $$@ - $$(TARGET_LIB$(1)$(2))/$$(CFG_STDLIB): \ $$(STDLIB_CRATE) $$(STDLIB_INPUTS) \ $$(TARGET_SREQ$(1)$(2)) @@ -27,9 +23,23 @@ $$(TARGET_LIB$(1)$(2))/libstd.rlib: \ @$$(call E, compile_and_link: $$@) $$(STAGE$(1)) --lib --static -o $$@ $$< +ifeq ($(1), 0) +$$(TARGET_LIB$(1)$(2))/main.o: rt/main0.o + @$$(call E, cp: $$@) + $$(Q)cp $$< $$@ + +$$(TARGET_LIB$(1)$(2))/$$(CFG_RUNTIME): stage0/lib/$$(CFG_RUNTIME) + @$$(call E, cp: $$@) + $$(Q)cp $$< $$@ +else +$$(TARGET_LIB$(1)$(2))/main.o: rt/main.o + @$$(call E, cp: $$@) + $$(Q)cp $$< $$@ + $$(TARGET_LIB$(1)$(2))/$$(CFG_RUNTIME): rt/$$(CFG_RUNTIME) @$$(call E, cp: $$@) $$(Q)cp $$< $$@ +endif $$(TARGET_LIB$(1)$(2))/$$(CFG_RUSTLLVM): rustllvm/$$(CFG_RUSTLLVM) @$$(call E, cp: $$@) diff --git a/src/rt/main0.ll.in b/src/rt/main0.ll.in new file mode 100644 index 00000000000..6b0454cc31f --- /dev/null +++ b/src/rt/main0.ll.in @@ -0,0 +1,43 @@ +%0 = type { i32, [1 x i32] } +%1 = type { i32, i32 } +%2 = type { i32, %3 } +%3 = type { %tydesc*, %4, i1, {} } +%4 = type { i1*, i1* } +%5 = type { i32, i32, i32, i32, [0 x %6*] } +%6 = type { i32, i32, i32, i32, [0 x i8] } + +%tydesc = type { %tydesc**, i32, i32, void (i1*, %task*, i1*, %tydesc**, i8*)*, void (i1*, %task*, i1*, %tydesc**, i8*)*, void (i1*, %task*, i1*, %tydesc**, i8*)*, void (i1*, %task*, i1*, %tydesc**, i8*)*, void (i1*, %task*, i1*, %tydesc**, i8*)*, void (i1*, %task*, i1*, %tydesc**, i8*)*, void (i1*, %task*, i1*, %tydesc**, i8*)*, void (i1*, %task*, i1*, %tydesc**, i8*, i8*, i8)* } + +%task = type { i32, i32, i32, i32, i32, i32, i32, i32 } + +%vec = type { i32, i32, [0 x i8] } + +@_rust_crate_map_toplevel = external global %0 + +declare i32 @rust_start(i32, i32, i32, i32) + +declare external fastcc void @_rust_main(i1* nocapture, %task*, %2* nocapture, %vec*) + +define void @_rust_main_wrap(i1* nocapture, %task *, %2* nocapture, %vec *) +{ + tail call fastcc void @_rust_main(i1* %0, %task *%1, %2* nocapture %2, %vec* %3) + ret void +} + +%nullary_fn = type void (i1*, %task*, %2*) + +define void @_rust_spawn_wrap( + i1* nocapture, %task*, %2* nocapture, %nullary_fn* %f) +{ + call void %f(i1* %0, %task *%1, %2* nocapture %2) + ret void +} + +declare external void @set_spawn_wrapper(void (i1*, %task*, %2*, %nullary_fn*)*); + +define i32 @"MAIN"(i32, i32) { + call void @set_spawn_wrapper(void (i1*, %task*, %2*, %nullary_fn*)* @_rust_spawn_wrap) + + %result = tail call i32 @rust_start(i32 ptrtoint (void (i1*, %task*, %2*, %vec*)* @_rust_main_wrap to i32), i32 %0, i32 %1, i32 ptrtoint (%0* @_rust_crate_map_toplevel to i32)) + ret i32 %result +}