Skip to content

Commit

Permalink
zstd: don't add -pthread to static linking flags on Windows
Browse files Browse the repository at this point in the history
Meson always returns -pthread in dependency('threads') on non-MSVC
compilers.  On Windows, zstd uses Windows threading primitives, so we
don't need this.  Avoid adding -pthread to libzstd's link flags, either as
a Meson subproject or via pkg-config Libs.private, so the application
doesn't inadvertently depend on winpthreads.

Merged upstream in facebook/zstd#3931.
  • Loading branch information
bgilbert authored and Will Wray committed Apr 22, 2024
1 parent e35cba0 commit eb2211a
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
1 change: 1 addition & 0 deletions releases.json
Original file line number Diff line number Diff line change
Expand Up @@ -3548,6 +3548,7 @@
"libzstd"
],
"versions": [
"1.5.6-2",
"1.5.6-1",
"1.5.5-1",
"1.5.4-1",
Expand Down
9 changes: 7 additions & 2 deletions subprojects/packagefiles/zstd/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,13 @@ feature_lz4 = get_option('lz4')
# =============================================================================

libm_dep = cc.find_library('m', required: false)
thread_dep = dependency('threads', required: feature_multi_thread)
use_multi_thread = thread_dep.found()
if host_machine_os == os_windows
thread_dep = dependency('', required: false)
use_multi_thread = not feature_multi_thread.disabled()
else
thread_dep = dependency('threads', required: feature_multi_thread)
use_multi_thread = thread_dep.found()
endif
# Arguments in dependency should be equivalent to those passed to pkg-config
zlib_dep = dependency('zlib', required: feature_zlib)
use_zlib = zlib_dep.found()
Expand Down
2 changes: 1 addition & 1 deletion subprojects/packagefiles/zstd/meson_options.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ option('bin_contrib', type: 'boolean', value: false,
description: 'Enable contrib build')

option('multi_thread', type: 'feature', value: 'enabled',
description: 'Enable multi-threading when pthread is detected')
description: 'Enable multi-threading when pthread or Windows is detected')
option('zlib', type: 'feature', value: 'auto',
description: 'Enable zlib support')
option('lzma', type: 'feature', value: 'auto',
Expand Down

0 comments on commit eb2211a

Please sign in to comment.