From 867963f1315023673abbe3cc823eb6d332ed8f86 Mon Sep 17 00:00:00 2001 From: Dylan Baker Date: Tue, 16 Feb 2021 14:09:34 -0800 Subject: [PATCH] Do not validate options when finding non-matching This is a) useless because it's only used to print which options are not default, and b) harmful because it can result in cases where things break, like in projects that set a standard that the chosen compiler doesn't support, but the project (or some subset) can be built with a different standard. Fixes: #8360 --- mesonbuild/interpreter.py | 7 ++----- .../236 invalid standard overriden to valid/main.c | 3 +++ .../236 invalid standard overriden to valid/meson.build | 8 ++++++++ .../236 invalid standard overriden to valid/test.json | 9 +++++++++ 4 files changed, 22 insertions(+), 5 deletions(-) create mode 100644 test cases/common/236 invalid standard overriden to valid/main.c create mode 100644 test cases/common/236 invalid standard overriden to valid/meson.build create mode 100644 test cases/common/236 invalid standard overriden to valid/test.json diff --git a/mesonbuild/interpreter.py b/mesonbuild/interpreter.py index f670aec8c8e0..2bc1afbf5f0a 100644 --- a/mesonbuild/interpreter.py +++ b/mesonbuild/interpreter.py @@ -2476,13 +2476,10 @@ def _redetect_machines(self): # TODO: Why is this in interpreter.py and not CoreData or Environment? def get_non_matching_default_options(self) -> T.Iterator[T.Tuple[str, str, coredata.UserOption]]: - env = self.environment for def_opt_name, def_opt_value in self.project_default_options.items(): cur_opt_value = self.coredata.options.get(def_opt_name) - if cur_opt_value is not None: - def_opt_value = env.coredata.validate_option_value(def_opt_name, def_opt_value) - if def_opt_value != cur_opt_value.value: - yield (str(def_opt_name), def_opt_value, cur_opt_value) + if cur_opt_value is not None and def_opt_value != cur_opt_value.value: + yield (str(def_opt_name), def_opt_value, cur_opt_value) def build_func_dict(self): self.funcs.update({'add_global_arguments': self.func_add_global_arguments, diff --git a/test cases/common/236 invalid standard overriden to valid/main.c b/test cases/common/236 invalid standard overriden to valid/main.c new file mode 100644 index 000000000000..9b6bdc2ec2f0 --- /dev/null +++ b/test cases/common/236 invalid standard overriden to valid/main.c @@ -0,0 +1,3 @@ +int main(void) { + return 0; +} diff --git a/test cases/common/236 invalid standard overriden to valid/meson.build b/test cases/common/236 invalid standard overriden to valid/meson.build new file mode 100644 index 000000000000..9463e4341a23 --- /dev/null +++ b/test cases/common/236 invalid standard overriden to valid/meson.build @@ -0,0 +1,8 @@ +project( + 'invalid C standard overriden to valid one', + 'c', + default_options : ['c_std=invalid99'], +) + +exe = executable('main', 'main.c') +test('main', exe) diff --git a/test cases/common/236 invalid standard overriden to valid/test.json b/test cases/common/236 invalid standard overriden to valid/test.json new file mode 100644 index 000000000000..c9b00ce197f5 --- /dev/null +++ b/test cases/common/236 invalid standard overriden to valid/test.json @@ -0,0 +1,9 @@ +{ + "matrix": { + "options": { + "c_std": [ + { "val": "c89" } + ] + } + } +}