Bug 1248391 - Don't force rust --target on unknown platforms. r=ted a=ritu
MozReview-Commit-ID: CYogxQNqhGf
--- a/build/autoconf/rust.m4
+++ b/build/autoconf/rust.m4
@@ -108,31 +108,37 @@ AC_DEFUN([MOZ_RUST_SUPPORT], [
# we need i686-pc-windows-gnu instead, since mingw32 builds work.
rust_target=i686-pc-windows-msvc
;;
x86_64-pc-mingw32)
# XXX and here as well
rust_target=x86_64-pc-windows-msvc
;;
*)
- AC_ERROR([don't know how to translate $target for rustc])
+ # Fall back to implicit (native) target when not cross-compiling
+ if test -n "$CROSS_COMPILE"; then
+ AC_ERROR([don't know how to translate $target for rustc])
+ fi
+ ;;
esac
- # Check to see whether we need to pass --target to RUSTC. This can
- # happen when building Firefox on Windows: js's configure will receive
- # a RUSTC from the toplevel configure that already has --target added to
- # it.
- rustc_target_arg=
- case "$RUSTC" in
- *--target=${rust_target}*)
- ;;
- *)
- rustc_target_arg=--target=${rust_target}
- ;;
- esac
+ if test -n "$rust_target"; then
+ # Check to see whether we need to pass --target to RUSTC. This can
+ # happen when building Firefox on Windows: js's configure will receive
+ # a RUSTC from the toplevel configure that already has --target added to
+ # it.
+ rustc_target_arg=
+ case "$RUSTC" in
+ *--target=${rust_target}*)
+ ;;
+ *)
+ rustc_target_arg=--target=${rust_target}
+ ;;
+ esac
+ fi
# Check to see whether our rustc has a reasonably functional stdlib
# for our chosen target.
echo 'pub extern fn hello() { println!("Hello world"); }' > conftest.rs
if AC_TRY_COMMAND(${RUSTC} --crate-type staticlib ${rustc_target_arg} -o conftest.rlib conftest.rs > /dev/null) && test -s conftest.rlib; then
RUSTC="${RUSTC} ${rustc_target_arg}"
else
AC_ERROR([cannot compile for ${rust_target} with ${RUSTC}])