Skip to content

Commit

Permalink
Enable 32bit builds.
Browse files Browse the repository at this point in the history
You specify a 32bit build by setting --target on configure.
  • Loading branch information
metajack committed Aug 14, 2014
1 parent 8e59706 commit 9a75a0f
Show file tree
Hide file tree
Showing 18 changed files with 114 additions and 48 deletions.
47 changes: 32 additions & 15 deletions Makefile.in
Expand Up @@ -49,6 +49,12 @@ endif
# https://github.com/rust-lang/rust/issues/16140
CFG_RUSTC_FLAGS += --extern url=$(B)/src/support/url/rust-url/liburl.rlib

# Handle target
TARGET_FLAGS = --target $(CFG_TARGET)
ifeq ($(CFG_OSTYPE),linux-androideabi)
TARGET_FLAGS += -C linker=$(CFG_ANDROID_CROSS_PATH)/bin/arm-linux-androideabi-g++ -C ar=$(CFG_ANDROID_CROSS_PATH)/bin/arm-linux-androideabi-ar
endif

export CFG_RUSTC
export CFG_RUSTC_FLAGS
export CFG_LOCAL_RUSTC
Expand Down Expand Up @@ -112,11 +118,6 @@ $(B)src/compiler/rust/rust-auto-clean-stamp: $(S)src/compiler/rust-auto-clean-tr

rust: $(CFG_RUSTC)

# These arguments are automatically provided by the Rust compiler's build process to
# itself, so they must be specified later for our Rust modules.
ifeq ($(CFG_OSTYPE),linux-androideabi)
CFG_RUSTC_FLAGS += --target arm-linux-androideabi -C linker=$(CFG_ANDROID_CROSS_PATH)/bin/arm-linux-androideabi-g++ -C ar=$(CFG_ANDROID_CROSS_PATH)/bin/arm-linux-androideabi-ar
endif

# Set up LD_LIBRARY_PATH os the compiler can find libraries
ifeq ($(CFG_OSTYPE),apple-darwin)
Expand All @@ -137,12 +138,17 @@ define DEF_SUBMODULE_VARS
#defaults
DEPS_$(1) =
CFLAGS_$(1) = -O2
CXXFLAGS_$(1) =

#if global cflags set, inherit that
ifdef CFLAGS
CFLAGS_$(1) = $$(CFLAGS)
endif

ifdef CXXFLAGS
CXXFLAGS_$(1) = $$(CXXFLAGS)
endif

# any "done" dummy files must be named libSOMETHING.dummy.
#
# We can't auto-compute this, because some modules have lib* prefix in
Expand Down Expand Up @@ -176,14 +182,20 @@ endef
# Define how to make submodule targets
define DEF_SUBMODULE_RULES

ENV_RLDFLAGS_$(1) = -L $$(CFG_BUILD_HOME)workspace/lib/$$(CFG_TARGET)
ENV_RLDFLAGS_$(1) += $$(foreach dep,$$(DEPS_$(1)),-L $$(B)src/$$(PATH_$$(dep)) -L $$(B)src/$$(PATH_$$(dep))/.libs -L $$(B)src/$$(PATH_$$(dep))/src/.libs)

# variables that depend on dependency definitions from sub.mk!
ENV_CFLAGS_$(1) = CFLAGS="$$(CFLAGS_$(1))"
ENV_RFLAGS_$(1) = RUSTFLAGS="$$(strip $$(CFG_RUSTC_FLAGS)) $$(ENV_RLDFLAGS_$(1))"
ENV_CXXFLAGS_$(1) = CXXFLAGS="$$(CXXFLAGS_$(1))"
ENV_EXT_DEPS_$(1) = EXT_DEPS="$$(DONE_DEPS_$(1))"

