[16/16] build: enable vla warnings on Windows built code

Message ID 1713397319-26135-17-git-send-email-roretzla@linux.microsoft.com (mailing list archive)
State Superseded
Delegated to: Thomas Monjalon
Headers
Series remove use of VLAs for Windows built code |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/loongarch-compilation success Compilation OK
ci/loongarch-unit-testing success Unit Testing PASS
ci/Intel-compilation success Compilation OK
ci/intel-Testing success Testing PASS
ci/intel-Functional success Functional PASS
ci/github-robot: build success github build: passed
ci/iol-mellanox-Performance success Performance Testing PASS
ci/iol-sample-apps-testing success Testing PASS
ci/iol-broadcom-Performance success Performance Testing PASS
ci/iol-abi-testing success Testing PASS
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-broadcom-Functional success Functional Testing PASS
ci/iol-unit-amd64-testing success Testing PASS
ci/iol-intel-Functional success Functional Testing PASS
ci/iol-compile-amd64-testing success Testing PASS
ci/iol-unit-arm64-testing success Testing PASS
ci/iol-compile-arm64-testing success Testing PASS

Commit Message

Tyler Retzlaff April 17, 2024, 11:41 p.m. UTC
  MSVC does not support optional C11 VLAs. When building for Windows
enable -Wvla so that mingw and clang also fail if a VLA is used.

Signed-off-by: Tyler Retzlaff <roretzla@linux.microsoft.com>
---
 config/meson.build | 4 ++++
 1 file changed, 4 insertions(+)
  

Comments

Morten Brørup April 18, 2024, 6:48 a.m. UTC | #1
> MSVC does not support optional C11 VLAs. When building for Windows
> enable -Wvla so that mingw and clang also fail if a VLA is used.

Minor detail, doesn't affect my Ack for the series...

Applications built for Windows with mingw and clang might use VLAs in the application itself.

Perhaps we should let them continue doing that for now.

> 
> Signed-off-by: Tyler Retzlaff <roretzla@linux.microsoft.com>
> ---
>  config/meson.build | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/config/meson.build b/config/meson.build
> index 8c8b019..9e887f2 100644
> --- a/config/meson.build
> +++ b/config/meson.build
> @@ -344,6 +344,10 @@ if cc.get_id() == 'intel'
>          warning_flags += '-diag-disable=@0@'.format(i)
>      endforeach
>  endif
> +# no VLAs in code built on Windows
> +if is_windows
> +    warning_flags += '-Wvla'
> +endif
>  foreach arg: warning_flags
>      if cc.has_argument(arg)
>          add_project_arguments(arg, language: 'c')
> --
> 1.8.3.1
  
Tyler Retzlaff April 18, 2024, 3:12 p.m. UTC | #2
On Thu, Apr 18, 2024 at 08:48:39AM +0200, Morten Brørup wrote:
> > MSVC does not support optional C11 VLAs. When building for Windows
> > enable -Wvla so that mingw and clang also fail if a VLA is used.
> 
> Minor detail, doesn't affect my Ack for the series...
> 
> Applications built for Windows with mingw and clang might use VLAs in the application itself.
> 
> Perhaps we should let them continue doing that for now.

i guess you mean our examples or if dpdk is configured as a sub-project?

for examples i could explicitly suppress in examples with -Wno-vla but
that means any that use VLAs could not be built with MSVC.

for sub-module and sub-project of dpdk i feel like these
add_project_arguments are not imparted on the application with
encapsulating project meson setup no?

anyone know? Bruce? Stephen?

