Bug 1248391 - Don't force rust --target on unknown platforms. r=ted a=ritu
authorJan Beich <jbeich@FreeBSD.org>
Thu, 24 Mar 2016 13:43:38 +0000
changeset 325731 36ad0d4df02c9c9ea551c1d5cc0b0669ef9d9efd
parent 325730 636964569c3b6d732424366fc03d29541ce90481
child 325732 6b279bfa8288a27d513b252382ca5ab640fe5387
push id1128
push userjlund@mozilla.com
push dateWed, 01 Jun 2016 01:31:59 +0000
treeherdermozilla-release@fe0d30de989d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersted, ritu
bugs1248391
milestone47.0a2
Bug 1248391 - Don't force rust --target on unknown platforms. r=ted a=ritu MozReview-Commit-ID: CYogxQNqhGf
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}])