# Some submodules should not be cross compiled
ifeq "$$(filter $(1),$$(NO_CROSS_BUILDS))" "$(1)"
ENV_RFLAGS_$(1) = RUSTFLAGS="$$(strip $$(CFG_RUSTC_FLAGS) $$(ENV_RLDFLAGS_$(1)))"
else
ENV_RFLAGS_$(1) = RUSTFLAGS="$$(strip $$(CFG_RUSTC_FLAGS) $$(ENV_RLDFLAGS_$(1)) $$(TARGET_FLAGS))"
endif

# Native builds do not depend on the rust compiler, so we can build them in parallel with rustc
RUSTC_DEP_$(1)=
ifneq "$$(filter $(1),$$(NATIVE_BUILDS))" "$(1)"
Expand All @@ -192,8 +204,13 @@ endif

$(eval $(call DEF_SUBMODULE_DEPS,$(1)))

ifeq ($(CFG_CPUTYPE),i686)
CROSS_COMPILER_CC = CC='$(CFG_CC) -m32'
CROSS_COMPILER_CXX = CXX='$(CFG_CXX) -m32'
else
CROSS_COMPILER_CC = CC=$(CFG_CC)
CROSS_COMPILER_CXX = CXX=$(CFG_CXX)
endif
CROSS_COMPILER_LD = LD=$(CFG_LD)
CROSS_COMPILER_AR = AR=$(CFG_AR)

Expand All @@ -209,10 +226,10 @@ $$(DONE_$(1)) : $$(DONE_DEPS_$(1)) $$(ROUGH_DEPS_$(1)) $$(RUSTC_DEP_$(1))
$$(ENV_CXXFLAGS_$(1)) \
$$(ENV_RFLAGS_$(1)) \
$$(ENV_EXT_DEPS_$(1)) \
$$(CROSS_COMPILER_CC) \
$$(CROSS_COMPILER_CXX) \
$$(CROSS_COMPILER_LD) \
$$(CROSS_COMPILER_AR) \
$$(CROSS_COMPILER_CC) \
$$(CROSS_COMPILER_CXX) \
$$(CROSS_COMPILER_LD) \
$$(CROSS_COMPILER_AR) \
$$(MAKE) -C $$(B)src/$$(PATH_$(1)) && touch $$(DONE_$(1))

# main submodule target
Expand Down Expand Up @@ -339,7 +356,7 @@ include $(S)mk/clean.mk
define DEF_LIB_CRATE_RULES
$$(DONE_$(1)): $$(DEPS_$(1))
@$$(call E, compile: $$@)
$$(Q)$$(RUSTC) $(strip $(CFG_RUSTC_FLAGS)) $$(RFLAGS_$(1)) --out-dir $$(B)src/components/$(1) $$< && touch $$@
$$(Q)$$(RUSTC) $(strip $(TARGET_FLAGS) $(CFG_RUSTC_FLAGS)) $$(RFLAGS_$(1)) --out-dir $$(B)src/components/$(1) $$< && touch $$@
endef

