From 5b2c6c776acadcd86247fdaa3e48c11c6848263e Mon Sep 17 00:00:00 2001 From: Eli Schwartz Date: Sun, 30 Jan 2022 20:42:35 -0500 Subject: [PATCH 1/4] meson: fix resource file compilation on Windows It needs to know about the correct include directories on its own. --- build/meson/lib/meson.build | 3 ++- build/meson/programs/meson.build | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/build/meson/lib/meson.build b/build/meson/lib/meson.build index 6b093378..bb761a4f 100644 --- a/build/meson/lib/meson.build +++ b/build/meson/lib/meson.build @@ -83,7 +83,8 @@ libzstd_c_args = [] if cc_id == compiler_msvc if default_library_type != 'static' libzstd_sources += [windows_mod.compile_resources( - join_paths(zstd_rootdir, 'build/VS2010/libzstd-dll/libzstd-dll.rc'))] + join_paths(zstd_rootdir, 'build/VS2010/libzstd-dll/libzstd-dll.rc'), + include_directories: libzstd_includes)] libzstd_c_args += ['-DZSTD_DLL_EXPORT=1', '-DZSTD_HEAPMODE=0', '-D_CONSOLE', diff --git a/build/meson/programs/meson.build b/build/meson/programs/meson.build index 5ccd679a..0704155d 100644 --- a/build/meson/programs/meson.build +++ b/build/meson/programs/meson.build @@ -66,7 +66,8 @@ endif if cc_id == compiler_msvc if default_library_type != 'static' zstd_programs_sources += [windows_mod.compile_resources( - join_paths(zstd_rootdir, 'build/VS2010/zstd/zstd.rc'))] + join_paths(zstd_rootdir, 'build/VS2010/zstd/zstd.rc'), + include_directories: libzstd_includes)] endif endif From 84c05453db61a5c518bda486ea36b0c00fc645a1 Mon Sep 17 00:00:00 2001 From: Eli Schwartz Date: Sun, 30 Jan 2022 21:02:44 -0500 Subject: [PATCH 2/4] meson: never require a libm libm is not guaranteed to exist. POSIX requires the math functions to exist, but doesn't require to have it be a standalone library. On platforms where libm exists as a standalone library, it will always be found by meson -- it is shipped with libc. If it is not found, then we can safely assume the linker will make the math functions available by default. See https://mesonbuild.com/howtox.html#add-math-library-lm-portably Fixes building with bin_tests=true on Windows. --- build/meson/meson.build | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/meson/meson.build b/build/meson/meson.build index 0c29a762..e0ea3dff 100644 --- a/build/meson/meson.build +++ b/build/meson/meson.build @@ -92,7 +92,7 @@ feature_lz4 = get_option('lz4') # Dependencies # ============================================================================= -libm_dep = cc.find_library('m', required: bin_tests) +libm_dep = cc.find_library('m', required: false) thread_dep = dependency('threads', required: feature_multi_thread) use_multi_thread = thread_dep.found() # Arguments in dependency should be equivalent to those passed to pkg-config From ef78b9af30422f8affe1ab35cd59b7170cde707a Mon Sep 17 00:00:00 2001 From: Eli Schwartz Date: Sun, 30 Jan 2022 21:45:19 -0500 Subject: [PATCH 3/4] meson: valgrind wrapper should return correct errors While trying to raise an exception on failures, it instead raised an exception for misusing the exception. CalledProcessError is only supposed to be used when given a return code and a command, and it prints: Command '{cmd}' returned non-zero exit status {ret} Passing an error message string instead, just errored out with: TypeError: __init__() missing 1 required positional argument Instead use the subprocess module's base error which does accept string messages. Everything that used to error out, still errors out, but now they do so with a slightly prettier console message. --- build/meson/tests/valgrindTest.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/build/meson/tests/valgrindTest.py b/build/meson/tests/valgrindTest.py index 218f7458..05d84878 100644 --- a/build/meson/tests/valgrindTest.py +++ b/build/meson/tests/valgrindTest.py @@ -21,7 +21,7 @@ def valgrindTest(valgrind, datagen, fuzzer, zstd, fullbench): if subprocess.call([*VALGRIND_ARGS, zstd], stdout=subprocess.DEVNULL) == 0: - raise subprocess.CalledProcessError('zstd without argument should have failed') + raise subprocess.SubprocessError('zstd without argument should have failed') with subprocess.Popen([datagen, '-g80'], stdout=subprocess.PIPE) as p1, \ subprocess.Popen([*VALGRIND_ARGS, zstd, '-', '-c'], @@ -30,7 +30,7 @@ def valgrindTest(valgrind, datagen, fuzzer, zstd, fullbench): p1.stdout.close() # Allow p1 to receive a SIGPIPE if p2 exits. p2.communicate() if p2.returncode != 0: - raise subprocess.CalledProcessError() + raise subprocess.SubprocessError() with subprocess.Popen([datagen, '-g16KB'], stdout=subprocess.PIPE) as p1, \ subprocess.Popen([*VALGRIND_ARGS, zstd, '-vf', '-', '-c'], @@ -39,7 +39,7 @@ def valgrindTest(valgrind, datagen, fuzzer, zstd, fullbench): p1.stdout.close() p2.communicate() if p2.returncode != 0: - raise subprocess.CalledProcessError() + raise subprocess.SubprocessError() with tempfile.NamedTemporaryFile() as tmp_fd: with subprocess.Popen([datagen, '-g2930KB'], stdout=subprocess.PIPE) as p1, \ @@ -48,7 +48,7 @@ def valgrindTest(valgrind, datagen, fuzzer, zstd, fullbench): p1.stdout.close() p2.communicate() if p2.returncode != 0: - raise subprocess.CalledProcessError() + raise subprocess.SubprocessError() subprocess.check_call([*VALGRIND_ARGS, zstd, '-vdf', tmp_fd.name, '-c'], stdout=subprocess.DEVNULL) @@ -60,7 +60,7 @@ def valgrindTest(valgrind, datagen, fuzzer, zstd, fullbench): p1.stdout.close() p2.communicate() if p2.returncode != 0: - raise subprocess.CalledProcessError() + raise subprocess.SubprocessError() subprocess.check_call([*VALGRIND_ARGS, fuzzer, '-T1mn', '-t1']) subprocess.check_call([*VALGRIND_ARGS, fullbench, '-i1']) From c01582dc8aee541171089fa2979c890752365104 Mon Sep 17 00:00:00 2001 From: Eli Schwartz Date: Sun, 30 Jan 2022 22:38:04 -0500 Subject: [PATCH 4/4] travis CI: update meson image to one with a python that isn't EOL Currently the build errors out with: ``` ERROR: This script does not work on Python 3.6 The minimum supported Python version is 3.7. Please use https://bootstrap.pypa.io/pip/3.6/get-pip.py instead. ``` While in theory this advice could be followed to get a better pip on xenial, Meson has now deprecated python 3.6 support too, and the next (unreleased) version requires python 3.7 There are a couple solutions to this: - hold the version of pip, allow pip to only install 3.6-compatible versions of meson (effectively freezing meson going forward) - install python 3.7 on xenial - update to a 2-year-old image instead of a 4-year-old one Option 3 is the simplest. --- .travis.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 6a1295b4..34cf0e1a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -92,8 +92,8 @@ matrix: - make -C tests versionsTest # meson dedicated test - - name: Xenial (Meson + clang) # ~15mn - dist: bionic + - name: Focal (Meson + clang) # ~15mn + dist: focal language: cpp compiler: clang install: