From 5bd7b74ec7ddbaefe21b2eec596d5a1f6b9bc4ad Mon Sep 17 00:00:00 2001 From: Ykkrosh Date: Mon, 14 Nov 2011 18:18:04 +0000 Subject: [PATCH] Fix ABI incompatibility with --with-system-mozjs185 in debug mode (see #990). This was SVN commit r10535. --- build/premake/extern_libs4.lua | 1 + source/scripting/ScriptGlue.cpp | 4 ++-- source/scriptinterface/ScriptInterface.cpp | 2 +- source/scriptinterface/ScriptTypes.h | 22 ++++++++++++++++++- .../tools/atlas/AtlasScript/ScriptInterface.h | 7 ++++++ 5 files changed, 32 insertions(+), 4 deletions(-) diff --git a/build/premake/extern_libs4.lua b/build/premake/extern_libs4.lua index 8a1e953241..24abc8b2e3 100644 --- a/build/premake/extern_libs4.lua +++ b/build/premake/extern_libs4.lua @@ -472,6 +472,7 @@ extern_lib_defs = { compile_settings = function() if _OPTIONS["with-system-mozjs185"] then pkgconfig_cflags("mozjs185") + defines { "WITH_SYSTEM_MOZJS185" } else if os.is("windows") then include_dir = "include-win32" diff --git a/source/scripting/ScriptGlue.cpp b/source/scripting/ScriptGlue.cpp index 22fe06a21a..d433aee30a 100644 --- a/source/scripting/ScriptGlue.cpp +++ b/source/scripting/ScriptGlue.cpp @@ -274,7 +274,7 @@ JSBool GetBuildTimestamp(JSContext* cx, uintN argc, jsval* vp) return JS_TRUE; } -#ifdef DEBUG +#if MOZJS_DEBUG_ABI void DumpHeap(const char* basename, int idx, JSContext* cx) { char filename[64]; @@ -292,7 +292,7 @@ JSBool DumpHeaps(JSContext* cx, uintN argc, jsval* vp) UNUSED2(cx); UNUSED2(argc); -#ifdef DEBUG +#if MOZJS_DEBUG_ABI static int i = 0; if (ScriptingHost::IsInitialised()) diff --git a/source/scriptinterface/ScriptInterface.cpp b/source/scriptinterface/ScriptInterface.cpp index b5ae9bcd3a..f260c30e29 100644 --- a/source/scriptinterface/ScriptInterface.cpp +++ b/source/scriptinterface/ScriptInterface.cpp @@ -1099,7 +1099,7 @@ void* ScriptInterface::GetPrivate(JSContext* cx, JSObject* obj) void ScriptInterface::DumpHeap() { -#ifdef DEBUG +#if MOZJS_DEBUG_ABI JS_DumpHeap(m->m_cx, stderr, NULL, 0, NULL, (size_t)-1, NULL); #endif fprintf(stderr, "# Bytes allocated: %d\n", JS_GetGCParameter(GetRuntime(), JSGC_BYTES)); diff --git a/source/scriptinterface/ScriptTypes.h b/source/scriptinterface/ScriptTypes.h index 5134f5f712..b5634e0fd5 100644 --- a/source/scriptinterface/ScriptTypes.h +++ b/source/scriptinterface/ScriptTypes.h @@ -33,11 +33,31 @@ // the ones that are needed and this avoids conflicting definitions # define JS_SYS_TYPES_H_DEFINES_EXACT_SIZE_TYPES -#else +#else // If not Windows, then Unix: + # define XP_UNIX + +// In DEBUG mode, jsval defaults to struct types. Normally we build separate +// debug/release mode versions of the library, but when using --with-system-mozjs185 +// it's always a release mode library, so we have to disable struct types for +// ABI compatibility +# if defined(DEBUG) && defined(WITH_SYSTEM_MOZJS185) +# define JS_NO_JSVAL_JSID_STRUCT_TYPES +# endif + #endif // (we don't support XP_OS2 or XP_BEOS) + +// Guess whether the library was compiled with the release-mode or debug-mode ABI +// (for JS_DumpHeap etc) +#if defined(DEBUG) && !defined(WITH_SYSTEM_MOZJS185) +# define MOZJS_DEBUG_ABI 1 +#else +# define MOZJS_DEBUG_ABI 0 +#endif + + #include // required by jsutil.h // SpiderMonkey wants the DEBUG flag diff --git a/source/tools/atlas/AtlasScript/ScriptInterface.h b/source/tools/atlas/AtlasScript/ScriptInterface.h index 7dd4b08416..7461425cfa 100644 --- a/source/tools/atlas/AtlasScript/ScriptInterface.h +++ b/source/tools/atlas/AtlasScript/ScriptInterface.h @@ -28,7 +28,14 @@ # define JS_NO_JSVAL_JSID_STRUCT_TYPES #else + # define XP_UNIX + +// (See comment in scriptinterface/ScriptTypes.h) +# if defined(DEBUG) && defined(WITH_SYSTEM_MOZJS185) +# define JS_NO_JSVAL_JSID_STRUCT_TYPES +# endif + #endif // (we don't support XP_OS2 or XP_BEOS) #ifdef __GNUC__