$(foreach lib_crate,$(SERVO_LIB_CRATES),\
Expand Down Expand Up @@ -389,7 +406,7 @@ ifneq ($(CFG_OSTYPE),linux-androideabi)
all: servo servo-embedding
servo: $(DEPS_servo)
@$(call E, compile: $@)
$(Q)$(RUSTC) $(strip $(CFG_RUSTC_FLAGS)) $(RFLAGS_servo) $< --crate-type bin,dylib,rlib
$(Q)$(RUSTC) $(strip $(TARGET_FLAGS) $(CFG_RUSTC_FLAGS)) $(RFLAGS_servo) $< --crate-type bin,dylib,rlib

RFLAGS_embedding = $(addprefix -L $(B)src/,$(DEPS_SUBMODULES)) -L $(B)src/components/gfx -L $(B)src/components/util -L $(B)src/components/net -L $(B)src/components/script -L $(B)src/components/layout -L $(B)src/components/layout_traits -L $(B)src/components/script_traits -L $(B)src/components/compositing -L $(B)src/components/style -L $(B)src/components/msg -L $(B).. -L $(B)src/components/main -L $(B)src/components/macros -A non_camel_case_types -A unused_variable

Expand All @@ -401,13 +418,13 @@ CRATE_embedding = $(S)src/components/embedding/embedding.rs

servo-embedding: servo $(SRC_embedding) $(CRATE_embedding)
@$(call E, compile: $@)
$(Q)$(RUSTC) $(strip $(CFG_RUSTC_FLAGS)) $(RFLAGS_embedding) $(CRATE_embedding) --crate-type dylib,rlib
$(Q)$(RUSTC) $(strip $(TARGET_FLAGS) $(CFG_RUSTC_FLAGS)) $(RFLAGS_embedding) $(CRATE_embedding) --crate-type dylib,rlib
touch servo-embedding
else
all: servo
servo: $(DEPS_servo)
@$(call E, compile: $@)
$(Q)$(RUSTC) $(strip $(CFG_RUSTC_FLAGS)) $(RFLAGS_servo) $< -o libservo.so --crate-type dylib
$(Q)$(RUSTC) $(strip $(TARGET_FLAGS) $(CFG_RUSTC_FLAGS)) $(RFLAGS_servo) $< -o libservo.so --crate-type dylib
touch servo
endif

Expand Down
64 changes: 52 additions & 12 deletions configure
Expand Up @@ -104,6 +104,35 @@ probe() {
putvar $V "$VER"
}

probe_ext() {
local V=$1
local E=$2
shift 2
local P
local T
for P
do
T=$(which $P 2>&1)
if [ $? -eq 0 ]
then
VER0=$($P --version 2>/dev/null | head -1 \
| sed -e 's/[^0-9]*\([vV]\?[0-9.]\+[^ ]*\).*/\1/' )
if [ $? -eq 0 -a "x${VER0}" != "x" ]
then
VER="($VER0)"
else
VER=""
fi
break
else
VER=""
T=""
fi
done
eval $V="'$T $E'"
putvar $V "$VER"
}

probe_need() {
local V=$1
probe $*
Expand Down Expand Up @@ -394,8 +423,13 @@ case ${TARGET_OSTYPE} in
;;
*)
CFG_PATH=$PATH
probe CFG_CC gcc
probe CFG_CXX g++
if [ "$CFG_CPUTYPE" = "i686" ]; then
probe_ext CFG_CC -m32 gcc
probe_ext CFG_CXX -m32 g++
else
probe CFG_CC gcc
probe CFG_CXX g++
fi
probe CFG_LD ld
probe CFG_AR ar
probe CFG_RANLIB ranlib
Expand Down Expand Up @@ -655,9 +689,9 @@ done
if [ -z "$CFG_LOCAL_RUST_ROOT" -a ${do_reconfigure} -ne 0 ]
then
cd ${CFG_BUILD_DIR}src/compiler/rust
RUST_CONFIGURE_ARGS="--enable-debug"
RUST_CONFIGURE_ARGS="--target=${CFG_TARGET} --enable-debug"
if [ $CFG_OSTYPE = "linux-androideabi" ]; then
RUST_CONFIGURE_ARGS="--target=arm-linux-androideabi --android-cross-path=${CFG_ANDROID_CROSS_PATH}"
RUST_CONFIGURE_ARGS="${RUST_CONFIGURE_ARGS} --android-cross-path=${CFG_ANDROID_CROSS_PATH}"
fi
${CFG_SRC_DIR}src/compiler/rust/configure ${RUST_CONFIGURE_ARGS}
cd ${CFG_BUILD_DIR}
Expand All @@ -680,7 +714,7 @@ then
fi

# cross compile configurations
EXTRA_CONFIGURE_ARGS="CC=${CFG_CC} CXX=${CFG_CXX} LD=${CFG_LD} AR=${CFG_AR} RANLIB=${CFG_RANLIB}"
EXTRA_CONFIGURE_ARGS="CC=\"${CFG_CC}\" CXX=\"${CFG_CXX}\" LD=${CFG_LD} AR=${CFG_AR} RANLIB=${CFG_RANLIB} CFLAGS=\"${CFLAGS}\" CXXFLAGS=\"${CXXFLAGS}\""

for i in ${CFG_SUBMODULES}
do
Expand All @@ -697,13 +731,11 @@ do
CONFIGURE_SCRIPT="${CFG_SRC_DIR}src/${i}/expat/configure"
CONFIGURE_ARGS="${CONFIGURE_ARGS} --host=arm-linux-androideabi"
CONFIGURE_ARGS="${CONFIGURE_ARGS} --with-sysroot=${CFG_ANDROID_CROSS_PATH}/sysroot"
CONFIGURE_ARGS="${CONFIGURE_ARGS} ${EXTRA_CONFIGURE_ARGS}"
;;
platform/android/libfreetype2)
CONFIGURE_ARGS="${CONFIGURE_ARGS} --host=arm-linux"
CONFIGURE_ARGS="${CONFIGURE_ARGS} --with-sysroot=${CFG_ANDROID_CROSS_PATH}/sysroot"
CONFIGURE_ARGS="${CONFIGURE_ARGS} --without-zlib"
CONFIGURE_ARGS="${CONFIGURE_ARGS} ${EXTRA_CONFIGURE_ARGS}"
;;
platform/linux/fontconfig)
CONFIGURE_SCRIPT="${CFG_SRC_DIR}src/${i}/autogen.sh"
Expand All @@ -716,7 +748,8 @@ do
# pkg-config files for expat: https://bugzilla.redhat.com/show_bug.cgi?id=833338
CONFIGURE_ARGS="${CONFIGURE_ARGS} --with-expat=/usr"
fi
CONFIGURE_ARGS="${CONFIGURE_ARGS} ${EXTRA_CONFIGURE_ARGS}"
# --enable-debug isn't supported by fontconfig
ENABLE_DEBUG=
;;
platform/android/fontconfig)
CONFIGURE_SCRIPT="${CFG_SRC_DIR}src/${i}/autogen.sh"
Expand All @@ -728,13 +761,19 @@ do
CONFIGURE_ARGS="${CONFIGURE_ARGS} --with-cache-dir=${CFG_ANDROID_RESOURCE_PATH}/.fccache"
CONFIGURE_ARGS="${CONFIGURE_ARGS} --with-confdir=${CFG_ANDROID_RESOURCE_PATH}/.fcconfig"
CONFIGURE_ARGS="${CONFIGURE_ARGS} --with-default-fonts=${CFG_ANDROID_FONT_PATH}"
CONFIGURE_ARGS="${CONFIGURE_ARGS} ${EXTRA_CONFIGURE_ARGS}"
# --enable-debug isn't supported by fontconfig
ENABLE_DEBUG=
;;
support/spidermonkey/mozjs)
# needed because Spidermonkey configure is in non-standard location
CONFIGURE_SCRIPT="${CFG_SRC_DIR}src/${i}/js/src/configure"
CONFIGURE_SCRIPT="${CFG_SRC_DIR}src/${i}/js/src/configure"
if [ ! ${DEFAULT_TARGET} = ${CFG_TARGET} ]; then
# Only pass --target if different from the build host because
# spidermonkey will trigger a cross compile even on minor
# differences here.
CONFIGURE_ARGS="${CONFIGURE_ARGS} --target=${CFG_TARGET}"
fi
if [ ${CFG_OSTYPE} = "linux-androideabi" ]; then
CONFIGURE_ARGS="${CONFIGURE_ARGS} --target=arm-linux-androideabi"
CONFIGURE_ARGS="${CONFIGURE_ARGS} --with-android-ndk=${CFG_ANDROID_NDK_PATH}"
CONFIGURE_ARGS="${CONFIGURE_ARGS} --with-android-toolchain=${CFG_ANDROID_CROSS_PATH}"
fi
Expand Down Expand Up @@ -768,12 +807,13 @@ do
;;
esac


