Commit 2477c7b0 authored by Xavier Claessens's avatar Xavier Claessens

Meson: add 'force_posix_threads' option

This allows building with posix threads on Windows. It is generally
better to use win32 threads implementation on Windows, but this option
can be used in case it causes issues, or for performance comparison for
example.

https://bugzilla.gnome.org/show_bug.cgi?id=784995
parent 4b82738f
Pipeline #11662 failed with stages
in 12 minutes and 3 seconds
......@@ -204,15 +204,15 @@ if host_system == 'windows'
)
glib_win_res = windows.compile_resources(glib_win_rc)
glib_sources += [glib_win_res]
glib_sources += files('gthread-win32.c')
glib_sources += files('gwin32.c', 'gspawn-win32.c', 'giowin32.c')
platform_deps = [winsock2, cc.find_library('winmm')]
else
glib_sources += files('gthread-posix.c')
glib_sources += files('glib-unix.c', 'gspawn.c', 'giounix.c')
platform_deps = []
endif
glib_sources += files('gthread-@0@.c'.format(threads_implementation))
if enable_dtrace
glib_dtrace_obj = dtrace_obj_gen.process('glib_probes.d')
glib_dtrace_hdr = dtrace_hdr_gen.process('glib_probes.d')
......
......@@ -1476,15 +1476,16 @@ endif
# === Threads ===
# Let meson figure out all this business and whether -pthread or whatnot is needed
# FIXME: probably needs more tweaking in meson for things like -D_REENTRANT etc.
thread_dep = dependency('threads')
# Determination of thread implementation
if host_system == 'windows'
if host_system == 'windows' and not get_option('force_posix_threads')
thread_dep = []
threads_implementation = 'win32'
glibconfig_conf.set('g_threads_impl_def', 'WIN32')
glib_conf.set('THREADS_WIN32', 1)
else
# FIXME: probably needs more tweaking in meson for things like -D_REENTRANT etc.
thread_dep = dependency('threads')
threads_implementation = 'posix'
pthread_prefix = '''
#ifndef _GNU_SOURCE
# define _GNU_SOURCE
......
......@@ -68,3 +68,8 @@ option('bsymbolic_functions',
type : 'boolean',
value : true,
description : 'link with -Bsymbolic-functions if supported')
option('force_posix_threads',
type : 'boolean',
value : false,
description : 'Also use posix threads in case the platform defaults to another implementation (on Windows for example)')
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment