Bug 1377157 - remove VCINSTALLDIR from cargo's environment when running in MozillaBuild; r=ted.mielczarek

Stable Rust currently has logic similar to the following for finding the
linker on Windows:

  if VCINSTALLDIR in os.env:
    search for things in PATH
    if found, return, otherwise fallthrough

  look for MSVC installations of various kinds

For our current MozillaBuild setup where we clear out PATH prior to
invoking Cargo, this works: even though VCINSTALLDIR is set and we
(unsuccessfully) search through an empty PATH, we'll still fallback to
looking for MSVC installations.

Beta Rust has altered this search strategy:

  if VCINSTALLDIR in os.env:
    search for things in PATH
    return the result of the search, regardless of success

  look for MSVC installations of various kinds

Note that in the above logic, if VCINSTALLDIR is set, we are only going
to try looking in PATH for an appropriate linker.  Since PATH is empty
in our current MozillaBuild setup, beta Rust will therefore fail to find
the correct linker.  This failure causes numerous problems.

Since Firefox is already trying to "clean" the environment that Cargo is
invoked in, we should work a little bit harder by unsetting VCINSTALLDIR
entirely, and simply force Rust to search for known MSVC installations.
Making this change makes stable and beta Rust behave identically.

(We don't have to worry about this distinction in automation, because
the "cleaning" code is only activated when we detect a MozillaBuild
shell.)
This commit is contained in:
Nathan Froyd 2017-06-29 13:41:57 -04:00
Родитель 21ef8236e2
Коммит 87007ca0f2
1 изменённых файлов: 1 добавлений и 1 удалений

Просмотреть файл

@ -891,7 +891,7 @@ ifdef MOZ_MSVCBITS
# to use the 64-bit linker for build.rs scripts. This conflict results
# in a build failure (see bug 1350001). So we clear out the environment
# variables that are actually relevant to 32- vs 64-bit builds.
environment_cleaner = PATH='' LIB='' LIBPATH=''
environment_cleaner = -u VCINSTALLDIR PATH='' LIB='' LIBPATH=''
# The servo build needs to know where python is, and we're removing the PATH
# so we tell it explicitly via the PYTHON env var.
environment_cleaner += PYTHON='$(shell which $(PYTHON))'