Bug 1350001 - Run cargo in a clean environment when running in a MozillaBuild shell. r?ted draft
authorKartikaya Gupta <kgupta@mozilla.com>
Thu, 06 Apr 2017 09:59:14 -0400
changeset 556998 8695cd464e1fb8d45b2ce5241ed7cc86e07f9e0f
parent 556960 950612071c4e5cbd61af6c0f66ed0bc40c35e39c
child 622993 bcda863457121ec7eb2c778a4038449d10816015
push id52656
push userkgupta@mozilla.com
push dateThu, 06 Apr 2017 13:59:53 +0000
reviewersted
bugs1350001
milestone55.0a1
Bug 1350001 - Run cargo in a clean environment when running in a MozillaBuild shell. r?ted This prevents the variables set in vcvars.bat from causing build failures when cargo tries to process build scripts in an environment where the default rust toolchain doesn't match the MozillaBuild shell (in terms of 32-bit or 64-bit). MozReview-Commit-ID: 5VRnQToYUYf
config/rules.mk
--- a/config/rules.mk
+++ b/config/rules.mk
@@ -916,17 +916,30 @@ rustflags = -C opt-level=0
 # Unfortunately, -C opt-level=0 implies -C debug-assertions, so we need
 # to explicitly disable them when MOZ_DEBUG is not set.
 ifndef MOZ_DEBUG
 rustflags += -C debug-assertions=no
 endif
 rustflags_override = RUSTFLAGS='$(rustflags)'
 endif
 
-CARGO_BUILD = env $(rustflags_override) \
+ifdef MOZ_MSVCBITS
+# If we are building a MozillaBuild shell, we want to clear out the
+# vcvars.bat environment variables for cargo builds. This is because
+# a 32-bit MozillaBuild shell on a 64-bit machine will try to use
+# the 32-bit compiler/linker for everything, while cargo/rustc wants
+# to use the 64-bit linker for build.rs scripts. This conflict results
+# in a build failure (see bug 1350001). Clearing out *just* the changes
+# from vcvars.bat is hard, so we just clear out the whole environment.
+environment_cleaner = -i
+else
+environment_cleaner =
+endif
+
+CARGO_BUILD = env $(environment_cleaner) $(rustflags_override) \
 	CARGO_TARGET_DIR=$(CARGO_TARGET_DIR) \
 	RUSTC=$(RUSTC) \
 	MOZ_DIST=$(ABS_DIST) \
 	LIBCLANG_PATH=$(MOZ_LIBCLANG_PATH) \
 	CLANG_PATH=$(MOZ_CLANG_PATH) \
 	PKG_CONFIG_ALLOW_CROSS=1 \
 	RUST_BACKTRACE=1 \
 	$(CARGO) build $(cargo_build_flags)