From 22e56a3628e0d1f927fcd356a65b5c213531eb80 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20M=C3=A4rkl?= Date: Mon, 14 Aug 2023 03:02:05 +0200 Subject: [PATCH] Fix blake3 build when a simd extension is missing (#3751) Regression from avx512 fix: Any call to add_project_arguments() must happen before declaring any build target. --- subprojects/packagefiles/blake3/meson.build | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/subprojects/packagefiles/blake3/meson.build b/subprojects/packagefiles/blake3/meson.build index 26d8ad7a7b..e82fceb5d7 100644 --- a/subprojects/packagefiles/blake3/meson.build +++ b/subprojects/packagefiles/blake3/meson.build @@ -112,24 +112,30 @@ else endforeach endif -blake3_libs = [] +blake3_lib_defs = [] foreach it : blake3_simd - file = it[0] disable_flag = it[1] name = it[2] code = it[3] args = it[4] has_extension = cc.compiles(code, args: args, name: name) if has_extension - # https://github.com/mesonbuild/meson/issues/1367 - # Individual static libraries are needed to avoid passing the simd flags to the C files, - # which would make functions like memset() use potentially unsupported instructions at runtime. - blake3_libs += static_library('blake3_' + name, file, c_args: args) + blake3_lib_defs += [it] else add_project_arguments(disable_flag, language: 'c') endif endforeach +# This must not happen inside the loop above because add_project_arguments() calls must precede any +# build target declaration. +blake3_libs = [] +foreach it : blake3_lib_defs + # https://github.com/mesonbuild/meson/issues/1367 + # Individual static libraries are needed to avoid passing the simd flags to the C files, + # which would make functions like memset() use potentially unsupported instructions at runtime. + blake3_libs += static_library('blake3_' + it[2], it[0], c_args: it[4]) +endforeach + blake3_inc = [ include_directories(['c']) ]