mirror of
https://github.com/mpv-player/mpv
synced 2024-12-19 13:21:13 +00:00
build: use -pthread when available
Our code currently tries to link -lpthread and adds stuff like -D_REENTRANT based on the target platform. GCC actually supports to just pass a -pthread compiler and linker flag that will automatically enable threading and define the correct symbols for the platform, so let's try to just use that as our first choice. clang also supports -pthread but it must be used only as a compiler flag, so we also take care of that scenario with this commit.
This commit is contained in:
parent
ae0c8ca219
commit
ce48da9e02
@ -8,7 +8,20 @@ __all__ = ["check_pthreads", "check_iconv", "check_lua", "check_oss_4front",
|
||||
|
||||
pthreads_program = load_fragment('pthreads.c')
|
||||
|
||||
def check_pthread_flag(ctx, dependency_identifier):
|
||||
checks = [
|
||||
check_cc(fragment = pthreads_program, cflags = '-pthread'),
|
||||
check_cc(fragment = pthreads_program, cflags = '-pthread',
|
||||
linkflags = '-pthread') ]
|
||||
|
||||
for fn in checks:
|
||||
if fn(ctx, dependency_identifier):
|
||||
return True
|
||||
return False
|
||||
|
||||
def check_pthreads(ctx, dependency_identifier):
|
||||
if check_pthread_flag(ctx, dependency_identifier):
|
||||
return True
|
||||
platform_cflags = {
|
||||
'linux': '-D_REENTRANT',
|
||||
'freebsd': '-D_THREAD_SAFE',
|
||||
|
Loading…
Reference in New Issue
Block a user