I have build spiderMonkey(esr78) in windows by following the steps mentioned in official documentation. For more info regarding build process see this link, https://firefox-source-docs.mozilla.org/setup/windows_build.html#building-firefox-on-windows
When I’m tryiing to build my testapp.cpp using spiderMonkey in visual studio 2019,it’s giving compilation error from GCPolicyAPI.h(line:70) whenever i’m adding jsapi.h in my program.
Error: error C2338: Pointer type not allowed for StructGCPolicy
If I remove “jsapi.h” the program compiles and runs fine.
// testapp.cpp:
#include <jsapi.h> #include <js/Initialization.h>
int main(void) {
if (!JS_Init()) return 1;
JS_ShutDown();
return 0;
}
[Note: preprocessor used: STATIC_JS_API in project properties]
Can anyone please help me on this, what’s wrong I’m doing here?
We’ve run into this as well, and work around it by defining a specialization of GCPolicy<void*> wherever GCPolicyAPI.h is included. (See link below.) Looks like you might be including it indirectly and that’s why this is happening.
from 85 ( https://bugzilla.mozilla.org/show_bug.cgi?id=1679736 ), the problematic case uses JS::detail::RootListEntry* instead of void*.
So, the workaround for MSVC needs to define the speciallization for detail::RootListEntry* instead of void*.
With both of these fixed, I am able to build a simple spidermonkey DLL demo on Windows. I am testing with v91 (the next upcoming ESR).
I also used the mach build workflow described here. I had to use ac_add_options --disable-jemalloc for embedding to avoid needing the more complicated build steps that Firefox uses.
I’ve filed Bug 1716247 to fix the GCPolicyAPI stuff on MSVC (and make the code less gross for everyone…). We should be able to get this small fixes into the ESR-91 version so at a first approximation MSVC should work for external embedders (though probably want to compile spidermonkey itself with the normal clang workflow…).