I noticed something while examining the executable with the statically linked JS: It exports hundreds of JS_* functions and many with C++ mangled names too, all from the JS library. If the reason we are building this exe is to avoid presenting a js32ECMAv5.dll as part of the binary distribution, then I think that exporting practically the entire JS library from the exe is more sus than the dll. If I were Microsoft and saw all those exports in the exe I would be asking for clarifications.
I don't have the exe handy now but tomorrow I will post a screenshot of what gets exported. Normally the Oolite executable (and most games executables for that matter) are expected to export just 2 functions: The NVidia and AMD functions required in dual-GPU laptops for telling the gfx driver that the discreet GPU must be used for the game.
It's certainly good that we now know how to use static JS linking if we want to, but I would recommend not replacing the dll with static linking at this stage. It just seems more straightforward if the js dll is separate and the exe remains "clean".
That is most likely related to the settings used when configure was called. I see in the configure script:
# Check whether --enable-shared-js or --disable-shared-js was given.
if test "${enable_shared_js+set}" = set; then
enableval="$enable_shared_js"
if test "$enableval" = "yes"; then
DISABLE_SHARED_JS=0
elif test "$enableval" = "no"; then
DISABLE_SHARED_JS=1
else
{ echo "configure: error: Option, shared-js, does not take an argument ($enableval)." 1>&2; exit 1; }
fi
fi
if test "$DISABLE_SHARED_JS" = "1" ; then
cat >> confdefs.h <<\EOF
#define STATIC_EXPORTABLE_JS_API 1
EOF
else
JS_SHARED_LIBRARY=1
fi
I noticed something while examining the executable with the statically linked JS: It exports hundreds of JS_* functions and many with C++ mangled names too, all from the JS library. If the reason we are building this exe is to avoid presenting a js32ECMAv5.dll as part of the binary distribution, then I think that exporting practically the entire JS library from the exe is more sus than the dll. If I were Microsoft and saw all those exports in the exe I would be asking for clarifications.
I don't have the exe handy now but tomorrow I will post a screenshot of what gets exported. Normally the Oolite executable (and most games executables for that matter) are expected to export just 2 functions: The NVidia and AMD functions required in dual-GPU laptops for telling the gfx driver that the discreet GPU must be used for the game.
It's certainly good that we now know how to use static JS linking if we want to, but I would recommend not replacing the dll with static linking at this stage. It just seems more straightforward if the js dll is separate and the exe remains "clean".
The debug build of Oolite (make debug=yes) is currently broken for the modern and legacy builds with the static js update. Modern was broken also prior because there was no libjs32ECMAv5dbg library to link against and the release js - static or not - is not suitable for linking with the game's debug build.
The solution would be to create also a debug static js flavor and include it in the build system. That would allow successful linking. Note that for the debug build to work when using the debug static JS, Oolite must be built with the macro STATIC_JS_API defined.
Having looked at the debug legacy build a bit, the JS debug static import library is 30MB in size. I don't think I'd want to check-in to github a binary of that size. Maybe it would be preferable if we keep the debug build linked to the js32ECMAv5dbg.dll That build is not for any kind of distribution anyway and is only expected to be used by developers for internal testing.
We'd still need the modern build equivalent of js32ECMAv5dbg.dll though.
Having looked at the debug legacy build a bit, the JS debug static import library is 30MB in size. I don't think I'd want to check-in to github a binary of that size. Maybe it would be preferable if we keep the debug build linked to the js32ECMAv5dbg.dll That build is not for any kind of distribution anyway and is only expected to be used by developers for internal testing.
We'd still need the modern build equivalent of js32ECMAv5dbg.dll though.
I'll try adding the debug dll and static lib to the Spidermonkey package so it can be installed by pacman.
Please make sure that the libjs32ECMAv5.dll.a import library for the debug dll is included too. This is the one to be used for the make debug=yes build.
Please make sure that the libjs32ECMAv5.dll.a import library for the debug dll is included too. This is the one to be used for the make debug=yes build.