PKGBUILDs/extra/gjs/build-Link-with-libatomic-if-necessary.patch
2021-11-10 05:37:17 +00:00

61 lines
1.9 KiB
Diff

From: Simon McVittie <smcv@debian.org>
Date: Fri, 8 Oct 2021 11:42:49 +0100
Subject: build: Link with libatomic if necessary
The implementation of atomic operations in gcc uses atomic opcodes if
supported, but falls back to a library implementation if necessary.
Link that library on architectures where 64-bit atomic operations need it,
such as Debian armel (ARMv5 EABI softfloat), mipsel and powerpc.
Bug: https://gitlab.gnome.org/GNOME/gjs/-/issues/442
Bug-Debian: https://bugs.debian.org/995930
Forwarded: https://gitlab.gnome.org/GNOME/gjs/-/merge_requests/686
Signed-off-by: Simon McVittie <smcv@debian.org>
---
meson.build | 18 +++++++++++++++++-
1 file changed, 17 insertions(+), 1 deletion(-)
diff --git a/meson.build b/meson.build
index 6ded66c..e230a09 100644
--- a/meson.build
+++ b/meson.build
@@ -109,6 +109,8 @@ endif
### Check for required libraries ###############################################
+null_dep = dependency('', required : false)
+
# Note: Notify GNOME release team when adding or updating dependencies
glib_required_version = '>= 2.66.0'
glib = dependency('glib-2.0', version: glib_required_version,
@@ -180,6 +182,20 @@ features.''')
endif
endif
+if cxx.links('''
+#include <atomic>
+
+int main(void)
+{
+ std::atomic_int64_t value = ATOMIC_VAR_INIT(0);
+ return value.load();
+}
+''', name: '64-bit atomics built-in')
+ libatomic = null_dep
+else
+ libatomic = cc.find_library('atomic', required: false)
+endif
+
build_profiler = sysprof_capture.found() and not get_option('profiler').disabled()
profiler_deps = [sysprof_capture]
if build_profiler and not cxx.has_function('timer_settime')
@@ -458,7 +474,7 @@ module_resource_srcs = gnome.compile_resources('js-resources',
c_name: 'js_resources')
libgjs_dependencies = [glib, gobject, gthread, gio, gi, ffi, spidermonkey,
- readline]
+ readline, libatomic]
pkg_dependencies = [glib, gobject, gthread, gio, gi, ffi, spidermonkey]
libraries_private = []