Closed Bug 1385241 Opened 5 years ago Closed 5 years ago

Remove Mozillabuild bootstrap Rust installation code

Categories

(Firefox Build System :: General, defect)

defect
Not set
normal

Tracking

(firefox57 fixed)

RESOLVED FIXED
mozilla57
Tracking Status
firefox57 --- fixed

People

(Reporter: mayhemer, Assigned: bryce)

References

(Blocks 1 open bug)

Details

Attachments

(1 file)

Windows 10, start-shell-msvc2015.bat, up to date m-c, mozilla-build 2.2.0

$ ./mach bootstrap
mach bootstrap is not fully implemented in MozillaBuild

Please choose the version of Firefox you want to build:
1. Firefox for Desktop Artifact Mode
2. Firefox for Desktop
3. Firefox for Android Artifact Mode
4. Firefox for Android

Note on Artifact Mode:

Firefox for Desktop and Android supports a fast build mode called
artifact mode. Artifact mode downloads pre-built C++ components rather
than building them locally, trading bandwidth for time.

Artifact builds will be useful to many developers who are not working
with compiled code. If you want to work on look-and-feel of Firefox,
you want "Firefox for Desktop Artifact Mode".

Similarly, if you want to work on the look-and-feel of Firefox for Android,
you want "Firefox for Android Artifact Mode".

To work on the Gecko technology platform, you would need to opt to full,
non-artifact mode. Gecko is Mozilla's web rendering engine, similar to Edge,
Blink, and WebKit. Gecko is implemented in C++ and JavaScript. If you
want to work on web rendering, you want "Firefox for Desktop", or
"Firefox for Android".

If you don't know what you want, start with just Artifact Mode of the desired
platform. Your builds will be much shorter than if you build Gecko as well.
But don't worry! You can always switch configurations later.

You can learn more about Artifact mode builds at
https://developer.mozilla.org/en-US/docs/Artifact_builds.

Your choice: 2
info: updating existing rustup installation

error: component 'rust-std' for target 'i686-pc-windows-msvc' is required for toolchain 'stable-i686-pc-windows-msvc' and cannot be re-added
Error running mach:

    ['bootstrap']

The error occurred in code that was called by the mach command. This is either
a bug in the called code itself or in the way that mach is calling it.

You should consider filing a bug for this issue.

If filing a bug, please include the full output of mach, including this error
message.

The details of the failure are as follows:

CalledProcessError: Command '[u'c:/Users/xmayhemer\\.cargo\\bin\\rustup', 'target', 'add', 'i686-pc-windows-msvc']' returned non-zero exit status 1

  File "c:\Mozilla\src\mozilla-central1\python/mozboot/mozboot/mach_commands.py", line 32, in bootstrap
    bootstrapper.bootstrap()
  File "c:\Mozilla\src\mozilla-central1\python/mozboot\mozboot\bootstrap.py", line 240, in bootstrap
    self.instance.install_system_packages()
  File "c:\Mozilla\src\mozilla-central1\python/mozboot\mozboot\mozillabuild.py", line 23, in install_system_packages
    self.install_rustup()
  File "c:\Mozilla\src\mozilla-central1\python/mozboot\mozboot\mozillabuild.py", line 45, in install_rustup
    self.run([rustup, 'target', 'add', 'i686-pc-windows-msvc'])
  File "c:\Mozilla\src\mozilla-central1\python/mozboot\mozboot\mozillabuild.py", line 84, in run
    subprocess.check_call(command, stdin=sys.stdin)
  File "c:\Mozilla\mozilla-build\python\lib\subprocess.py", line 540, in check_call
    raise CalledProcessError(retcode, cmd)
Doesn't go away with MozillaBuild 3.0.0
Note: 

$rustup install stable-i686-pc-windows-msvc 

doesn't help

if rustup command can't be found, try restarting the terminal.
mach is trying to install rust even it's already there.  mach is missing a check if it's already installed.

a quick and dirty fix in case you are facing this issue and need to move on:

