From 5e40aa6aa362aab3808bfa7caebb97edf6d33258 Mon Sep 17 00:00:00 2001 From: Brian Anderson Date: Wed, 9 Jan 2013 18:52:17 -0800 Subject: [PATCH] Use the in-tree Rust compiler --- Makefile.in | 8 +++--- README.md | 18 +++---------- configure | 77 ++++++++++++++++++++++++++++++++++++++++++++++++----- mk/sub.mk | 4 +-- 4 files changed, 80 insertions(+), 27 deletions(-) diff --git a/Makefile.in b/Makefile.in index 1540abf8e3f..d7a74b16a21 100644 --- a/Makefile.in +++ b/Makefile.in @@ -46,7 +46,6 @@ else CFG_GCCISH_CFLAGS += -DRUST_NDEBUG endif - export CFG_RUSTC export CFG_RUSTC_FLAGS export RUSTC=$(CFG_RUSTC) @@ -75,6 +74,9 @@ $(S)config.stamp : $(S)configure $(S)Makefile.in @$(call E, cfg: reconfiguring) $(Q)$(S)configure $(CFG_CONFIGURE_ARGS) +# Build the compiler +$(CFG_RUSTC): + $(MAKE) -C "$(CFG_BUILD_DIR)src/rust" CFG_RUSTC_FLAGS="" RUSTFLAGS="" define DEF_SUBMODULE_VARS DEPS_$(1) = @@ -109,7 +111,7 @@ ROUGH_DEPS_$(1)=$$(call rwildcard,$$(S)src/$(1),*h *c *cpp *rs *rc) DONE_DEPS_$(1)=$$(foreach dep,$$(DEPS_$(1)),$$(DONE_$$(dep))) # the main target for a submodule # -- -$$(DONE_$(1)) : $$(DONE_DEPS_$(1)) $$(ROUGH_DEPS_$(1)) +$$(DONE_$(1)) : $$(DONE_DEPS_$(1)) $$(ROUGH_DEPS_$(1)) $$(CFG_RUSTC) # @$$(call E, make: $(1)) # @$$(call E, $(1) deps= $$(DEPS_$(1))) # @$$(call E, $(1) done_deps= $$(DONE_DEPS_$(1))) @@ -165,7 +167,7 @@ servo: $(DEPS_servo) # Darwin app packaging -ifeq ($(OSTYPE),darwin) +ifeq ($(OSTYPE),apple-darwin) package: servo mkdir -p Servo.app/Contents/MacOS/src/rust-cocoa diff --git a/README.md b/README.md index c4f9fa72db0..945dda2b9e8 100644 --- a/README.md +++ b/README.md @@ -3,20 +3,8 @@ Servo is a prototype web browser engine written in the [Rust] language. It is currently developed on OS X and Linux. -**Note:** Servo always requires a specific version of Rust - building -against a released version of Rust will not work, nor will the Rust -'master' branch. The commit below will *probably* work. If it does not -then the topic in #servo might know better. - -* Last known-good Rust commit: 3ee1d3ebb81de199fc630a86933ac18c0a869482 - -[rust]: http://www.rust-lang.org - ## Prerequisites -First, you need the Rust compiler, built from the exact commit listed -above. - On OS X (homebrew): brew install https://raw.github.com/Homebrew/homebrew-versions/master/autoconf213.rb @@ -30,6 +18,9 @@ On Debian-based Linuxes: sudo apt-get install libcairo2-dev libpango1.0-dev autoconf2.13 freeglut3-dev +Servo builds its own copy of Rust, so there is no need to provide a Rust +compiler. + ## Building git clone git://github.com/mozilla/servo.git @@ -39,9 +30,6 @@ On Debian-based Linuxes: make check-servo && make ./servo ../src/test/hello.html -If `rustc` is not installed then add `RUSTC=/path/to/rustc` to your -`make` commands. - ## Build Workarounds diff --git a/configure b/configure index f998e739a4a..7488cddcdaa 100755 --- a/configure +++ b/configure @@ -199,28 +199,65 @@ need_cmd sed msg "inspecting environment" CFG_OSTYPE=$(uname -s) +CFG_CPUTYPE=$(uname -m) + +if [ $CFG_OSTYPE = Darwin -a $CFG_CPUTYPE = i386 ] +then + # Darwin's `uname -s` lies and always returns i386. We have to use sysctl + # instead. + if sysctl hw.optional.x86_64 | grep -q ': 1' + then + CFG_CPUTYPE=x86_64 + fi +fi + +# The goal here is to come up with the same triple as LLVM would, +# at least for the subset of platforms we're willing to target. + case $CFG_OSTYPE in + Linux) - CFG_OSTYPE=linux + CFG_OSTYPE=unknown-linux-gnu ;; FreeBSD) - CFG_OSTYPE=freebsd + CFG_OSTYPE=unknown-freebsd ;; Darwin) - CFG_OSTYPE=darwin + CFG_OSTYPE=apple-darwin ;; MINGW32*) - CFG_OSTYPE=mingw32 + CFG_OSTYPE=pc-mingw32 ;; + *) err "unknown OS type: $CFG_OSTYPE" ;; esac +case $CFG_CPUTYPE in + + i386 | i486 | i686 | i786 | x86) + CFG_CPUTYPE=i686 + ;; + + xscale | arm) + CFG_CPUTYPE=arm + ;; + + x86_64 | x86-64 | x64 | amd64) + CFG_CPUTYPE=x86_64 + ;; + + *) + err "unknown CPU type: $CFG_CPUTYPE" +esac + +DEFAULT_HOST_TRIPLE="${CFG_CPUTYPE}-${CFG_OSTYPE}" + CFG_SRC_DIR="$(cd $(dirname $0) && pwd)/" CFG_BUILD_DIR="$(pwd)/" CFG_SELF=${CFG_SRC_DIR}$(basename $0) @@ -271,7 +308,9 @@ if [ ! -z "$CFG_LOCAL_RUST_ROOT" ] then if [ ! -f ${CFG_LOCAL_RUST_ROOT}/bin/rustc ] then - err "no local rust to use" + msg "using in-tree rust compiler" + # The Rust compiler we're going to build + CFG_RUSTC="${CFG_BUILD_DIR}src/rust/${DEFAULT_HOST_TRIPLE}/stage2/bin/rustc" else LRV=`${CFG_LOCAL_RUST_ROOT}/bin/rustc --version` step_msg "using rustc at: ${CFG_LOCAL_RUST_ROOT} with version: " $LRV @@ -346,12 +385,12 @@ step_msg "running submodule autoconf scripts" CFG_SUBMODULES="libwapcaplet rust-wapcaplet rust-harfbuzz rust-opengles skia rust-azure rust-cairo rust-stb-image rust-geom rust-glut rust-layers rust-http-client libparserutils libhubbub libcss rust-netsurfcss rust-css rust-hubbub sharegl rust-mozjs mozjs" -if [ $CFG_OSTYPE = "darwin" ] +if [ $CFG_OSTYPE = "apple-darwin" ] then CFG_SUBMODULES="rust-cocoa rust-io-surface rust-core-foundation rust-core-graphics rust-core-text ${CFG_SUBMODULES}" fi -if [ $CFG_OSTYPE = "linux" ] +if [ $CFG_OSTYPE = "unknown-linux-gnu" ] then CFG_SUBMODULES="rust-freetype rust-fontconfig rust-xlib ${CFG_SUBMODULES}" fi @@ -367,11 +406,33 @@ done make_dir ${CFG_BUILD_DIR}src/servo-gfx make_dir src/test/ref +make_dir src/rust # TODO: don't run configure on submodules unless necessary. For an example, # see how Rust's configure script optionally reconfigures the LLVM module. step_msg "running submodule configure scripts" +# Only reconfigure Rust when it changes +do_reconfigure=1 +index1="${CFG_SRC_DIR}.git/modules/src/rust/index" +index2="${CFG_SRC_DIR}src/rust/.git/index" +for index in ${index1} ${index2} +do + config_stamp="${CFG_BUILD_DIR}src/rust/config.stamp" + if test -e ${index} -a -e ${config_stamp} -a ${config_stamp} -nt ${index} + then + msg "not reconfiguring Rust, config.stamp is fresh" + do_reconfigure=0 + fi +done + +if [ ${do_reconfigure} -ne 0 ] +then + cd ${CFG_BUILD_DIR}src/rust + ${CFG_SRC_DIR}src/rust/configure + cd ${CFG_BUILD_DIR} +fi + for i in ${CFG_SUBMODULES} do if [ -d ${CFG_BUILD_DIR}src/${i} ] @@ -398,6 +459,8 @@ done step_msg "writing configuration" +putvar DEFAULT_HOST_TRIPLE +putvar CFG_CPUTYPE putvar CFG_OSTYPE putvar CFG_SRC_DIR putvar CFG_BUILD_DIR diff --git a/mk/sub.mk b/mk/sub.mk index ac1206fed61..e7c83fd87fe 100644 --- a/mk/sub.mk +++ b/mk/sub.mk @@ -82,7 +82,7 @@ DEPS_libcss += \ $(NULL) # Platform-specific dependencies -ifeq ($(CFG_OSTYPE),darwin) +ifeq ($(CFG_OSTYPE),apple-darwin) DEPS_rust-azure += \ rust-core-graphics \ rust-core-text \ @@ -121,7 +121,7 @@ DEPS_rust-layers += \ endif -ifeq ($(CFG_OSTYPE),linux) +ifeq ($(CFG_OSTYPE),unknown-linux-gnu) DEPS_rust-cairo += \ rust-freetype \