Bug 1248391 - Don't force rust --target on unknown platforms. r=ted
authorJan Beich <jbeich@FreeBSD.org>
Thu, 24 Mar 2016 13:43:38 +0000
changeset 291210 70e88ad137197c2b5cc73916c15b5385684b3a2e
parent 291209 7511231503fbee1ad7f1a936e531192f25efa262
child 291211 6001a9e0ec92fa83ab76f2628d1d0638b6db523d
push id19656
push usergwagner@mozilla.com
push dateMon, 04 Apr 2016 13:43:23 +0000
treeherderb2g-inbound@e99061fde28a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersted
bugs1248391
milestone48.0a1
Bug 1248391 - Don't force rust --target on unknown platforms. r=ted
build/autoconf/rust.m4
--- 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}])