diff --git a/python/mozboot/mozboot/mozillabuild.py b/python/mozboot/mozboot/mozillabuild.py
--- a/python/mozboot/mozboot/mozillabuild.py
+++ b/python/mozboot/mozboot/mozillabuild.py
@@ -15,17 +15,17 @@ class MozillaBuildBootstrapper(BaseBoots
     def __init__(self, no_interactive=False):
         BaseBootstrapper.__init__(self, no_interactive=no_interactive)
         print("mach bootstrap is not fully implemented in MozillaBuild")

     def which(self, name):
         return BaseBootstrapper.which(self, name + '.exe')

     def install_system_packages(self):
-        self.install_rustup()
+        return

     def install_rustup(self):
         try:
             rustup_init = tempfile.gettempdir() + '/rustup-init.exe'
             self.http_download_and_save(
                     'https://static.rust-lang.org/rustup/archive/0.2.0/i686-pc-windows-msvc/rustup-init.exe',
                     rustup_init,
                     'a45ab7462b567dacddaf6e9e48bb43a1b9c1db4404ba77868f7d6fc685282a46')
(In reply to Honza Bambas (:mayhemer) from comment #3)
> a quick and dirty fix in case you are facing this issue and need to move on:

Credit: Ted!
MozillaBuildBootstrapper.install_rustup unconditionally installs rustup:
https://dxr.mozilla.org/mozilla-central/rev/36f95aeb4c77f7cf3b3366583008cd6e4b6b1dba/python/mozboot/mozboot/mozillabuild.py#25

rustup mostly handles this OK, but it also unconditionally runs `rustup target add i686-pc-windows-msvc`, which fails if it already exists, so bootstrap fails even though all the Rust bits are actually there.

mozboot.base already has an `ensure_rust_modern` that ought to work fine:
https://dxr.mozilla.org/mozilla-central/rev/36f95aeb4c77f7cf3b3366583008cd6e4b6b1dba/python/mozboot/mozboot/base.py#592

and in fact the main bootstrap process will call that after `install_system_packages` anyway:
https://dxr.mozilla.org/mozilla-central/rev/36f95aeb4c77f7cf3b3366583008cd6e4b6b1dba/python/mozboot/mozboot/bootstrap.py#247

We should just remove the whole `install_rustup` function and let `ensure_rust_modern` do its thing.
The other issue here was that Honza had the `i686-pc-windows-msvc` Rust toolchain installed as the default, and all of our bootstrap machinery assumes the `x86_64-pc-windows-msvc` toolchain will be the default, so we don't handle that case very well. Specifically he was trying to do a 64-bit build, and bootstrap didn't make sure he had the `x86_64-pc-windows-msvc` *target* installed.
Honza fixed his toolchain problem by running `rustup default stable-x86_64-pc-windows-msvc`.
Resummarizing--we should do what I outlined in comment 5.
Summary: ./mach bootstrap: error: component 'rust-std' for target 'i686-pc-windows-msvc' is required for toolchain 'stable-i686-pc-windows-msvc' and cannot be re-added → Remove Mozillabuild bootstrap Rust installation code
Comment on attachment 8905706 [details]
Bug 1385241 - Remove mozilla-build specific rust install. .mielczarek

https://reviewboard.mozilla.org/r/177504/#review184512

Thanks for the patch!
Attachment #8905706 - Flags: review?(ted) → review+
Assignee: nobody → bvandyk
We're sorry, Autoland could not rebase your commits for you automatically. Please manually rebase your commits and try again.

hg error in cmd: hg rebase -s ead3aa456707 -d 39b0e0aead7b: rebasing 419820:ead3aa456707 "Bug 1385241 - Remove mozilla-build specific rust install. r=ted.mielczarek" (tip)
merging python/mozboot/mozboot/mozillabuild.py
warning: conflicts while merging python/mozboot/mozboot/mozillabuild.py! (edit, then use 'hg resolve --mark')
unresolved conflicts (see hg resolve, then hg rebase --continue)
Pushed by bvandyk@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/a54ba2e89fe0
Remove mozilla-build specific rust install. r=ted.mielczarek
https://hg.mozilla.org/mozilla-central/rev/a54ba2e89fe0
Status: NEW → RESOLVED
Closed: 5 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla57
Product: Core → Firefox Build System
You need to log in before you can comment on or make changes to this bug.