[gjs] build: Autodetect SpiderMonkey's debug mode
- From: Philip Chimento <pchimento src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gjs] build: Autodetect SpiderMonkey's debug mode
- Date: Sat, 6 May 2017 06:24:06 +0000 (UTC)
commit 8a0bba5173ec7c052a6279a51e8d4613a7669911
Author: Philip Chimento <philip chimento gmail com>
Date: Mon May 1 23:16:43 2017 -0700
build: Autodetect SpiderMonkey's debug mode
We currently check whether JS_DEBUG was defined in js-config.h in order to
decide whether to define DEBUG. (It's a long-standing bug in SpiderMonkey
headers that you have to define DEBUG before including them if SpiderMonkey
is in debug mode.)
That will not be possible in SpiderMonkey 52. In an effort to mitigate the
bug, it will error out if you include js-config.h without defining DEBUG
when you are supposed to (or having defined DEBUG when you are not supposed
to.) So, our method of checking will not work anymore.
Instead, run a configure-time check that generates an #error if JS_DEBUG is
defined in js-config.h, and define a symbol in config.h. This check will
also work in the SpiderMonkey 52 case, since including js-config.h will
also error out if JS_DEBUG is defined.
https://bugzilla.gnome.org/show_bug.cgi?id=781429
configure.ac | 17 +++++++++++++++++
gjs/jsapi-wrapper.h | 7 +++++--
2 files changed, 22 insertions(+), 2 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 43e1e3d..31f2df1 100644
--- a/configure.ac
+++ b/configure.ac
@@ -187,6 +187,23 @@ AC_ARG_ENABLE([Bsymbolic],
AS_IF([test "x$enable_Bsymbolic" != "xno"],
[AX_APPEND_LINK_FLAGS([-Bsymbolic-functions])])
+dnl If SpiderMonkey was compiled with --enable-debug, then we need to define
+dnl -DDEBUG before including js-config.h.
+AC_MSG_CHECKING([whether SpiderMonkey was configured with --enable-debug])
+CPPFLAGS_save="$CPPFLAGS"
+CPPFLAGS="$GJS_CFLAGS"
+AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
+#include <js-config.h>
+#ifdef JS_DEBUG
+#error debug yes, if we didn't already error out due to DEBUG not being defined
+#endif
+]])], [AC_MSG_RESULT([no])], [
+ AC_DEFINE([HAVE_DEBUG_SPIDERMONKEY], [1],
+ [Define to 1 if SpiderMonkey was compiled with --enable-debug])
+ AC_MSG_RESULT([yes])
+])
+CPPFLAGS="$CPPFLAGS_save"
+
dnl If SpiderMonkey was compiled with this configure option, then GJS needs to
dnl be compiled with it as well, because we inherit from a SpiderMonkey class in
dnl jsapi-constructor-proxy.cpp. See build/autoconf/compiler-opts.m4 in mozjs31.
diff --git a/gjs/jsapi-wrapper.h b/gjs/jsapi-wrapper.h
index 9c64ec6..11bdadb 100644
--- a/gjs/jsapi-wrapper.h
+++ b/gjs/jsapi-wrapper.h
@@ -25,13 +25,16 @@
#ifndef GJS_JSAPI_WRAPPER_H
#define GJS_JSAPI_WRAPPER_H
-#include <js-config.h> /* SpiderMonkey's #defines that affect public API */
+#include <config.h>
+
/* COMPAT: SpiderMonkey headers in some places use DEBUG instead of JS_DEBUG */
/* https://bugzilla.mozilla.org/show_bug.cgi?id=1261161 */
-#if defined(JS_DEBUG) && JS_DEBUG
+#ifdef HAVE_DEBUG_SPIDERMONKEY
#define DEBUG 1
#endif
+#include <js-config.h> /* SpiderMonkey's #defines that affect public API */
+
#if defined(__clang__) || __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)
#pragma GCC system_header
#endif
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]