Servo: Adding Documentation for MSVC

Created on 8 Sep 2016  ·  37Comments  ·  Source: servo/servo

In the light of #12916's completion, it's important to let the contributors know how to setup their Windows environments for Servo.

Files to modify: Anything with documentation (ie, README.md)

cc @larsbergstrom

A-documentation C-assigned P-windows

Most helpful comment

Thanks! I'm trying this out right now, and here's what I've got for some initial steps. I've only tried it on one non-clean Virtual Machine so far, though...

Windows MSVC pre-setup

  • Install Git for Windows (https://git-scm.com/download/win)
    DO allow it to add git.exe to the PATH (default settings for the installer are fine)
  • Install Visual Studio 2015 Community Edition (https://www.visualstudio.com/)
    You MUST add "Visual C++" to the list of installed components. It is not on by default.
  • Install Python for Windows (https://www.python.org/downloads/release/python-2711/)
    The windows x86-64 MSI installer is fine.
    You should change the installation to install the "Add python.exe to Path" feature.
  • Install virtualenv
    In a normal Windows Shell (cmd.exe or "Command Prompt" from the start menu), do:
pip install virtualenv

If this does not work, you may need to reboot for the changed PATH settings to take effect.

Clone servo

  • Open a normal Windows shell (cmd.exe, or "Command Prompt" from the start menu)
  • Make a clone of Servo:
git clone https://github.com/servo/servo

Build servo

cd servo
mach.bat build -d

All 37 comments

Thanks! I'm trying this out right now, and here's what I've got for some initial steps. I've only tried it on one non-clean Virtual Machine so far, though...

Windows MSVC pre-setup

  • Install Git for Windows (https://git-scm.com/download/win)
    DO allow it to add git.exe to the PATH (default settings for the installer are fine)
  • Install Visual Studio 2015 Community Edition (https://www.visualstudio.com/)
    You MUST add "Visual C++" to the list of installed components. It is not on by default.
  • Install Python for Windows (https://www.python.org/downloads/release/python-2711/)
    The windows x86-64 MSI installer is fine.
    You should change the installation to install the "Add python.exe to Path" feature.
  • Install virtualenv
    In a normal Windows Shell (cmd.exe or "Command Prompt" from the start menu), do:
pip install virtualenv

If this does not work, you may need to reboot for the changed PATH settings to take effect.

Clone servo

  • Open a normal Windows shell (cmd.exe, or "Command Prompt" from the start menu)
  • Make a clone of Servo:
git clone https://github.com/servo/servo

Build servo

cd servo
mach.bat build -d

I'm trying this right now, but it's failing to compile mozjs_sys:

error: failed to run custom build command for `mozjs_sys v0.0.0 (https://github.com/servo/mozjs#7cd66925)`
process didn't exit successfully: `D:\Code\servo\target\release\build\mozjs_sys-661d4efe7c7ca939\build-script-build` (ex
it code: 101)
--- stderr
makefile.cargo:98: *** recipe commences before first target.  Stop.
thread 'main' panicked at 'assertion failed: result.success()', D:\Code\servo\.cargo\git\checkouts\mozjs-fa11ffc7d4f1cc2
d\master\build.rs:43
stack backtrace:
   0:     0x7ff7538547ea - std::rand::thread_rng::hf605c918a7eb7363
   1:     0x7ff753852f82 - std::rt::lang_start::haaae1186de9de8cb
   2:     0x7ff75385392d - std::panicking::rust_panic_with_hook::hb1322e5f2588b4db
   3:     0x7ff753841be3 - __ImageBase
   4:     0x7ff7538439c0 - __ImageBase
   5:     0x7ff7538572e1 - _rust_maybe_catch_panic
   6:     0x7ff7538529ba - std::rt::lang_start::haaae1186de9de8cb
   7:     0x7ff75385bfa8 - __scrt_common_main_seh
                        at f:\dd\vctools\crt\vcstartup\src\startup\exe_common.inl:253
   8:     0x7ffff0cf8363 - BaseThreadInitThunk

_Edit:_ I've forgotten to mention that I'm doing a release build (mach.bat build -r), in case that matters.
_Edit 2:_ Same result with mach.bat build -d

Note that it is not enough to simply have python.exe in my PATH, I also had to make sure the scripts folder was in my PATH so I could run pip to install virtualenv and for mach to see virtualenv.

Also I am disappointed that there is no mach.ps.

Selecting the "Add to PATH" option in the Python installer added both the Python installation's root directory and the scripts directory. I just needed to logoff and log in to Windows again for these changes to take effect.

Finished debug [unoptimized + debuginfo] target(s) in 2395.9 secs

I guess it worked, sorta. Attempting to actually run the result...

Servo exited with return value -1073741515 which means STATUS_DLL_NOT_FOUND. I believe the missing dll is freetype.dll. Hmmm, might have actually been due to my .cargo/config which specifies a build script override for freetype so it would actually work normally, and it could be conflicting with servo's freetype.

Okay, after commenting out my .cargo/config, servo now actually runs, and then is totally useless. Loading any page does get the title, but the page itself is totally blank.

Furthermore, it sits around eating up 2 CPU cores while doing absolutely nothing.

If I close servo, the process continues to run and starts eating up _all_ my CPU cores.

@retep998 You need to specify a URL.

@Coder206 I did cmd /c mach.bat run -d http://www.purple.com. Is that not enough?

@retep998 That should do it. I stand corrected mine is outputting like yours. Win 10 Anniversary?

@retep998 I suspect this is because of dummy font settings in gfx.

OS Name:                   Microsoft Windows 10 Pro
OS Version:                10.0.10586 N/A Build 10586

AMD Radeon R9 380 with up to date drivers with full OpenGL 4.5 support.

@retep998 Thanks, this seems to be a general Windows or perhaps just Windows 10 issue.

By looking at makefile.cargo:98 in mosjs-sys I found the line

$(message You must either have the Native Win32 python installed in C:/python27, or set NATIVE_WIN32_PYTHON to point to the appropriate python.exe.)

which is unfortunately never shown when building, because it ends up in stdout instead of stderr, so it won't be forwarded by cargo.

Setting NATIVE_WIN32_PYTHON then actually fixed the issue :smiley:
Now I'm also at the point where running servo shows an empty white window with the correct title, but nothing else. I'm running Windows 10 Home.

Thanks, everybody! It looks like the instructions are correct (though need a fix for @Boddlnagg's issue, potentially) enough to put on the website.

That said, as @retep998 and @Coder206 have noticed and I can confirm, the MSVC build currently does not complete loading and is blank. We'll have to look into that :-)

@larsbergstrom I think I had issues with storage space on my VM. What are your thoughts (or anyone's) about adding a recommended disk space?

With regards to disk space... for a simple dev build, with no tests, and no release build, and not counting space taken up in the cargo cache...

So I'd say at _least_ 10GB of free space.

@retep998 Thanks for doing this. I think this is why I had issues compiling (ie compiling "script" failed).

Yeah, I think that a "low disk space warning" (as a separate issue) might be worthwhile. Right now, when we run out of space, the script build fails in a way that is both opaque and non-trivial to recover from - you typically have to do a clean build.

@larsbergstrom Success on clean Windows 10 machine

You don't need Visual Studio.
You can get Visual C++ as stand alone from here:
http://landinghub.visualstudio.com/visual-cpp-build-tools
Using the default install option

@Jayflux I like that much better, it saves lots of space

Build failing for me
https://pastebin.mozilla.org/8909561

OS Name Microsoft Windows 10 Pro
Version 10.0.10586 Build 10586
<vlad> Jayflux: you want https://github.com/vvuk/mozjs/commit/f9b707cbeb6ad653b8afb8e457b0b2d609ec66ef

When using Vlad's fork i get this
https://pastebin.mozilla.org/8909575

Testing on cmd

  Compiling miniz-sys v0.1.7
   Compiling unreachable v0.1.1
   Compiling ordered-float v0.2.3
   Compiling quickersort v2.1.0
   Compiling openssl v0.7.14
Build failed, waiting for other jobs to finish...
error: failed to run custom build command for `mozjs_sys v0.0.0 (https://github.com/servo/mozjs#87c47526)`
process didn't exit successfully: `C:\Users\Jason\workspace\servo\target\debug\build\mozjs_sys-661d4efe7c7ca939\build-script-build` (exit code: 101)
--- stdout
[[ /c/Users/Jason/workspace/servo/.cargo/git/checkouts/mozjs-fa11ffc7d4f1cc2d/master/mozjs/js/src/configure -ot /c/Users/Jason/workspace/servo/.cargo/git/checkouts/mozjs-fa11ffc7d4f1cc2d/master/mozjs/js/src/configure.in ]] && touch /c/Users/Jason/workspace/servo/.cargo/git/checkouts/mozjs-fa11ffc7d4f1cc2d/master/mozjs/js/src/configure || true
[[ /c/Users/Jason/workspace/servo/.cargo/git/checkouts/mozjs-fa11ffc7d4f1cc2d/master/mozjs/js/src/old-configure -ot /c/Users/Jason/workspace/servo/.cargo/git/checkouts/mozjs-fa11ffc7d4f1cc2d/master/mozjs/js/src/old-configure.in ]] && touch /c/Users/Jason/workspace/servo/.cargo/git/checkouts/mozjs-fa11ffc7d4f1cc2d/master/mozjs/js/src/old-configure || true
! [[ /c/Users/Jason/workspace/servo/.cargo/git/checkouts/mozjs-fa11ffc7d4f1cc2d/master/mozjs/js/src/configure.in -ot /c/Users/Jason/workspace/servo/.cargo/git/checkouts/mozjs-fa11ffc7d4f1cc2d/master/mozjs/js/src/configure ]] && touch /c/Users/Jason/workspace/servo/.cargo/git/checkouts/mozjs-fa11ffc7d4f1cc2d/master/mozjs/js/src/configure || true
! [[ /c/Users/Jason/workspace/servo/.cargo/git/checkouts/mozjs-fa11ffc7d4f1cc2d/master/mozjs/js/src/old-configure.in -ot /c/Users/Jason/workspace/servo/.cargo/git/checkouts/mozjs-fa11ffc7d4f1cc2d/master/mozjs/js/src/old-configure ]] && touch /c/Users/Jason/workspace/servo/.cargo/git/checkouts/mozjs-fa11ffc7d4f1cc2d/master/mozjs/js/src/old-configure || true
if [[ /c/Users/Jason/workspace/servo/.cargo/git/checkouts/mozjs-fa11ffc7d4f1cc2d/master/mozjs/js/src/configure -nt C:\Users\Jason\workspace\servo\target\debug\build\mozjs_sys-661d4efe7c7ca939\out/config.status ]] ; then \
  cd C:\Users\Jason\workspace\servo\target\debug\build\mozjs_sys-661d4efe7c7ca939\out && \
  PYTHON="python" MOZ_TOOLS="" \
  CC="gcc" CPP="gcc -E" CXX="g++" AR="ar" \
  /c/Users/Jason/workspace/servo/.cargo/git/checkouts/mozjs-fa11ffc7d4f1cc2d/master/mozjs/js/src/configure --disable-jemalloc --disable-js-shell --disable-tests --without-intl-api --build-backends=RecursiveMake --disable-shared-js || (cat config.log && exit 1) ; \
fi
makefile.cargo:120: recipe for target 'maybe-configure' failed

--- stderr
C:/Users/Jason/AppData/Local/Temp/make7000-5.sh: line 2: cd: C:UsersJasonworkspaceservotargetdebugbuildmozjs_sys-661d4efe7c7ca939out: No such file or directory
cat: config.log: No such file or directory
mozmake: *** [maybe-configure] Error 1
thread 'main' panicked at 'assertion failed: result.success()', C:\Users\Jason\workspace\servo\.cargo\git\checkouts\mozjs-fa11ffc7d4f1cc2d\master\build.rs:43
note: Run with `RUST_BACKTRACE=1` for a backtrace.

Build FAILED in 0:05:56

Can you do set PATH and paste the results in here? I'm worried that there is another, more evil, python that is first in your PATH. Mine looks like:

C:\Users\larsberg>set PATH
Path=C:\Python27\;C:\Python27\Scripts;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\system32\config\systemprofile\.dnx\bin;C:\Program Files\Microsoft DNX\Dnvm\;C:\Program Files (x86)\Windows Kits\8.1\Windows Performance Toolkit\;C:\Program Files\Microsoft SQL Server\130\Tools\Binn\;C:\Program Files\Git\cmd;C:\Program Files (x86)\WiX Toolset v3.10\bin
C:\Users\Jason\workspace\servo>set PATH
Path=C:\Program Files (x86)\MSBuild\14.0\bin\amd64;C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\amd64;C:\Windows\Microsoft.NET\Framework64\v4.0.30319;C:\Windows\Microsoft.NET\Framework64\;C:\Program Files (x86)\Windows Kits\10\bin\x64;C:\Program Files (x86)\Windows Kits\10\bin\x86;C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.6.1 Tools\x64\;C:\Python27\;C:\Python27\Scripts;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\Windows Kits\10\Windows Performance Toolkit\;C:\Program Files\nodejs\;C:\ProgramData\chocolatey\bin;C:\Program Files\Oracle\VirtualBox;C:\Program Files\Sublime Text 3;C:\Program Files (x86)\Skype\Phone\;C:\HashiCorp\Vagrant\bin;C:\Program Files\Git\cmd;C:\Users\Jason\AppData\Roaming\npm;C:\Program Files (x86)\Nmap
PATHEXT=.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC

NATIVE_WIN32_PYTHON hasn't worked for me

The instructions worked for me as well.

@Coder206 Is there an open issue for the problem of seeing a white screen instead of the contents of the website? I am experiencing the same problem on Windows 10 Educational (Version 10.0.10586) with an Intel HD Graphics 4000.

@aochagavia No there is no issue for it

Should I create a new one?

I would think it would be a good idea. Thanks for doing this @aochagavia!

in mozjs makefile.cargo, there's a line: SRC_DIR = $(shell pwd) I wonder if for you, pwd is giving c:......, and for me, it's giving c:/....

For me %MOZTOOLS_PATH%\pwd gives /c/proj/r; but that's with a local MOZTOOLS_PATH. You should see whatever mach does to set up $PATH/$MOZTOOLS_PATH and what pwd it finds.

@vlad are there any steps to working out what pwd is giving me?
These commands don't run in the console

Do i need to set the moztools paths env variable?

@vvuk here are the results (my host machine, not VM)
cmder:

C:\Users\Jason\workspace\servo (master)
λ .servo\msvc-dependencies\moztools\bin\pwd.exe
/c/Users/Jason/workspace/servo

CMD

C:\Users\Jason\workspace\servo>.servo\msvc-dependencies\moztools\bin\pwd.exe
/c/Users/Jason/workspace/servo

C:\Users\Jason\workspace\servo>

Also...
Don't know if this helps, but i've noticed you've added a path to python here:
https://github.com/servo/mozjs/commit/7ba7cfa262dd6864d581855bad47c28d4ad97970#diff-9080a05d9a2f1078a5790475b50fdb37L96

However, my installation of python is:
C:\Python27 with an uppercase P

By looking at makefile.cargo:98 in mosjs-sys I found the line

$(message You must either have the Native Win32 python installed in C:/python27, or set NATIVE_WIN32_PYTHON to point to the appropriate python.exe.)
which is unfortunately never shown when building, because it ends up in stdout instead of stderr, so it won't be forwarded by cargo.

Setting NATIVE_WIN32_PYTHON then actually fixed the issue :smiley:
Now I'm also at the point where running servo shows an empty white window with the correct title, but nothing else. I'm running Windows 10 Home.

@Boddlnagg I did the same thing but its still failling for me :sob: :sob:
Looks like its hardcoded to c:\python27 which will fail for some, as its an uppercase P on installation (or at least for me it was)

@Jayflux Did you set it to the path containing python.exe or actually to point to python.exe itself? It must be the latter.
And I don't know why the uppercase P should matter here, since (a) that is the default and (b) filenames should be case insensitive on Windows ...

@Boddlnagg i pointed directly to the python.exe itself and i still get the same error
Ok didn't know about the case insensitivity, good to know

So if https://github.com/servo/servo/issues/13272 is anything to go by.. Visual C++ build tools is giving different results to the full Visual Studio build

I'm going to try doing this again, uninstalling the Visual C++ build tools and instead using the Visual Studio full install, to see if that has anything to do with it

@larsbergstrom @vvuk
Turns out the issue was me using http://landinghub.visualstudio.com/visual-cpp-build-tools instead of installing Visual Studio.

I now get the white screen like everyone else

Was this page helpful?
0 / 5 - 0 ratings

Related issues

noisiak picture noisiak  ·  3Comments

roberto68 picture roberto68  ·  3Comments

pyfisch picture pyfisch  ·  4Comments

Grishy picture Grishy  ·  3Comments

larsbergstrom picture larsbergstrom  ·  3Comments