NSS Build failure due to assembly code Windows 10 64bit machine

1.1k Views Asked by At

I am building 64-bit nss 3.39 on Windows 10 with Microsoft Visual Studio 2017. It failed with the error:

error C4235: nonstandard extension used : '__asm' keyword not supported on this architecture

Has anyone faced this issue? Need solution on this.

Steps I followed:

  1. Installed Visual Studio 2017 (Enterprise trial edition) as mentioned in the Windows Prerequisites for Firefox build.
  2. Installed Rust.
  3. Installed MozillaBuild, downloaded from MozillaBuild Package.
  4. Downloaded the NSS package of release 3.39 (nss-3.39-with-nspr-4.20.tar.gz) from http://ftp.mozilla.org/pub/security/nss/releases/NSS_3_39_RTM/
  5. Created a directory C:\src Extracted nss to c:/src (this looks like C:/src/nss-3.39)
  6. Run the C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\VC\Auxiliary\Build\vcvars64.bat
  7. Run C:\mozilla-build\start-shell.bat
  8. Set MOZ_NO_RESET_PATH=1 so this will not override the PATH variable.
  9. Created the required env variables,

    export OS_TARGET=WIN95
    export BUILD_OPT=1
    export HOME="/c/src"
    
  10. cd ~ (To bring me into my home directory).

  11. Now cd into the nss-3.5\nss Build using make nss_build_all

Now with these options: USE_64=1 BUILD_OPT=1 make nss_build_all I am getting the following error:

gtest/include/gtest/internal/gtest-port.h(999): error C2220: warning treated as error - no 'object' file generated... [some build messages]...
make[2]: *** [WIN954.0_x86_64_64_OPT.OBJ/gtest/src/gtest-all.obj] Error 2
make[2]: Leaving directory /c/src/nss-3.39/nss/gtests/google_test'
make[1]: *** [libs] Error 2
make[1]: Leaving directory /c/src/nss-3.39/nss/gtests'
make: *** [libs] Error 2
1

There are 1 best solutions below

0
On

Installing CYGWIN and disabling 'gtests' worked for me. To disable GTests, set NSS_DISABLE_GTESTS=1

Here are some troubleshooting:

  1. If you get following errors which are due to lack of some libraries and includes then remove two variables from C:\mozilla-build\start-shell.bat (basically, you should not initialize them with empty values so it can pick up required libraries from Windows)

    SET INCLUDE=
    SET LIB=
    

    Error Ex.:

    c:\src\nss-3.39\nss\cpputil\databuffer.h(10): fatal error C1083: Cannot open include file: 'algorithm': No such file or directory
    make[1]: *** [WINNT6.2_x86_64_64_OPT.OBJ/databuffer.obj] Error 2
    make[1]: Leaving directory `/c/src/nss-3.39/nss/cpputil'
    make: *** [libs] Error 2
    

    Re-execute steps from step 8 onwards.

  2. If your build is failed due to assembly code/assembly keywords then install some assembly compiler(I have installed CYGWIN) and add into your path or set CYGWIN variable value in C:\mozilla-build\start-shell.bat.

    Error Ex.:

    error C4235: nonstandard extension used : '__asm' keyword not supported on this architecture
    

    This happens because inline asm on 64-bit development is not a supported scenario by VS2017.

  3. NSS 3.39 is using gtest 1.7 and it throws TR1 deprecation warnings. This could lead into build failure. If you see error like following then by disabling 'gtests', you can compile NSS successfully. To do this, before starting build set NSS_DISABLE_GTESTS=1

    Error Ex.:

    gtest/include/gtest/internal/gtest-port.h(999): error C2220: warning treated as error - no 'object' file generated
    gtest/include/gtest/internal/gtest-port.h(999): warning C4996: 'std::tr1': warning STL4002: The non-Standard std::tr1 namespace and TR1-only machinery are deprecated and will be REMOVED. You can define _SILENCE_TR1_NAMESPACE_DEPRECATION_WARNING to acknowledge that you have received this warning
    

    Though this issue has been fixed into Mozilla build system project, it is not reflected in NSS. I think, NSS needs to be updated to use gtest 1.8.

Following are the steps I followed to build NSSv3.39 (with NSPR) successfully on Windows 10 (64-bit) with VS2017.

  1. Installed Visual Studio 2017 (Enterprise trial edition) as mentioned in the Windows Prerequisites for Firefox build.
  2. Installed Rust.
  3. Installed MozillaBuild, downloaded from MozillaBuild Package.
  4. Installed CYGWIN.
  5. Download the NSS package of release 3.39 (nss-3.39-with-nspr-4.20.tar.gz) from
  6. Created a directory C:\src
  7. Extracted nss to c:/src (this is looking like C:/src/nss-3.39)
  8. Run the

    C:\Program Files (x86)\Microsoft Visual
    Studio\2017\Enterprise\VC\Auxiliary\Build\vcvars64.bat
    
  9. Run C:\mozilla-build\start-shell.bat

  10. Set MOZ_NO_RESET_PATH=1 so this will not override the PATH variable.
  11. Created the required env variables,

    export OS_TARGET=WINNT
    export USE_64=1
    export BUILD_OPT=1
    export NSS_DISABLE_GTESTS=1
    export HOME="/c/src"
    
  12. cd ~ (To bring into home directory).

  13. Now cd into the nss-3.5\nss
  14. Build using make nss_build_all