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.
This commit is contained in:
Florian Märkl 2023-08-14 03:02:05 +02:00 committed by GitHub
parent 14d607e7fd
commit 22e56a3628
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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'])
]