if [ -n "$ENABLE_DEBUG" ]; then
CONFIGURE_ARGS="${CONFIGURE_ARGS} --enable-debug"
fi

if [ -f ${CONFIGURE_SCRIPT} ]; then
(sh ${CONFIGURE_SCRIPT} ${CONFIGURE_ARGS}) || exit $?
(sh -c "${EXTRA_CONFIGURE_ARGS} ${CONFIGURE_SCRIPT} ${CONFIGURE_ARGS}") || exit $?
fi
done

Expand Down
12 changes: 8 additions & 4 deletions mk/check.mk
Expand Up @@ -8,6 +8,10 @@ check-$(1) : $$(DONE_$(1))
$$(ENV_CFLAGS_$(1)) \
$$(ENV_CXXFLAGS_$(1)) \
$$(ENV_RFLAGS_$(1)) \
$$(CROSS_COMPILER_CC) \
$$(CROSS_COMPILER_CXX) \
$$(CROSS_COMPILER_LD) \
$$(CROSS_COMPILER_AR) \
$$(MAKE) -C $$(B)src/$$(PATH_$(1)) check

DEPS_CHECK_ALL += $(1)
Expand All @@ -20,7 +24,7 @@ $(eval $(call DEF_SUBMODULE_TEST_RULES,$(submodule))))
define DEF_LIB_CRATE_TEST_RULES
servo-test-$(1): $$(DEPS_$(1))
@$$(call E, compile: servo-test-$(1))
$$(Q)$$(RUSTC) $(strip $(CFG_RUSTC_FLAGS)) $$(RFLAGS_$(1)) --test -o $$@ $$<
$$(Q)$$(RUSTC) $(strip $(TARGET_FLAGS) $(CFG_RUSTC_FLAGS)) $$(RFLAGS_$(1)) --test -o $$@ $$<

