Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Validation fails when overriding default_option c_std #8360

Closed
archi opened this issue Feb 16, 2021 · 2 comments · Fixed by #8372
Closed

Validation fails when overriding default_option c_std #8360

archi opened this issue Feb 16, 2021 · 2 comments · Fixed by #8372
Assignees
Milestone

Comments

@archi
Copy link
Contributor

archi commented Feb 16, 2021

Describe the bug

Hi, when bumping our internal meson git to the latest version, I noticed that meson now enforces the c_std set by a project.

The CompCert support I added only claims c89 and c99, which is close enough to the truth (there are some exceptions, see https://compcert.org/compcert-C.html if curious). However, when building the picolibc I now get into trouble because it sets the c_std to gnu99 in the default_options. Generally speaking, this is also quite true, but at least for our config I removed all GNU-isms.

So I now end up with this:

../src/meson.build:35:0: ERROR: Value "gnu99" (of type "string") for combo option "C language standard to use" is not one of the choices. Possible choices are (as string): "none", "c89", "c99".

And can't override it. I tried -Dc_std=c99, but then it just fails at a later point (seems like after running the whole "configure" script):

ERROR: Validation failed for option c_std: Value "gnu99" (of type "string") for combo option "C language standard to use" is not one of the choices. Possible choices are (as string): "none", "c89", "c99".

Same for the minimal, native example below. I suppose this might be a bug?

OTOH, if I'm doing it wrong I'm happy to be pointed out on how to achieve my goal :)

To Reproduce

Consider this simple project, meson.build file:

project('testproject', 'c',
  version : '0.1',
  default_options : ['warning_level=3', 'c_std=foobar99'])

executable('testproject',
           'hello.c',
           install : true)

source in hello.c (doesn't matter):

#include <stdio.h>
int main (void) { printf("Hello World!\n"); return 0; }

Calling only meson $project_src, I get the following error:

The Meson build system
Version: 0.57.999
Source dir: /local/hdd/meyer/tmp/c_std/project
Build dir: /local/hdd/meyer/tmp/c_std/project/build
Build type: native build
Project name: testproject
Project version: 0.1

../meson.build:1:0: ERROR: Value "foobar99" (of type "string") for combo option "C language standard to use" is not one of the choices. Possible choices are (as string): "none", "c89", "c99", "c11", "c17", "c18", "c2x", "gnu89", "gnu99", "gnu11", "gnu17", "gnu18", "gnu2x".

This is expected, as my system GCC (10.2.0, x86_64) doesn't support the non-existent C language standard foobar99.

However, when overriding the value by calling ``meson $project_src -Dc_std=c99`, I get more output - but it still fails:

The Meson build system
Version: 0.57.999
Source dir: /local/hdd/meyer/tmp/c_std/project
Build dir: /local/hdd/meyer/tmp/c_std/project/build
Build type: native build
Project name: testproject
Project version: 0.1
C compiler for the host machine: cc (gcc 10.2.0 "cc (GCC) 10.2.0")
C linker for the host machine: cc ld.bfd 2.35.1
Host machine cpu family: x86_64
Host machine cpu: x86_64
Build targets in project: 1


ERROR: Validation failed for option c_std: Value "foobar99" (of type "string") for combo option "C language standard to use" is not one of the choices. Possible choices are (as string): "none", "c89", "c99", "c11", "c17", "c18", "c2x", "gnu89", "gnu99", "gnu11", "gnu17", "gnu18", "gnu2x".

Hence the title, Validation fails when overriding default_option c_std.

Expected behavior
The hello world project is build.

system parameters

  • native build (only originally stumbled on cross build)
  • Manjaro (kernel 5.10.2-2-MANJARO)
  • Python 3.9.1
  • Meson 0.57.999 (commit 1104575)
  • Ninja 1.10.2
@dcbaker
Copy link
Member

dcbaker commented Feb 16, 2021

This is one of those, danged whatever you do situations. What happened was that we enforced the c standard options for some compilers, but not all compilers. We're now enforcing it for all compilers.

The second part though, that setting the default value to something invalid, then overriding it something valid and that not working is not good, and I can replicate that.

@dcbaker dcbaker self-assigned this Feb 16, 2021
@dcbaker dcbaker added this to the 0.57.1 milestone Feb 16, 2021
dcbaker added a commit to dcbaker/meson that referenced this issue Feb 16, 2021
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: mesonbuild#8360
dcbaker added a commit to dcbaker/meson that referenced this issue Feb 16, 2021
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: mesonbuild#8360
@archi
Copy link
Contributor Author

archi commented Feb 17, 2021

Aah, the first part was just flavour to point out the use case - I think the better enforcement for all compilers makes sense. Thanks for looking into the regression :)

jpakkane pushed a commit that referenced this issue Feb 17, 2021
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
nirbheek pushed a commit that referenced this issue Feb 20, 2021
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
tristan957 pushed a commit to tristan957/meson that referenced this issue Mar 2, 2021
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: mesonbuild#8360
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants