Building SpiderMonkey for Windows

278 views Asked by At

I'm trying to build SpiderMonkey (32 bit) for Windows. Following the answer here, I performed the instructions here

The command line I used for building is:

PATH=$PATH:"/c/Program Files/LLVM/bin/" JS_STANDALONE=1 ../configure.in --enable-nspr-build --disable-jemalloc --disable-js-shell --disable-tests --target=i686-pc-mingw32 --host=i686-pc-mingw32 --with-libclang-path="C:/Program Files/LLVM/bin"

However, I'm getting various linker errors where SpiderMonkey doesn't find Rust encoding functions, such as:

lld-link: error: undefined symbol: _encoding_mem_convert_latin1_to_utf8_partial
referenced by c:\firefox_90_0\js\src\vm\CharacterEncoding.cpp:109 
..\Unified_cpp_js_src17.obj:(unsigned int __cdecl JS::DeflateStringToUTF8Buffer(class 
JSLinearString *, class mozilla::Span<char, 4294967295>))

After looking at SpiderMonkey config files (Cargo.toml files), it seems to me that during compilation SpiderMonkey should build jsrust.lib out of Rust bindings. but in fact this doesn't happen and I get the linker errors. any idea?

1

There are 1 answers

0
Raziel Anarki On

Yes, you are right, in that during compiling SpiderMonkey mach/mozbuild build jsrust.lib and link it into the resulting dll/js-shell executable.

Also, in my case, building jsrust.lib was also missing a bcrypt import.

this can be easily fixed by applying the following patch to the sources, which enables mozbuild to traverse into the js/rust directory, and fixes the aforementioned missing import too. (tested on esr91 and up):

--- a/js/src/moz.build
+++ b/js/src/moz.build
@@ -7,6 +7,10 @@
 include("js-config.mozbuild")
 include("js-cxxflags.mozbuild")

+if CONFIG["JS_STANDALONE"]:
+    DIRS += ["rust"]
+    include("js-standalone.mozbuild")
+
 # Directory metadata
 component_engine = ("Core", "JavaScript Engine")
 component_gc = ("Core", "JavaScript: GC")
@@ -51,10 +55,7 @@ if CONFIG["ENABLE_WASM_CRANELIFT"]:
     CONFIGURE_SUBST_FILES += ["rust/extra-bindgen-flags"]

 if not CONFIG["JS_DISABLE_SHELL"]:
-    DIRS += [
-        "rust",
-        "shell",
-    ]
+    DIRS += ["shell"]

     TEST_DIRS += [
         "gdb",
--- a/js/src/rust/moz.build
+++ b/js/src/rust/moz.build
@@ -37,4 +37,5 @@ elif CONFIG["OS_ARCH"] == "WINNT":
         "shell32",
         "userenv",
         "ws2_32",
+        "bcrypt"
     ]

(the patch is available as a gist alongside a tested mozbuild config, which builds a 32bit .dll, here: https://gist.github.com/razielanarki/a890f21a037312a46450e244beeba983 )