{"thread":{"id":"63481","subject":"[PATCH] meson: reformat default options to workaround bug in `meson configure`","startedAt":"2025-05-19T17:09:51Z","lastAt":"2025-05-19T19:19:14Z","messageCount":2,"participants":["Eli Schwartz","Patrick Steinhardt"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"518440","messageId":"20250519170945.57746-1-eschwartz@gentoo.org","threadId":"63481","inReplyTo":null,"subject":"[PATCH] meson: reformat default options to workaround bug in `meson configure`","fromName":"Eli Schwartz","fromEmail":"eschwartz@gentoo.org","sentAt":"2025-05-19T17:09:42Z","receivedAt":"2025-05-19T17:09:51Z","isPatch":true,"sender":{"key":"eschwartz@gentoo.org","avatar":"https://avatars.githubusercontent.com/u/6551424?v=4"},"body":"Since 13cb20fc46 (\"meson: fix compilation with Visual Studio\",\n2025-01-22) it has not been possible to list build options via `meson\nconfigure`. This is due to Meson's static analysis of build options\nfailing to handle constant folding, and thinking we set a totally\ninvalid default `-std=`.\n\nThis is reported upstream but we anyways need to work with existing\nversions. It turns out there is a simple solution: turn the entire\ndefault option into a conditional branch, which means Meson sees either\nnothing, or everything.\n\nAs a result, Git users can once again see pretty-printed options before\nbuilding.\n\nReported-by: Ramsay Jones <ramsay@ramsayjones.plus.com>\nBug: https://github.com/mesonbuild/meson/issues/14623\nSigned-off-by: Eli Schwartz <eschwartz@gentoo.org>\n---\n meson.build | 14 ++++++--------\n 1 file changed, 6 insertions(+), 8 deletions(-)\n\ndiff --git a/meson.build b/meson.build\nindex a1476e5b32..43fc3afdf5 100644\n--- a/meson.build\n+++ b/meson.build\n@@ -215,14 +215,12 @@ project('git', 'c',\n     capture: true,\n     check: true,\n   ).stdout().strip() : 'unknown',\n-  default_options: [\n-    # Git requires C99 with GNU extensions, which of course isn't supported by\n-    # MSVC. Funny enough, C99 doesn't work with MSVC either, as it has only\n-    # learned to define __STDC_VERSION__ with C11 and later. We thus require\n-    # GNU C99 and fall back to C11. Meson only learned to handle the fallback\n-    # with version 1.3.0, so on older versions we use GNU C99 unconditionally.\n-    'c_std=' + (meson.version().version_compare('>=1.3.0') ? 'gnu99,c11' : 'gnu99'),\n-  ],\n+  # Git requires C99 with GNU extensions, which of course isn't supported by\n+  # MSVC. Funny enough, C99 doesn't work with MSVC either, as it has only\n+  # learned to define __STDC_VERSION__ with C11 and later. We thus require\n+  # GNU C99 and fall back to C11. Meson only learned to handle the fallback\n+  # with version 1.3.0, so on older versions we use GNU C99 unconditionally.\n+  default_options: meson.version().version_compare('>=1.3.0') ? ['c_std=gnu99,c11'] : ['c_std=gnu99'],\n )\n \n fs = import('fs')\n-- \n2.49.0\n\n"},{"id":"518448","messageId":"aCuELL0SLUkszicn@pks.im","threadId":"63481","inReplyTo":"20250519170945.57746-1-eschwartz@gentoo.org","subject":"Re: [PATCH] meson: reformat default options to workaround bug in `meson configure`","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2025-05-19T19:19:08Z","receivedAt":"2025-05-19T19:19:14Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"On Mon, May 19, 2025 at 01:09:42PM -0400, Eli Schwartz wrote:\n> Since 13cb20fc46 (\"meson: fix compilation with Visual Studio\",\n> 2025-01-22) it has not been possible to list build options via `meson\n> configure`.\n\nNit: it _is_ possible to do this in the build directory. What doesn't\nwork is to do this in the source directory.\n\n> This is due to Meson's static analysis of build options\n> failing to handle constant folding, and thinking we set a totally\n> invalid default `-std=`.\n\nInteresting.\n\n> This is reported upstream but we anyways need to work with existing\n> versions. It turns out there is a simple solution: turn the entire\n> default option into a conditional branch, which means Meson sees either\n> nothing, or everything.\n> \n> As a result, Git users can once again see pretty-printed options before\n> building.\n\nNice.\n\n> Reported-by: Ramsay Jones <ramsay@ramsayjones.plus.com>\n> Bug: https://github.com/mesonbuild/meson/issues/14623\n> Signed-off-by: Eli Schwartz <eschwartz@gentoo.org>\n> ---\n>  meson.build | 14 ++++++--------\n>  1 file changed, 6 insertions(+), 8 deletions(-)\n> \n> diff --git a/meson.build b/meson.build\n> index a1476e5b32..43fc3afdf5 100644\n> --- a/meson.build\n> +++ b/meson.build\n> @@ -215,14 +215,12 @@ project('git', 'c',\n>      capture: true,\n>      check: true,\n>    ).stdout().strip() : 'unknown',\n> -  default_options: [\n> -    # Git requires C99 with GNU extensions, which of course isn't supported by\n> -    # MSVC. Funny enough, C99 doesn't work with MSVC either, as it has only\n> -    # learned to define __STDC_VERSION__ with C11 and later. We thus require\n> -    # GNU C99 and fall back to C11. Meson only learned to handle the fallback\n> -    # with version 1.3.0, so on older versions we use GNU C99 unconditionally.\n> -    'c_std=' + (meson.version().version_compare('>=1.3.0') ? 'gnu99,c11' : 'gnu99'),\n> -  ],\n> +  # Git requires C99 with GNU extensions, which of course isn't supported by\n> +  # MSVC. Funny enough, C99 doesn't work with MSVC either, as it has only\n> +  # learned to define __STDC_VERSION__ with C11 and later. We thus require\n> +  # GNU C99 and fall back to C11. Meson only learned to handle the fallback\n> +  # with version 1.3.0, so on older versions we use GNU C99 unconditionally.\n> +  default_options: meson.version().version_compare('>=1.3.0') ? ['c_std=gnu99,c11'] : ['c_std=gnu99'],\n>  )\n\nMakes sense. It doesn't really make much of a difference for us in which\nof the two ways we format this, so let's just stick with what works. We\ncould of course link to the upstream bug here in the comment, but on the\nother hand I don't expect that we'll have to touch these anytime soon\nanyway.\n\nSo this patch looks good to me, thanks!\n\nPatrick\n"}]}