JS (also referred as SpiderMonkey) is Mozilla's JavaScript and WebAssembly Engine, written in C++ and Rust. In BLFS, the source code of JS is taken from Firefox.
This package is known to build and work properly using an LFS 12.0 platform.
Download (HTTP): https://archive.mozilla.org/pub/firefox/releases/102.13.0esr/source/firefox-102.13.0esr.source.tar.xz
Download MD5 sum: 42b9a73626ed8281b86222f6f0a96c73
Download size: 464 MB
Estimated disk space required: 3.3 GB (38 MB installed after removing 34MB static lib)
Estimated build time: 1.7 SBU (with parallelism=4)
ICU-73.2, rustc-1.71.1, and Which-2.21
LLVM-16.0.5 (with Clang, required for 32-bit systems without SSE2 capabilities)
![[Important]](../images/important.png) 
          
            If you are building this package on a 32-bit system, and Clang is
            not installed or you're overriding the default compiler choice
            with the environment variable CXX,
            please read the Command Explanations section first.
          
![[Note]](../images/note.png) 
          
            Unlike most other packages in BLFS, the instructions below
            require you to untar firefox-102.13.0esr.tar.xz and change into the
            firefox-102.13.0 folder.
          
            Extracting the tarball will reset the permissions of the current
            directory to 0755 if you have permission to do that. If you do
            this in a directory where the sticky bit is set, such as
            /tmp it will end with error
            messages:
          
              tar: .: Cannot utime: Operation not permitted
              tar: .: Cannot change mode to rwxr-xr-t: Operation not permitted
              tar: Exiting with failure status due to previous errors
            
            This does finish with non-zero status, but it does NOT mean there is a real problem. Do
            not untar as the root user in a
            directory where the sticky bit is set - that will unset it.
          
Install JS by running the following commands:
![[Note]](../images/note.png) 
          
            If you are compiling this package in chroot you must do two
            things. First, as the root user,
            ensure that /dev/shm is mounted. If
            you do not do this, the Python
            configuration will fail with a traceback report referencing
            /usr/lib/pythonN.N/multiprocessing/synchronize.py.
            Run:
          
mountpoint -q /dev/shm || mount -t tmpfs devshm /dev/shm
            Second, either as the root user
            export the $SHELL environment variable
            using export
            SHELL=/bin/sh or else prepend SHELL=/bin/sh when running the configure command.
          
Compiling the C++ code respects $MAKEFLAGS and defaults to 'j1', the rust code will use all processors.
mkdir obj &&
cd    obj &&
sh ../js/src/configure.in --prefix=/usr            \
                          --with-intl-api          \
                          --with-system-zlib       \
                          --with-system-icu        \
                          --disable-jemalloc       \
                          --disable-debug-symbols  \
                          --enable-readline        &&
make
        To run the JS test suite, issue: make -C js/src check-jstests JSTESTS_EXTRA_ARGS="--timeout 300 --wpt=disabled". It's recommended to redirect the output into a log. Because we are building with system ICU, more than one hundred tests (out of a total of more than 50,000) are known to fail.
To run the JIT test suite, issue: make -C js/src check-jit-test JITTEST_EXTRA_ARGS="--timeout 300".
![[Caution]](../images/caution.png) 
          An issue in the installation process causes any running program which links to JS102 shared library (for example, GNOME Shell) to crash if JS102 is upgraded or reinstalled. To work around this issue, remove the old version of the JS102 shared library before installation:
rm -fv /usr/lib/libmozjs-102.so
          Now, as the root user:
        
make install && rm -v /usr/lib/libjs_static.ajs && sed -i '/@NSPR_CFLAGS@/d' /usr/bin/js102-config
          sh
          ../js/src/configure.in: configure.in is actually a shell script, but the
          executable bit is not set in its permission mode so it's needed to
          explicitly run it with sh.
        
          --with-intl-api: This
          enables the internationalization functions required by Gjs.
        
          --with-system-*: These
          parameters allow the build system to use system versions of the
          above libraries. These are required for stability.
        
          --enable-readline: This
          switch enables Readline support in the JS shell.
        
          --disable-jemalloc: This
          switch disables the internal memory allocator used in JS102.
          jemalloc is only intended for the Firefox browser environment. For
          other applications using JS102, the application may crash as items
          allocated in the jemalloc allocator are freed on the system (glibc)
          allocator.
        
          --disable-debug-symbols:
          Don't generate debug symbols since they are very large and most
          users won't need it. Remove it if you want to debug JS102.
        
rm -v /usr/lib/libjs_static.ajs: Remove a large static library which is not used by any BLFS package.
sed -i '/@NSPR_CFLAGS@/d' /usr/bin/js102-config: Prevent js102-config from using buggy CFLAGS.
          CC=gcc
          CXX=g++
          CXXFLAGS="-msse2
          -mfpmath=sse"