]> git.lizzy.rs Git - rust.git/commitdiff
More steps to arch-specific target libs (#474)
authorGraydon Hoare <graydon@mozilla.com>
Fri, 23 Sep 2011 17:50:06 +0000 (10:50 -0700)
committerGraydon Hoare <graydon@mozilla.com>
Fri, 23 Sep 2011 17:50:16 +0000 (10:50 -0700)
Makefile.in
configure
mk/stage0.mk
mk/stageN.mk
src/comp/driver/rustc.rs

index e74b4cb29e5b2d42f593521c6b1a1d5b682729d5..503a4a6d9f43f66d29728e32f0f7ce0b5d5a20e3 100644 (file)
@@ -13,6 +13,7 @@ endif
 
 CFG_INFO := $(info cfg: shell host triple $(CFG_HOST_TRIPLE))
 CFG_INFO := $(info cfg: llvm host triple $(CFG_LLVM_TRIPLE))
+CFG_INFO := $(info cfg: llvm target triples $(CFG_LLVM_TRIPLES))
 
 ifdef CFG_DISABLE_OPTIMIZE
   $(info cfg: disabling rustc optimization (CFG_DISABLE_OPTIMIZE))
index c4516c85a315c2fa33ec6aed2140e3e2ff951efc..881874abd70b3229b8a0e6faaebfc534d9db7dbf 100755 (executable)
--- a/configure
+++ b/configure
@@ -10,6 +10,10 @@ step_msg() {
     msg
 }
 
+warn() {
+    echo "configure: WARNING: $1"
+}
+
 err() {
     echo "configure: error: $1"
     exit 1
@@ -228,7 +232,6 @@ putvar CFG_SRC_DIR
 putvar CFG_BUILD_DIR
 putvar CFG_OSTYPE
 putvar CFG_CPUTYPE
-putvar CFG_HOST_TRIPLE
 putvar CFG_CONFIGURE_ARGS
 
 step_msg "looking for build programs"
@@ -335,6 +338,26 @@ then
 else
     CFG_C_COMPILER="gcc"
 fi
+
+if [ ! -z "$CFG_LLVM_TRIPLE" ]
+then
+    if [ $CFG_HOST_TRIPLE != $CFG_LLVM_TRIPLE ]
+    then
+        warn "LLVM host-triple $CFG_LLVM_TRIPLE differs from"
+        warn "detected host triple $CFG_HOST_TRIPLE"
+        warn "choosing LLVM host-triple instead"
+        msg ""
+        CFG_HOST_TRIPLE=$CFG_LLVM_TRIPLE
+    fi
+fi
+
+# FIXME: add support for extending the target-triples list
+CFG_TARGET_TRIPLES="${CFG_HOST_TRIPLE}"
+
+putvar CFG_HOST_TRIPLE
+putvar CFG_TARGET_TRIPLES
+
+
 putvar CFG_C_COMPILER
 
 putvar CFG_LLVM_ROOT
@@ -356,14 +379,31 @@ for i in \
     doc \
     rt rt/isaac rt/bigint rt/sync rt/test rt/arch/i386 \
     rt/libuv rt/libuv/src/ares rt/libuv/src/eio rt/libuv/src/ev \
-    rustllvm \
-    dl stage{0,1,2,3}{,/lib,/lib/$CFG_LLVM_TRIPLE} \
+    rustllvm dl \
     test/run-pass test/run-fail test/compile-fail \
     test/bench test/perf test/pretty
 do
     make_dir $i
 done
 
+for t in $CFG_TARGET_TRIPLES
+do
+    for i in 0 1 2 3
+    do
+        # old-style "bin" dir
+        make_dir stage$i
+
+        # new-style bin dir, not yet used
+        make_dir stage$i/bin
+
+        # old-style non-arch libs
+        make_dir stage$i/lib
+
+        # new-style arch-prefixed libs, not yet used
+        make_dir stage$i/lib/rustc/$t
+    done
+done
+
 copy ${CFG_SRC_DIR}Makefile.in ./Makefile
 
 copy ${CFG_SRC_DIR}src/rt/libuv/Makefile rt/libuv/Makefile
index c35fbfa3352eb9a52e1ccc6ee439c02ad758ab5c..9098c39d17cd171af8f4482620a951b058e3498d 100644 (file)
@@ -17,16 +17,9 @@ stage0/$(CFG_STDLIB): stage0/rustc$(X)
 stage0/$(CFG_RUSTLLVM): stage0/rustc$(X)
        $(Q)touch $@
 
-# Target libs will be made in the process of making rustc above.
-
-stage0/lib/glue.o: stage0/rustc$(X)
-       $(Q)touch $@
-
-stage0/lib/main.o: stage0/rustc$(X)
-       $(Q)touch $@
-
 # Instantiate template (in stageN.mk) for building
-# stage0/lib/$(CFG_STDLIB) and stage0/lib/libstd.rlib.
+# target libraries.
+
 SREQpre = stage0/lib/main.o $(MKFILES)
-$(eval $(call LIBGEN,pre,0))
+$(eval $(call TARGET_LIBS,pre,0,$(CFG_HOST_TRIPLE)))
 
index 868ac84e1fe2000895d6c212445407ee5794c125..cd83192129cf270d503a2e3ad5847fd855842cc5 100644 (file)
@@ -1,38 +1,15 @@
-# StageN template: arg 1 is the N we're building *from*, arg 2 is N+1.
+# STAGE_N template: arg 1 is the N we're building *from*, arg 2 is N+1, arg 3
+# is the target triple we're building for. You have to invoke this for each
+# target triple.
 #
 # 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.
 #
-# LIBGEN is pulled out seperately because we need to specially invoke
+# TARGET_LIBS 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 LIBGEN
-stage$(2)/lib/$$(CFG_STDLIB): $$(STDLIB_CRATE) $$(STDLIB_INPUTS) \
-                              stage$(2)/rustc$$(X)               \
-                              stage$(2)/$$(CFG_RUNTIME)          \
-                              stage$(2)/$$(CFG_RUSTLLVM)         \
-                              stage$(2)/lib/glue.o               \
-                              $$(SREQ$(1))
-       @$$(call E, compile_and_link: $$@)
-       $$(STAGE$(2))  --lib -o $$@ $$<
-
-stage$(2)/lib/libstd.rlib: $$(STDLIB_CRATE) $$(STDLIB_INPUTS) \
-                           stage$(2)/rustc$$(X)               \
-                           stage$(2)/$$(CFG_RUNTIME)          \
-                           stage$(2)/$$(CFG_RUSTLLVM)         \
-                           stage$(2)/lib/glue.o               \
-                           $$(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
+define STAGE_N
 
 # Host libraries and executables (stage$(2)/rustc and its runtime needs)
 #
@@ -74,9 +51,14 @@ stage$(2)/$$(CFG_RUSTLLVM): rustllvm/$$(CFG_RUSTLLVM)
        @$$(call E, cp: $$@)
        $$(Q)cp $$< $$@
 
+# Expand out target libraries
 
-# Target libraries (for binaries generated by stage$(2)/rustc)
+$(eval $(call TARGET_LIBS,$(1),$(2),$(3)))
 
+endef
+
+
+define TARGET_LIBS
 stage$(2)/lib/intrinsics.bc: $$(INTRINSICS_BC)
        @$$(call E, cp: $$@)
        $$(Q)cp $$< $$@
@@ -89,8 +71,6 @@ stage$(2)/lib/glue.o: stage$(2)/rustc$$(X)        \
        @$$(call E, generate: $$@)
        $$(STAGE$(2)) -c -o $$@ --glue
 
-$(eval $(call LIBGEN,$(1),$(2)))
-
 stage$(2)/lib/main.o: rt/main.o
        @$$(call E, cp: $$@)
        $$(Q)cp $$< $$@
@@ -100,10 +80,86 @@ stage$(2)/lib/$$(CFG_LIBRUSTC): $$(COMPILER_CRATE) $$(COMPILER_INPUTS) \
        @$$(call E, compile_and_link: $$@)
        $$(STAGE$(2)) --lib -o $$@ $$<
 
+stage$(2)/lib/$$(CFG_STDLIB): $$(STDLIB_CRATE) $$(STDLIB_INPUTS) \
+                              stage$(2)/rustc$$(X)               \
+                              stage$(2)/$$(CFG_RUNTIME)          \
+                              stage$(2)/$$(CFG_RUSTLLVM)         \
+                              stage$(2)/lib/glue.o               \
+                              $$(SREQ$(1))
+       @$$(call E, compile_and_link: $$@)
+       $$(STAGE$(2))  --lib -o $$@ $$<
+
+stage$(2)/lib/libstd.rlib: $$(STDLIB_CRATE) $$(STDLIB_INPUTS) \
+                           stage$(2)/rustc$$(X)               \
+                           stage$(2)/$$(CFG_RUNTIME)          \
+                           stage$(2)/$$(CFG_RUSTLLVM)         \
+                           stage$(2)/lib/glue.o               \
+                           $$(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 $$< $$@
+
+
+# New per-target-arch target libraries; when we've transitioned to
+# using these exclusively, you should delete the non-arch-prefixed
+# rules above. They're duplicates, redundant.
+
+stage$(2)/lib/rustc/$(3)/intrinsics.bc: $$(INTRINSICS_BC)
+       @$$(call E, cp: $$@)
+       $$(Q)cp $$< $$@
+
+stage$(2)/lib/rustc/$(3)/glue.o: \
+         stage$(2)/rustc$$(X)        \
+         stage$(2)/$$(CFG_RUNTIME)   \
+         stage$(2)/$$(CFG_RUSTLLVM)  \
+         stage$(2)/lib/intrinsics.bc \
+         $$(SREQ$(1))
+       @$$(call E, generate: $$@)
+       $$(STAGE$(2)) -c -o $$@ --glue
+
+stage$(2)/lib/rustc/$(3)/main.o: rt/main.o
+       @$$(call E, cp: $$@)
+       $$(Q)cp $$< $$@
+
+stage$(2)/lib/rustc/$(3)/$$(CFG_LIBRUSTC): \
+          $$(COMPILER_CRATE) $$(COMPILER_INPUTS) \
+          $$(SREQ$(2))
+       @$$(call E, compile_and_link: $$@)
+       $$(STAGE$(2)) --lib -o $$@ $$<
+
+stage$(2)/lib/rustc/$(3)/$$(CFG_STDLIB): \
+        $$(STDLIB_CRATE) $$(STDLIB_INPUTS) \
+        stage$(2)/rustc$$(X)               \
+        stage$(2)/$$(CFG_RUNTIME)          \
+        stage$(2)/$$(CFG_RUSTLLVM)         \
+        stage$(2)/lib/rustc/$(3)/glue.o     \
+        $$(SREQ$(1))
+       @$$(call E, compile_and_link: $$@)
+       $$(STAGE$(2))  --lib -o $$@ $$<
+
+stage$(2)/lib/rustc/$(3)/libstd.rlib: \
+        $$(STDLIB_CRATE) $$(STDLIB_INPUTS) \
+        stage$(2)/rustc$$(X)               \
+        stage$(2)/$$(CFG_RUNTIME)          \
+        stage$(2)/$$(CFG_RUSTLLVM)         \
+        stage$(2)/lib/rustc/$(3)/glue.o     \
+        $$(SREQ$(1))
+       @$$(call E, compile_and_link: $$@)
+       $$(STAGE$(2)) --lib --static -o $$@ $$<
+
+stage$(2)/lib/rustc/$(3)/$$(CFG_RUNTIME): rt/$$(CFG_RUNTIME)
+       @$$(call E, cp: $$@)
+       $$(Q)cp $$< $$@
+
 endef
 
-# Instantiate template for 0->1, 1->2, 2->3 build dirs
 
-$(eval $(call STAGEN,0,1))
-$(eval $(call STAGEN,1,2))
-$(eval $(call STAGEN,2,3))
+
+# Instantiate template for 0->1, 1->2, 2->3 build dirs
+$(foreach target,$(CFG_TARGET_TRIPLES), \
+ $(eval $(call STAGE_N,0,1,$(target)))   \
+ $(eval $(call STAGE_N,1,2,$(target)))   \
+ $(eval $(call STAGE_N,2,3,$(target))))
index 9ed221953f0d3bb821de9c5d877ebe4c5058ceb2..b1f7fa84f42a22275e1433a134ebcfb3f3b8332c 100644 (file)
@@ -372,7 +372,7 @@ fn build_session_options(binary: str, match: getopts::match, binary_dir: str)
         };
 
     let library_search_paths = [binary_dir + "/lib", // FIXME: legacy
-                                binary_dir + "/lib/" + target ];
+                                binary_dir + "/lib/rustc/" + target ];
     let lsp_vec = getopts::opt_strs(match, "L");
     for lsp: str in lsp_vec { library_search_paths += [lsp]; }