.PHONY: check-servo-$(1)
check-servo-$(1): servo-test-$(1)
Expand All @@ -36,15 +40,15 @@ $(eval $(call DEF_LIB_CRATE_TEST_RULES,$(lib_crate))))

servo-test: $(DEPS_servo)
@$(call E, check: servo)
$(Q)$(RUSTC) $(RFLAGS_servo) --test -o $@ $<
$(Q)$(RUSTC) $(TARGET_FLAGS) $(RFLAGS_servo) --test -o $@ $<

reftest: $(S)src/test/harness/reftest/reftest.rs servo
@$(call E, compile: $@)
$(Q)$(RUSTC) -L$(B)/src/support/png/rust-png/ -L$(B)/src/support/png/libpng/ -o $@ $<
$(Q)$(RUSTC) $(TARGET_FLAGS) -L$(B)/src/support/png/rust-png/ -L$(B)/src/support/png/libpng/ -o $@ $<

contenttest: $(S)src/test/harness/contenttest/contenttest.rs servo
@$(call E, compile: $@)
$(Q)$(RUSTC) $(RFLAGS_servo) -o $@ $< -L .
$(Q)$(RUSTC) $(TARGET_FLAGS) $(RFLAGS_servo) -o $@ $< -L .


DEPS_CHECK_TESTABLE = $(filter-out $(NO_TESTS),$(DEPS_CHECK_ALL))
Expand Down
3 changes: 3 additions & 0 deletions mk/sub.mk
Expand Up @@ -28,6 +28,9 @@ NATIVE_BUILDS += \
libpng \
$(NULL)

NO_CROSS_BUILDS += \
$(NULL)

