Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/videolan/dav1d.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMehdi Sabwat <mehdi@videolabs.io>2021-07-05 20:18:54 +0300
committerJean-Baptiste Kempf <jb@videolan.org>2021-07-15 11:37:32 +0300
commit5808975341835008b06501270377b3b247188ed5 (patch)
tree645ac95a027e516a768e21018549c347a3466e32 /meson.build
parent35aa1c226b21a7b8cf44cdef636c8a8d26d58062 (diff)
build : enable atomics for wasm-emscripten
When targetting wasm32-unknown-emscripten, we need to have the -pthread option during compilation for all the objects that use atomic instructions. When -pthread option is used on a object that has atomic instructions, a section is added to the binary notifying the linker that it is safe to use shared linear memory because atomic instructions were not stripped (default behavior if the option is not set). cf. https://github.com/WebAssembly/tool-conventions/blob/master/Linking.md#target-features-section Before this patch, lib.c and thread_task.c were using atomic instructions but since -pthread was not passed during compilation a section was added to the binary, disallowing shared linear memory and preventing linking dav1d with a multi threaded wasm application. It also renames stdatomic_dependency to stdatomic_dependencies, for clarity because it is now an array of dependency objects. cf. https://mesonbuild.com/Reference-manual.html#dependency-object
Diffstat (limited to 'meson.build')
-rw-r--r--meson.build11
1 files changed, 8 insertions, 3 deletions
diff --git a/meson.build b/meson.build
index 334d8c2..8a9d4c6 100644
--- a/meson.build
+++ b/meson.build
@@ -173,16 +173,16 @@ libm_dependency = cc.find_library('m', required: false)
# Header checks
-stdatomic_dependency = []
+stdatomic_dependencies = []
if not cc.check_header('stdatomic.h')
if cc.get_id() == 'msvc'
# we have a custom replacement for MSVC
- stdatomic_dependency = declare_dependency(
+ stdatomic_dependencies += declare_dependency(
include_directories : include_directories('include/compat/msvc'),
)
elif cc.compiles('''int main() { int v = 0; return __atomic_fetch_add(&v, 1, __ATOMIC_SEQ_CST); }''',
name : 'GCC-style atomics', args : test_args)
- stdatomic_dependency = declare_dependency(
+ stdatomic_dependencies += declare_dependency(
include_directories : include_directories('include/compat/gcc'),
)
else
@@ -190,6 +190,11 @@ if not cc.check_header('stdatomic.h')
endif
endif
+if host_machine.cpu_family().startswith('wasm')
+ # enable atomics + bulk-memory features
+ stdatomic_dependencies += thread_dependency.partial_dependency(compile_args: true)
+endif
+
if cc.check_header('unistd.h')
cdata.set('HAVE_UNISTD_H', 1)
endif