> 
> > 
> > Signed-off-by: Tyler Retzlaff <roretzla@linux.microsoft.com>
> > ---
> >  config/meson.build | 4 ++++
> >  1 file changed, 4 insertions(+)
> > 
> > diff --git a/config/meson.build b/config/meson.build
> > index 8c8b019..9e887f2 100644
> > --- a/config/meson.build
> > +++ b/config/meson.build
> > @@ -344,6 +344,10 @@ if cc.get_id() == 'intel'
> >          warning_flags += '-diag-disable=@0@'.format(i)
> >      endforeach
> >  endif
> > +# no VLAs in code built on Windows
> > +if is_windows
> > +    warning_flags += '-Wvla'
> > +endif
> >  foreach arg: warning_flags
> >      if cc.has_argument(arg)
> >          add_project_arguments(arg, language: 'c')
> > --
> > 1.8.3.1
>
  
Bruce Richardson April 18, 2024, 3:23 p.m. UTC | #3
On Thu, Apr 18, 2024 at 08:12:26AM -0700, Tyler Retzlaff wrote:
> On Thu, Apr 18, 2024 at 08:48:39AM +0200, Morten Brørup wrote:
> > > MSVC does not support optional C11 VLAs. When building for Windows
> > > enable -Wvla so that mingw and clang also fail if a VLA is used.
> > 
> > Minor detail, doesn't affect my Ack for the series...
> > 
> > Applications built for Windows with mingw and clang might use VLAs in
> > the application itself.
> > 
> > Perhaps we should let them continue doing that for now.
> 
> i guess you mean our examples or if dpdk is configured as a sub-project?
> 
> for examples i could explicitly suppress in examples with -Wno-vla but
> that means any that use VLAs could not be built with MSVC.
> 
> for sub-module and sub-project of dpdk i feel like these
> add_project_arguments are not imparted on the application with
> encapsulating project meson setup no?
> 
> anyone know? Bruce? Stephen?
> 
Project args are not used when building external applications - either
those using DPDK as a subproject or via pkg-config. So therefore, this
change should be safe. It will only impact built-in DPDK apps and examples.

/Bruce
  
Morten Brørup April 18, 2024, 7:22 p.m. UTC | #4
> From: Bruce Richardson [mailto:bruce.richardson@intel.com]
> Sent: Thursday, 18 April 2024 17.24
> 
> On Thu, Apr 18, 2024 at 08:12:26AM -0700, Tyler Retzlaff wrote:
> > On Thu, Apr 18, 2024 at 08:48:39AM +0200, Morten Brørup wrote:
> > > > MSVC does not support optional C11 VLAs. When building for Windows
> > > > enable -Wvla so that mingw and clang also fail if a VLA is used.
> > >
> > > Minor detail, doesn't affect my Ack for the series...
> > >
> > > Applications built for Windows with mingw and clang might use VLAs
> in
> > > the application itself.
> > >
> > > Perhaps we should let them continue doing that for now.
> >
> > i guess you mean our examples or if dpdk is configured as a sub-
> project?
> >
> > for examples i could explicitly suppress in examples with -Wno-vla but
> > that means any that use VLAs could not be built with MSVC.
> >
> > for sub-module and sub-project of dpdk i feel like these
> > add_project_arguments are not imparted on the application with
> > encapsulating project meson setup no?
> >
> > anyone know? Bruce? Stephen?
> >
> Project args are not used when building external applications - either
> those using DPDK as a subproject or via pkg-config. So therefore, this
> change should be safe. It will only impact built-in DPDK apps and
> examples.
> 
> /Bruce

Thank you for clarifying, Bruce.

Then my comment was irrelevant. Sorry about the noise. ;-)
  

Patch

diff --git a/config/meson.build b/config/meson.build
index 8c8b019..9e887f2 100644
--- a/config/meson.build
+++ b/config/meson.build
@@ -344,6 +344,10 @@  if cc.get_id() == 'intel'
         warning_flags += '-diag-disable=@0@'.format(i)
     endforeach
 endif
+# no VLAs in code built on Windows
+if is_windows
+    warning_flags += '-Wvla'
+endif
 foreach arg: warning_flags
     if cc.has_argument(arg)
         add_project_arguments(arg, language: 'c')