# NOTE: the make magic can only compute transitive build dependencies,
# not transitive link flags. So, if A -> B -> C, must add A as a dep
# of C so the correct -L/path/to/A flag is generated for building C.
Expand Down
4 changes: 2 additions & 2 deletions src/components/embedding/command_line.rs
Expand Up @@ -21,7 +21,7 @@ static mut GLOBAL_CMDLINE: Option<*mut command_line_t> = None;
fn command_line_new() -> *mut command_line_t {
unsafe {
let cl = calloc(1, mem::size_of::<command_line>() as size_t) as *mut command_line_t;
(*cl).cl.base.size = mem::size_of::<cef_command_line_t>() as u64;
(*cl).cl.base.size = mem::size_of::<cef_command_line_t>() as size_t;
cl
}
}
Expand Down Expand Up @@ -59,7 +59,7 @@ pub extern "C" fn command_line_get_switch_value(cmd: *mut cef_command_line_t, na
let string = cef_string_userfree_utf16_alloc() as *mut cef_string_utf16_t;
let arg = o.slice_from(opt.len() + 1).as_bytes();
arg.with_c_str(|c_str| {
cef_string_utf16_set(mem::transmute(c_str), arg.len() as u64, string, 1);
cef_string_utf16_set(mem::transmute(c_str), arg.len() as size_t, string, 1);
});
return string as *mut cef_string_userfree_t
}
Expand Down
2 changes: 2 additions & 0 deletions src/components/embedding/embedding.rs
Expand Up @@ -9,6 +9,8 @@

#![feature(globs, macro_rules, phase, thread_local)]

#![allow(experimental)]

#![feature(phase)]
#[phase(plugin, link)]
extern crate log;
Expand Down
4 changes: 2 additions & 2 deletions src/components/embedding/mem.rs
Expand Up @@ -24,13 +24,13 @@ pub fn newarray0<T>(nmem: size_t) -> *mut T {

pub fn newarray<T>(nmem: size_t) -> *mut T {
unsafe {
tc_newarray(nmem * mem::size_of::<T>() as u64) as *mut T
tc_newarray(nmem * mem::size_of::<T>() as size_t) as *mut T
}
}

#[allow(experimental)]
pub fn new0<T>(nmem: size_t) -> *mut T {
let mem = new(nmem * mem::size_of::<T>() as u64) as *mut T;
let mem = new(nmem * mem::size_of::<T>() as size_t) as *mut T;
unsafe {
set_memory(mem, 0 as u8, nmem as uint);
}
Expand Down
2 changes: 1 addition & 1 deletion src/platform/android/fontconfig
Submodule fontconfig updated 1 files
+0 −0 autogen.sh
2 changes: 1 addition & 1 deletion src/platform/macos/rust-cocoa
2 changes: 1 addition & 1 deletion src/platform/macos/rust-core-graphics
4 changes: 2 additions & 2 deletions src/platform/macos/rust-task_info/Makefile.in
@@ -1,10 +1,10 @@
VPATH=%VPATH%

CC=gcc
CC ?= gcc
RUSTC ?= rustc
AR ?= ar
RUSTFLAGS ?=
CFLAGS=-Wall
CFLAGS += -Wall

RUST_SRC = $(shell find $(VPATH)/. -type f -name '*.rs')

Expand Down
4 changes: 2 additions & 2 deletions src/support/encoding/Makefile.in
Expand Up @@ -6,7 +6,7 @@ CXXFLAGS ?=
AR ?= ar
RUSTC ?= rustc
RUSTDOC ?= rustdoc
RUSTFLAGS ?= -O
RUSTFLAGS ?=
EXT_DEPS ?=
RUSTDOC_FLAGS ?=
RUSTDOC_TARGET ?= doc
Expand Down Expand Up @@ -36,7 +36,7 @@ doctest: $(LIB_RS) $(RUST_SRC) libencoding.dummy
$(RUSTDOC) $< -L . --test

.PHONY: check
check: doctest rustencoding-test
check: rustencoding-test
./rustencoding-test

.PHONY: doc
Expand Down
2 changes: 1 addition & 1 deletion src/support/hubbub/libhubbub
Submodule libhubbub updated 1 files
+0 −0 configure

0 comments on commit 9a75a0f

Please sign in to comment.