Skip to content

Commit 1232d4c

Browse files
authored
Merge pull request #3931 from bgilbert/pthread
meson: don't add `-pthread` to static linking flags on Windows
2 parents da797d0 + 5be2a87 commit 1232d4c

File tree

3 files changed

+52
-3
lines changed

3 files changed

+52
-3
lines changed

.github/workflows/dev-short-tests.yml

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,50 @@ jobs:
237237
meson test -C builddir/ --print-errorlogs
238238
meson install -C builddir --destdir staging/
239239
240+
meson-mingw-cross-compilation:
241+
runs-on: ubuntu-latest
242+
steps:
243+
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # tag=v4.1.1
244+
- name: Install packages
245+
run: |
246+
sudo apt-get -qqq update
247+
sudo apt-get -y install build-essential python3-pip ninja-build {gcc,g++}-mingw-w64-x86-64
248+
pip install --pre meson
249+
- name: Build with Meson
250+
run: |
251+
cat > cross.ini <<EOF
252+
[binaries]
253+
ar = 'x86_64-w64-mingw32-ar'
254+
c = 'x86_64-w64-mingw32-gcc'
255+
cpp = 'x86_64-w64-mingw32-g++'
256+
ld = 'x86_64-w64-mingw32-ld'
257+
objcopy = 'x86_64-w64-mingw32-objcopy'
258+
objdump = 'x86_64-w64-mingw32-objdump'
259+
strip = 'x86_64-w64-mingw32-strip'
260+
windres = 'x86_64-w64-mingw32-windres'
261+
262+
[host_machine]
263+
system = 'windows'
264+
endian = 'little'
265+
cpu_family = 'x86_64'
266+
cpu = 'x86_64'
267+
EOF
268+
269+
# pzstd doesn't build; skip -Dbin_contrib=true
270+
meson setup \
271+
--buildtype=debugoptimized \
272+
--cross-file=cross.ini \
273+
-Db_lundef=false \
274+
-Dbin_programs=true \
275+
-Dbin_tests=true \
276+
-Ddefault_library=both \
277+
build/meson builddir
278+
ninja -C builddir/
279+
if grep -- -pthread builddir/meson-private/libzstd.pc; then
280+
echo "Error: found stray pthread dependency"
281+
exit 1
282+
fi
283+
240284
meson-windows:
241285
runs-on: windows-latest
242286
steps:

build/meson/meson.build

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,13 @@ feature_lz4 = get_option('lz4')
8888
# =============================================================================
8989

9090
libm_dep = cc.find_library('m', required: false)
91-
thread_dep = dependency('threads', required: feature_multi_thread)
92-
use_multi_thread = thread_dep.found()
91+
if host_machine_os == os_windows
92+
thread_dep = dependency('', required: false)
93+
use_multi_thread = not feature_multi_thread.disabled()
94+
else
95+
thread_dep = dependency('threads', required: feature_multi_thread)
96+
use_multi_thread = thread_dep.found()
97+
endif
9398
# Arguments in dependency should be equivalent to those passed to pkg-config
9499
zlib_dep = dependency('zlib', required: feature_zlib)
95100
use_zlib = zlib_dep.found()

build/meson/meson_options.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ option('bin_contrib', type: 'boolean', value: false,
2727
description: 'Enable contrib build')
2828

2929
option('multi_thread', type: 'feature', value: 'enabled',
30-
description: 'Enable multi-threading when pthread is detected')
30+
description: 'Enable multi-threading when pthread or Windows is detected')
3131
option('zlib', type: 'feature', value: 'auto',
3232
description: 'Enable zlib support')
3333
option('lzma', type: 'feature', value: 'auto',

0 commit comments

Comments
 (0)