Open CIPop opened 2 days ago
Workaround:
diff --git a/meson.build b/meson.build
index 44fc844f..01ed86f4 100644
--- a/meson.build
+++ b/meson.build
@@ -35,7 +35,6 @@ project(
license: 'GPL-3.0-or-later OR BSD-3-Clause OR MIT',
# license_files: ['COPYING', 'COPYING-BSD', 'COPYING-MIT'], # Only available in meson 1.1.0
default_options: [
- 'c_std=c11',
'optimization=s',
'debug=true',
# 'warning_level=3', # TODO: Enable by default when all warnings are fixed
Thank you for this report, however this is an issue on the HIDAPI fork, not this repo. It was already addressed in commit 9a5cb9f which is where the hidapi-0.14.0-meson tag should point which is what the Meson .wrap file points to in this repo.
Please run rm -rf deps/hidapi
on your working copy in the root of the working copy and retry your build - you appear to have an out of date HIDAPI clone.
Please note that "just" removing the C standard line is not actually the correct fix as this causes the library to be built with whatever standard the compiler defaults to. It very specifically needs an older GNU mode, hence how we fixed the issue on the fork.
I cloned again:
git clone https://github.com/blackmagic-debug/blackmagic
cd blackmagic
meson setup build
cd build/
ninja
I have verified that deps/hidapi does indeed contain the fix:
cat deps/hidapi/meson.build
# SPDX-License-Identifier: BSD-3-Clause
# SPDX-FileCopyrightText: 2023 Rachel Mant <git@dragonmux.network>
project(
'hidapi',
'c',
version: files('VERSION'),
meson_version: '>=0.58.0',
license: 'BSD-3-Clause OR GPL-3.0-only',
default_options: [
'c_std=gnu99', <---------------------------
'warning_level=3',
'b_pie=true',
'b_lto=true',
'cpp_eh=s',
'buildtype=release',
'b_ndebug=if-release',
]
)
It looks like the root meson.build's default_options is overriding the sub-project configuration. Unfortunately, this is my first interaction with Meson build (I'm used to CMake.)
This is the compiler invocation with the current root meson.build showing that -std=c11
is picked instead of the expected g99
.
FAILED: deps/hidapi/linux/libhidapi-hidraw.a.p/hid.c.o gcc-12 -Ideps/hidapi/linux/libhidapi-hidraw.a.p -Ideps/hidapi/linux -I../deps/hidapi/linux -Ideps/hidapi/hidapi -I../deps/hidapi/hidapi -fdiagnostics-color=always -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -Wextra -Wpedantic -std=c11 -Os -g -fPIC -pthread -MD -MQ deps/hidapi/linux/libhidapi-hidraw.a.p/hid.c.o -MF deps/hidapi/linux/libhidapi-hidraw.a.p/hid.c.o.d -o deps/hidapi/linux/libhidapi-hidraw.a.p/hid.c.o -c ../deps/hidapi/linux/hid.c ../deps/hidapi/linux/hid.c: In function ‘utf8_to_wchar_t’:
Different workaround:
diff --git a/meson.build b/meson.build
index 44fc844f..054ec053 100644
--- a/meson.build
+++ b/meson.build
@@ -35,7 +35,7 @@ project(
license: 'GPL-3.0-or-later OR BSD-3-Clause OR MIT',
# license_files: ['COPYING', 'COPYING-BSD', 'COPYING-MIT'], # Only available in meson 1.1.0
default_options: [
- 'c_std=c11',
+ 'c_std=gnu99',
'optimization=s',
'debug=true',
# 'warning_level=3', # TODO: Enable by default when all warnings are fixed
I found this issue: https://github.com/mesonbuild/meson/issues/2612#issuecomment-343698235
In Meson you can never, ever change the value of existing options inside your build files. You can only specify a new default value for options that do not exist yet. Global options are shared for all projects. When a subproject is called, the option already exists and has a value, thus it can not be changed.
This is a bit odd since I would expect dependencies to come up with their own defaults. Looks like a different mechanism needs to be used in this case to avoid the root meson.build defining dependency-level configurations?
To complete this picture, as we're not seeing this issue in CI or locally, what version of Meson are you running? (meson --version
)
Regarding your proposed fix that edits the project's main meson.build: unfortunately that won't work out because GNU modes subtly change semantics, and particularly downgrading the standard version is no-go as we are depending on C11 features. It's troubling in particular that the existing mitigation is not seeming to work for you either.
Note that project()
block options are not global, they're project-level - global options can only be set with add_global_arguments()
/add_global_link_arguments()
which we explicitly never do.
I tried gcc 10,11 and 12 with the same result.
Repro on 6.5.0-41-generic #41~22.04.2-Ubuntu :
meson setup build
meson compile
orninja
within the\build
folder: