mozilla nss for windows
https://developer.mozilla.org/en-US/docs/NSS/Building
https://developer.mozilla.org/en-US/docs/Developer_Guide/Build_Instructions/Windows_Prerequisites
This article is in need of a technical review.
Introduction
This page has detailed information on how to build NSS. Because NSS is a cross-platform library that builds on many different platforms and has many options, it may be complex to build. Please read these instructions carefully before attempting to build.
Build Environment
Windows
- Get the Prerequisites
- NSS compilation on Windows uses the same shared build system as Mozilla Firefox. You must first install the Windows Prerequisites, including MozillaBuild.
Get the source
NSS and NSPR currently use CVS for source control, rather than Mercurial like other Mozilla projects. In order to get the source, you will need to perform a CVS checkout. To check out the latest sources for NSS and NSPR--which may not be part of a stable release--use the following commands:
cvs -d :pserver:anonymous@cvs-mirror.mozilla.org:/cvsroot co -r HEAD NSPR cvs -d :pserver:anonymous@cvs-mirror.mozilla.org:/cvsroot co -r HEAD NSS
Configure the Environment
The build system for NSS uses a variety of environment variables to control the build. Below is a list of the variables, along with possible values they may be set to. For example, on Windows, you may wish to set OS_TARGET=WINNT.
- OS_TARGET
- WINNT
- Build for Windows 2000 or later.
- WIN95
- Build for Windows 98 or earlier.
- BUILD_OPT
- 0
- Build a debug (non-optimized) version of NSS. This is the default.
- 1
- Build an optimized (non-debug) version of NSS.
- USE_64
-
Note: Building for a 64-bit environment/ABI is only supported on Unix/POSIX platforms.
- 0
- Build for a 32-bit environment/ABI. This is the default.
- 1
- Build for a 64-bit environment/ABI.
Build
To build NSS, it's as simple as navigating to the NSS checkout and making the "nss_build_all" target.
cd mozilla/security/nss make nss_build_all
This page covers the steps needed to prepare your machine to build a bleeding-edge, development version of Firefox and/or Thunderbird on Windows.
Hardware requirements
Mozilla takes time to build. You need a development-class system:
- A fast processor, ideally with several cores.
- More than 2 GB of RAM for recent Firefox builds, 4 GB or higher recommended.
- 1.5 GB NTFS or 3 GB FAT disk space, or more. (This is in addition to the disk space required for the source code.)
- Windows Vista or later recommended (the build should work on Windows XP, though).
Overview
The Mozilla build process requires many tools that are not installed on most Windows systems. In addition to Visual Studio, you must install MozillaBuild, which is a bundle of software including just the right versions of bash, GNU make, autoconf, Mercurial, and much more.
The Mozilla codebase works with the following compilers ("Official" means this is what we use for the builds we release as the Firefox product):
VC8 (Visual Studio 2005) | VC9 (Visual Studio 2008) | VC10 (Visual Studio 2010) | VC11 (Visual Studio 2012) | |
---|---|---|---|---|
Firefox | No | No | Yes (Official) | Yes |
Caution when using:
Visual Studio 2010:
- Installing .NET Framework 4.5 when using Visual Studio 2010 RTM breaks the builds. See Bug 772989 Comments 15 and 17 on this: according tohttp://support.microsoft.com/kb/2757355, installing Visual Studio 2010 SP1 should fix this problem.
- Installing both Visual Studio 2010 and Visual Studio 2012 on Windows 64-bit might break the build. It can work, but in the past there have been sometimes been build problems (at the moment it should work though).
- Visual Studio 2012:
- When building Thunderbird or SeaMonkey, you need to install the MAPI header files from http://www.microsoft.com/en-us/download/details.aspx?id=12905 because the MAPI header files are not bundled with Visual Studio 2012 (Windows SDK 8.0). You should copy the header files to a Windows SDK include directory so that the build process will find the files, for example to
C:\Program Files (x86)\Windows Kits\8.0\Include\shared.
Install build prerequisites
Complete each of these steps, otherwise you may not be able to build successfully. There are notes on these software requirements below.
- Make sure your system is up-to-date through Windows Update. (Windows XP needs at least Service Pack 2 and .NET Framework 2.0.)
- You may need to install one or more Windows SDKs. See Windows SDK versions for a quick guide.
- Install the June 2010 DirectX SDK (even VS 2012 requires this). (If you have previously installed Visual C++ 2010, you may encounter a "S1023" error during installation. For corrective steps, see Known Issue: DirectX SDK (June 2010) Setup and the S1023 error on the "Games for Windows and the DirectX SDK" blog.)
- Install a version of Visual Studio that supports C++ development: VS 2012 for Windows Desktop Pro or Express (free), or VC++ 2010 Pro or Express (free).
- Install MozillaBuild, a package of additional build tools. If you have cygwin installed, read the note in the tips section. (After MozillaBuild's installer exits, if you see a Windows error dialog giving you the option to re-install with the 'correct settings', choose that option and after that all should be well.) More information about MozillaBuild is available at https://wiki.mozilla.org/MozillaBuild.
- If you get errors about missing .dll files, you will need to find the folder(s) containing each missing .dll and add them to the PATH environment variable (in advanced system settings).
- If you intend to build the Firefox Windows 8 UI (formerly known as Metro), see the additional information located at Windows 8 Integration - Building Locally.
Mozilla will not build if some of the tools are installed at a path that contains spaces or other breaking characters such as pluses, quotation marks, or metacharacters. But the Visual C++ tools are an exception -- they may be installed in a directory which contains spaces, and the default install location is preferred.
Opening a Build Command Prompt
After the prerequisites are installed, launch one of the following batch files from the directory to which you installed MozillaBuild (c:\mozilla-build
by default):
start-msvc10.bat (VS 2010)
start-msvc11.bat (VS 2012)
start-msvcX-x64.bat
files (unless you know what you're doing). Those files are experimental andunsupported. See the Build:MozillaBuild For x64 wiki page. This will launch an MSYS / BASH command prompt properly configured to build one of the aforementioned code bases. All further commands should be executed in this command prompt window. (Note that this is not the same as what you get with the Windows CMD.EXE shell.)
This must be launched with administrator privileges. If you have User Account Control (UAC) turned on, it may not be granted automatically. Right click the .BAT file and select "Run as Administrator".
Create a directory for the source
It's a sensible idea to create a new directory dedicated solely to the code:
cd /c; mkdir mozilla-source; cd mozilla-source
Now you are ready to get the Firefox source and build; continue on to Simple Firefox build (Get_the_source).
Command Prompt Tips and Caveats
- To paste into this window, you must right-click on the window's title bar, move your cursor to the Edit menu, and click Paste. You can also set Quick Edit Mode in the Properties menu and use a right-click in the window to paste your selection.
- If you have cygwin installed, make sure that the MozillaBuild directories come before any cygwin directories in the search path (use
echo $PATH
to see your search path). - In the MSYS / BASH shell, the c: drive looks like a directory called
c
under the root directory (/). So if you want to change to the directoryc:\mydir
, in the MSYS shell you would usecd /c/mydir
. Note the UNIX-style forward slashes (/) in the prompt instead of the Windows-style backward slashes (\). - The MSYS root directory is located in
c:\mozilla-build\msys
if you used the default installation directory. It's a good idea not to build anything under this directory. Instead use something like/c/mydir
.
Common problems, hints, and restrictions
- Debugging Mozilla on Windows FAQ: Tips on how to debug Mozilla on Windows.
- Note that in Windows you need to build with Administrator privileges. If you have User Account Control (UAC) turned on, it may not automatically grant that to you.
- The build may fail if your PATH environment variable contains quotes ("). Quotes are not properly translated when passed down to MozillaBuild sub-shells. Quotes are usually not needed so they can be removed.
- The build may fail if you have a PYTHON environment variable set. You will see an error almost immediately that says "
The system cannot find the file specified
". In a cmd-shell typing "SET PYTHON=" before running mozilla build tools in that same shell should fix this. - The build may fail if you have cygwin installed. Make sure that the MozillaBuild directories (
c:\mozilla-build
and subdirectories) come before any cygwin directories in your PATH environment variable. If this does not help, remove the cygwin directories from PATH, or try building on a clean PC with no cygwin. - Building with versions of NSIS other than the version that comes with the latest supported version of MozillaBuild is not supported and will likely fail.
- If you intend to distribute your build to others, you will need to set
WIN32_REDIST_DIR=$VCINSTALLDIR\redist\x86\Microsoft.VC80.CRT
in your mozconfig to get the Microsoft CRT DLLs packaged along with the application. - The Microsoft Antimalware service can interfere with compilation, often manifesting as an error related to
conftest.exe
during build. To remedy this, add at least your object directory to the exclusion settings. - If you encounter an error that atlbase.h cannot be found and you have installed Visual Studio 10 Express together with the platform SDK, you may have to delete a registry entry so that guess-msvc.bat doesn't detect VC10 installed. The key is HKLM\SOFTWARE\Microsoft\VisualStudio\10.0\Setup\VC.
- If you encounter an error like "second C linkage of overloaded function '_interlockedbittestandset' not allowed", it happens when intrin.h and windows.h are included together. Use a #define to redefine one instance of the function's name. See more on using intrin.h.
- Parallel builds (-jN) do not work with GNU make on Windows. You need to use pymake instead.
Warning: If you follow the below advice, your computer will not be protected against attacks that exploit this vulnerability. Make sure you take adequate precautions.
- If you still get random crashes when running MAKE, you may be encountering interference from Windows Security Updates that prevents proper operation of the Bash shell on some Windows systems. In this case, if you're on Windows XP, you will need to uninstall Windows XP Security Updates KB933729 and KB970238 using Add or Remove Programs from the Control Panel. The first of these Security Updates is also incorporated into Windows XP Service Pack 3 (KB936929), so if you have already installed SP3 you'll need to uninstall it and then make sure that Service Pack 2, including all Windows updates (EXCEPT KB933729, KB936929, and KB970238) get installed. To prevent these updates from being installed automatically, select "Notify me but don't automatically download or install them" in the Control Panel's "Automatic Updates" dialog. Then de-select them when any of these items appear in the list of recommended updates, and when asked, indicate that you don't want to be asked about these de-selected updates in the future.
Microsoft DirectX SDK
The June 2010 DirectX SDK (specifically) is required for building the ANGLE GLES-on-D3D9 renderer, which is required on Windows for WebGL rendering. (If you don't care about compatibility with official Firefox builds and want to avoid installing this large SDK, you can disable WebGL by building Mozilla with the --disable-webgl option.) As part of the DirectX SDK install, you must install the End-User Redistributable Packages; don't uncheck it in the installer. (At least prior to Win7+VS2012?)
(Note that other versions of the DirectX SDK on Microsoft's Developer Center that claim to have been released after June 2010 are actually older versions that are misdated, some of which will result in an error if you try and download them due to the installer files themselves having been removed from the MS servers. There will not be any further standalone DirectX SDKs released by MS, since DirectX has been transitioned from an independent distribution model to an integrated (into Windows and Visual Studio) model, and the DirectX SDK is now integrated into the Windows 8 SDK (which is bundled with Visual Studio as of VS2012) [ref]. The reason that we require the June SDK even on newer Win7+VS2012 systems is because ANGLE depends on D3DX9, but MS considers D3DX to have been obsoleted by newer technologies and therefore VS2012 doesn't include the d3dx9.h and d3dx9tex.h headers that are required to compile ANGLE. Any queries about this paragraph, talk to Jonathan Watt.)
Note: The DirectX SDK installer may display an "S1023" error during the final installation step. You may be able to simply ignore this error and continue with the Mozilla build process. If the Mozilla build system still cannot locate the DirectX SDK, see this Microsoft support page.
MozillaBuild
The MozillaBuild package contains the other software prerequisites necessary for building Mozilla. This includes the MSYS build environment, Mercurial, autoconf-2.13, CVS, Python, YASM, NSIS, and UPX, as well as optional but useful tools such as wget and emacs.
Download the current MozillaBuild package.
By default, the package installs to c:\mozilla-build
. It is recommended to use the default path. Don't use a path that contains spaces. The installer does not modify the Windows registry. Note that some binaries may require Visual C++ Redistributable package to run.
Expectation setting: Note that the "UNIX-like" environment provided by MozillaBuild is only really useful for building and committing to the Mozilla source. Most command line tools you would expect in a modern Linux distribution are not present, and those tools that are provided can be as much as a decade or so old (especially those provided by MSYS). It's the old tools in particular that can cause problems, since they often don't behave as expected, are buggy, or don't support command line arguments that have been taken for granted for years. For example, copying a source tree using cp -rf src1 src2
does not work correctly because of an old version of cp (it gives "cp: will not create hard link" errors for some files). In short, MozillaBuild supports essential developer interactions with the Mozilla code, but beyond that don't be surprised if it trips you up in all sorts of exciting and unexpected ways.
The MozillaBuild package includes the "make" program that originated on the UNIX and Linux platforms. This version of make does not make use of Windows' multi-core architecture. pymake is a Python implementation of Make that uses Windows' multi-core architecture and thus significantly speeds up build time.