[gjs] build: Disable glib assertions via G_DISABLE_ASSERT on release builds
- From: Philip Chimento <pchimento src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gjs] build: Disable glib assertions via G_DISABLE_ASSERT on release builds
- Date: Wed, 26 May 2021 04:27:55 +0000 (UTC)
commit 603d08fa31a409bd0af5de09e92a930968041551
Author: Marco Trevisan (TreviƱo) <mail 3v1n0 net>
Date: Wed May 19 17:20:19 2021 +0200
build: Disable glib assertions via G_DISABLE_ASSERT on release builds
gjs/internal.cpp | 7 ++++---
gjs/module.cpp | 3 ++-
meson.build | 18 ++++++++++--------
util/misc.h | 6 ++++++
4 files changed, 22 insertions(+), 12 deletions(-)
---
diff --git a/gjs/internal.cpp b/gjs/internal.cpp
index 1c1a57de..dff83e47 100644
--- a/gjs/internal.cpp
+++ b/gjs/internal.cpp
@@ -45,6 +45,7 @@
#include "gjs/module.h"
#include "gjs/native.h"
#include "util/log.h"
+#include "util/misc.h"
#include "gi/repo.h"
@@ -501,7 +502,7 @@ class PromiseData {
//
https://searchfox.org/mozilla-central/rev/95cf843de977805a3951f9137f5ff1930599d94e/js/src/builtin/Promise.cpp#4435
void reject_with_pending_exception() {
JS::RootedValue exception(cx);
- bool ok = JS_GetPendingException(cx, &exception);
+ bool ok GJS_USED_ASSERT = JS_GetPendingException(cx, &exception);
g_assert(ok && "Cannot reject a promise with an uncatchable exception");
JS::RootedValueArray<1> args(cx);
@@ -516,8 +517,8 @@ class PromiseData {
JS::RootedValueArray<1> args(cx);
args[0].set(result);
JS::RootedValue ignored_rval(cx);
- bool ok = JS_CallFunction(cx, /* this_obj = */ nullptr, resolver(),
- args, &ignored_rval);
+ bool ok GJS_USED_ASSERT = JS_CallFunction(
+ cx, /* this_obj = */ nullptr, resolver(), args, &ignored_rval);
g_assert(ok && "Failed resolving promise");
}
};
diff --git a/gjs/module.cpp b/gjs/module.cpp
index 61bc4e9a..2c0840f7 100644
--- a/gjs/module.cpp
+++ b/gjs/module.cpp
@@ -42,6 +42,7 @@
#include "gjs/module.h"
#include "gjs/native.h"
#include "util/log.h"
+#include "util/misc.h"
class GjsScriptModule {
char *m_name;
@@ -535,7 +536,7 @@ static bool finish_import(JSContext* cx, const JS::CallArgs& args) {
JS::RootedValue importing_module_priv(cx);
JS::RootedValue v_specifier(cx);
JS::RootedValue v_internal_promise(cx);
- bool ok =
+ bool ok GJS_USED_ASSERT =
JS_GetProperty(cx, callback_data, "priv", &importing_module_priv) &&
JS_GetProperty(cx, callback_data, "promise", &v_internal_promise) &&
JS_GetProperty(cx, callback_data, "specifier", &v_specifier);
diff --git a/meson.build b/meson.build
index 828f30bd..bf767296 100644
--- a/meson.build
+++ b/meson.build
@@ -25,7 +25,8 @@ if get_option('systemtap') and not get_option('dtrace')
error('-Ddtrace=true is required for -Dsystemtap=true')
endif
-if get_option('buildtype').startswith('release') and get_option('verbose_logs')
+release_build = get_option('buildtype').startswith('release')
+if release_build and get_option('verbose_logs')
error('-Dverbose_logs=true is not allowed with --buildtype=release')
endif
@@ -102,7 +103,7 @@ if get_option('verbose_logs')
], language: 'cpp')
endif
-if get_option('buildtype').startswith('release')
+if release_build
add_project_arguments('-DG_DISABLE_CAST_CHECKS', language: ['c', 'cpp'])
endif
@@ -225,7 +226,7 @@ if not nondebug_spidermonkey
debug_arg = ['-DDEBUG'] # for compile tests
endif
-if get_option('buildtype').startswith('release') and not nondebug_spidermonkey
+if release_build and not nondebug_spidermonkey
error('''You are trying to make a release
build with a debug-enabled copy of SpiderMonkey. This is probably not what you
want, since it will have bad performance and is not binary-compatible with
@@ -507,14 +508,15 @@ base_build_dep = declare_dependency(
compile_args: libgjs_cpp_args,
dependencies: libgjs_dependencies)
-internal_build_dep = [base_build_dep]
-if build_profiler
- internal_build_dep += profiler_deps
-endif
+internal_build_dep = declare_dependency(
+ compile_args: (release_build ? ['-DG_DISABLE_ASSERT'] : []),
+ dependencies: [
+ base_build_dep,
+ build_profiler ? profiler_deps : [],
+ ])
libgjs_jsapi = static_library(meson.project_name() + '-jsapi',
libgjs_jsapi_sources, probes_header, probes_objfile,
- cpp_args: libgjs_cpp_args,
cpp_pch: pch_headers,
dependencies: internal_build_dep,
install: false)
diff --git a/util/misc.h b/util/misc.h
index 4c7cde3a..6c9b4712 100644
--- a/util/misc.h
+++ b/util/misc.h
@@ -11,6 +11,12 @@
#include <glib.h> // for g_malloc
+#ifdef G_DISABLE_ASSERT
+# define GJS_USED_ASSERT [[maybe_unused]]
+#else
+# define GJS_USED_ASSERT
+#endif
+
bool gjs_environment_variable_is_set (const char *env_variable_name);
char** gjs_g_strv_concat(char*** strv_array, int len);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]