DPDK patches and discussions
 help / color / mirror / Atom feed
* [PATCH 0/3] unblock the use of the MSVC compiler
@ 2023-01-25 19:25 Tyler Retzlaff
  2023-01-25 19:25 ` [PATCH 1/3] build: " Tyler Retzlaff
                   ` (6 more replies)
  0 siblings, 7 replies; 44+ messages in thread
From: Tyler Retzlaff @ 2023-01-25 19:25 UTC (permalink / raw)
  To: dev; +Cc: bruce.richardson, Tyler Retzlaff

Introduce minimum changes to the build system to allow use of the MSVC
compiler.

This change is intended to enable a phased approach to allowing DPDK to
built with MSVC. Building with MSVC removes barriers to enterprise
customers use of DPDK who have constraints around security policy,
compliance and functional requirements.

Tyler Retzlaff (3):
  build: unblock the use of the MSVC compiler
  build: determine execution environment at config time
  build: limit what is built when using MSVC compiler

 buildtools/meson.build | 10 +++++++---
 config/meson.build     | 29 ++++++++++++++++++++++-------
 config/x86/meson.build |  8 +++++---
 lib/eal/meson.build    |  8 --------
 lib/meson.build        | 20 +++++++++++++++++---
 meson.build            | 13 +++++++++----
 6 files changed, 60 insertions(+), 28 deletions(-)

-- 
1.8.3.1


^ permalink raw reply	[flat|nested] 44+ messages in thread

* [PATCH 1/3] build: unblock the use of the MSVC compiler
  2023-01-25 19:25 [PATCH 0/3] unblock the use of the MSVC compiler Tyler Retzlaff
@ 2023-01-25 19:25 ` Tyler Retzlaff
  2023-01-26 10:07   ` Bruce Richardson
  2023-01-25 19:25 ` [PATCH 2/3] build: determine execution environment at config time Tyler Retzlaff
                   ` (5 subsequent siblings)
  6 siblings, 1 reply; 44+ messages in thread
From: Tyler Retzlaff @ 2023-01-25 19:25 UTC (permalink / raw)
  To: dev; +Cc: bruce.richardson, Tyler Retzlaff

Detect when MSVC toolset is available and tweak toolchain arguments
where the meson build system offers no abstraction.

Signed-off-by: Tyler Retzlaff <roretzla@linux.microsoft.com>
---
 buildtools/meson.build | 10 +++++++---
 config/meson.build     | 21 ++++++++++++++-------
 config/x86/meson.build |  8 +++++---
 lib/meson.build        | 13 ++++++++++---
 4 files changed, 36 insertions(+), 16 deletions(-)

diff --git a/buildtools/meson.build b/buildtools/meson.build
index e1c600e..838c39f 100644
--- a/buildtools/meson.build
+++ b/buildtools/meson.build
@@ -4,7 +4,9 @@
 pkgconf = find_program('pkg-config', 'pkgconf', required: false)
 check_symbols = find_program('check-symbols.sh')
 ldflags_ibverbs_static = find_program('options-ibverbs-static.sh')
-objdump = find_program('objdump', 'llvm-objdump')
+if cc.get_id() != 'msvc'
+    objdump = find_program('objdump', 'llvm-objdump')
+endif
 
 python3 = import('python').find_installation(required: false)
 if python3.found()
@@ -18,8 +20,10 @@ map_to_win_cmd = py3 + files('map_to_win.py')
 sphinx_wrapper = py3 + files('call-sphinx-build.py')
 get_cpu_count_cmd = py3 + files('get-cpu-count.py')
 get_numa_count_cmd = py3 + files('get-numa-count.py')
-binutils_avx512_check = (py3 + files('binutils-avx512-check.py') +
-                        [objdump] + cc.cmd_array())
+if cc.get_id() != 'msvc'
+    binutils_avx512_check = (py3 + files('binutils-avx512-check.py') +
+                            [objdump] + cc.cmd_array())
+endif
 
 # select library and object file format
 pmdinfo = py3 + files('gen-pmdinfo-cfile.py') + [meson.current_build_dir()]
diff --git a/config/meson.build b/config/meson.build
index 6d9ffd4..898b743 100644
--- a/config/meson.build
+++ b/config/meson.build
@@ -16,7 +16,8 @@ endforeach
 
 # MS linker requires special treatment.
 # TODO: use cc.get_linker_id() with Meson >= 0.54
-is_ms_linker = is_windows and (cc.get_id() == 'clang')
+is_ms_compiler = is_windows and (cc.get_id() == 'msvc')
+is_ms_linker = is_windows and (cc.get_id() == 'clang' or is_ms_compiler)
 
 # set the major version, which might be used by drivers and libraries
 # depending on the configuration options
@@ -130,11 +131,13 @@ dpdk_conf.set('RTE_MACHINE', cpu_instruction_set)
 machine_args = []
 
 # ppc64 does not support -march= at all, use -mcpu and -mtune for that
-if host_machine.cpu_family().startswith('ppc')
-    machine_args += '-mcpu=' + cpu_instruction_set
-    machine_args += '-mtune=' + cpu_instruction_set
-else
-    machine_args += '-march=' + cpu_instruction_set
+if not is_ms_compiler
+    if host_machine.cpu_family().startswith('ppc')
+        machine_args += '-mcpu=' + cpu_instruction_set
+        machine_args += '-mtune=' + cpu_instruction_set
+    else
+        machine_args += '-march=' + cpu_instruction_set
+    endif
 endif
 
 toolchain = cc.get_id()
@@ -252,7 +255,11 @@ if cc.get_id() == 'clang' and dpdk_conf.get('RTE_ARCH_64') == false
 endif
 
 # add -include rte_config to cflags
-add_project_arguments('-include', 'rte_config.h', language: 'c')
+if is_ms_compiler
+    add_project_arguments('/FI', 'rte_config.h', language: 'c')
+else
+    add_project_arguments('-include', 'rte_config.h', language: 'c')
+endif
 
 # enable extra warnings and disable any unwanted warnings
 # -Wall is added by default at warning level 1, and -Wextra
diff --git a/config/x86/meson.build b/config/x86/meson.build
index 54345c4..11f0bcc 100644
--- a/config/x86/meson.build
+++ b/config/x86/meson.build
@@ -25,9 +25,11 @@ if cc.has_argument('-mavx512f')
 endif
 
 # we require SSE4.2 for DPDK
-if cc.get_define('__SSE4_2__', args: machine_args) == ''
-    message('SSE 4.2 not enabled by default, explicitly enabling')
-    machine_args += '-msse4'
+if not is_ms_compiler
+    if cc.get_define('__SSE4_2__', args: machine_args) == ''
+        message('SSE 4.2 not enabled by default, explicitly enabling')
+        machine_args += '-msse4'
+    endif
 endif
 
 base_flags = ['SSE', 'SSE2', 'SSE3','SSSE3', 'SSE4_1', 'SSE4_2']
diff --git a/lib/meson.build b/lib/meson.build
index a90fee3..82e4666 100644
--- a/lib/meson.build
+++ b/lib/meson.build
@@ -235,9 +235,16 @@ foreach l:libraries
                 output: '@0@_exports.def'.format(libname))
         lk_deps += [def_file]
 
-        lk_args = ['-Wl,/def:' + def_file.full_path()]
-        if meson.version().version_compare('<0.54.0')
-            lk_args += ['-Wl,/implib:lib\\librte_' + l + '.dll.a']
+        if is_ms_compiler
+            lk_args = ['/def:' + def_file.full_path()]
+            if meson.version().version_compare('<0.54.0')
+                lk_args += ['/implib:lib\\librte_' + l + '.dll.a']
+            endif
+        else
+            lk_args = ['-Wl,/def:' + def_file.full_path()]
+            if meson.version().version_compare('<0.54.0')
+                lk_args += ['-Wl,/implib:lib\\librte_' + l + '.dll.a']
+            endif
         endif
     else
         if is_windows
-- 
1.8.3.1


^ permalink raw reply	[flat|nested] 44+ messages in thread

* [PATCH 2/3] build: determine execution environment at config time
  2023-01-25 19:25 [PATCH 0/3] unblock the use of the MSVC compiler Tyler Retzlaff
  2023-01-25 19:25 ` [PATCH 1/3] build: " Tyler Retzlaff
@ 2023-01-25 19:25 ` Tyler Retzlaff
  2023-01-26 10:09   ` Bruce Richardson
  2023-01-25 19:25 ` [PATCH 3/3] build: limit what is built when using MSVC compiler Tyler Retzlaff
                   ` (4 subsequent siblings)
  6 siblings, 1 reply; 44+ messages in thread
From: Tyler Retzlaff @ 2023-01-25 19:25 UTC (permalink / raw)
  To: dev; +Cc: bruce.richardson, Tyler Retzlaff

Move execution environment determination and definitions to config. The
RTE_EXEC_ENV macros are actually used by libraries built before EAL.

Currently it does not matter that this is determined in lib/eal since
the definitions are consumed before anything is built including libs
built before lib/eal. By moving this logic to config it allows kvargs
and telemetry to be built without EAL.

No functional change intended.

Signed-off-by: Tyler Retzlaff <roretzla@linux.microsoft.com>
---
 config/meson.build  | 8 ++++++++
 lib/eal/meson.build | 8 --------
 2 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/config/meson.build b/config/meson.build
index 898b743..e0b9e4e 100644
--- a/config/meson.build
+++ b/config/meson.build
@@ -14,6 +14,14 @@ foreach env:supported_exec_envs
     set_variable('is_' + env, exec_env == env)
 endforeach
 
+exec_envs = {'freebsd': 0, 'linux': 1, 'windows': 2}
+foreach env, id:exec_envs
+    dpdk_conf.set('RTE_ENV_' + env.to_upper(), id)
+    dpdk_conf.set10('RTE_EXEC_ENV_IS_' + env.to_upper(), (exec_env == env))
+endforeach
+dpdk_conf.set('RTE_EXEC_ENV', exec_envs[exec_env])
+dpdk_conf.set('RTE_EXEC_ENV_' + exec_env.to_upper(), 1)
+
 # MS linker requires special treatment.
 # TODO: use cc.get_linker_id() with Meson >= 0.54
 is_ms_compiler = is_windows and (cc.get_id() == 'msvc')
diff --git a/lib/eal/meson.build b/lib/eal/meson.build
index 056beb9..26c638f 100644
--- a/lib/eal/meson.build
+++ b/lib/eal/meson.build
@@ -10,14 +10,6 @@ if not is_windows
     subdir('unix')
 endif
 
-exec_envs = {'freebsd': 0, 'linux': 1, 'windows': 2}
-foreach env, id:exec_envs
-    dpdk_conf.set('RTE_ENV_' + env.to_upper(), id)
-    dpdk_conf.set10('RTE_EXEC_ENV_IS_' + env.to_upper(), (exec_env == env))
-endforeach
-dpdk_conf.set('RTE_EXEC_ENV', exec_envs[exec_env])
-
-dpdk_conf.set('RTE_EXEC_ENV_' + exec_env.to_upper(), 1)
 subdir(exec_env)
 
 subdir(arch_subdir)
-- 
1.8.3.1


^ permalink raw reply	[flat|nested] 44+ messages in thread

* [PATCH 3/3] build: limit what is built when using MSVC compiler
  2023-01-25 19:25 [PATCH 0/3] unblock the use of the MSVC compiler Tyler Retzlaff
  2023-01-25 19:25 ` [PATCH 1/3] build: " Tyler Retzlaff
  2023-01-25 19:25 ` [PATCH 2/3] build: determine execution environment at config time Tyler Retzlaff
@ 2023-01-25 19:25 ` Tyler Retzlaff
  2023-01-26 11:10   ` Bruce Richardson
  2023-01-26 18:03 ` [PATCH v2 0/3] unblock the use of the " Tyler Retzlaff
                   ` (3 subsequent siblings)
  6 siblings, 1 reply; 44+ messages in thread
From: Tyler Retzlaff @ 2023-01-25 19:25 UTC (permalink / raw)
  To: dev; +Cc: bruce.richardson, Tyler Retzlaff

Build only kvargs and telemetry when is_ms_compiler.

Signed-off-by: Tyler Retzlaff <roretzla@linux.microsoft.com>
---
 lib/meson.build |  7 +++++++
 meson.build     | 13 +++++++++----
 2 files changed, 16 insertions(+), 4 deletions(-)

diff --git a/lib/meson.build b/lib/meson.build
index 82e4666..8e99e21 100644
--- a/lib/meson.build
+++ b/lib/meson.build
@@ -65,6 +65,13 @@ libraries = [
         'node',
 ]
 
+if is_ms_compiler
+    libraries = [
+            'kvargs',
+            'telemetry',
+    ]
+endif
+
 optional_libs = [
         'bitratestats',
         'cfgfile',
diff --git a/meson.build b/meson.build
index f91d652..e095192 100644
--- a/meson.build
+++ b/meson.build
@@ -76,11 +76,16 @@ subdir('config')
 
 # build libs and drivers
 subdir('lib')
-subdir('drivers')
 
-# build binaries and installable tools
-subdir('usertools')
-subdir('app')
+if is_ms_compiler
+    enabled_apps = []
+else
+    subdir('drivers')
+
+    # build binaries and installable tools
+    subdir('usertools')
+    subdir('app')
+endif
 
 # build docs
 subdir('doc')
-- 
1.8.3.1


^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: [PATCH 1/3] build: unblock the use of the MSVC compiler
  2023-01-25 19:25 ` [PATCH 1/3] build: " Tyler Retzlaff
@ 2023-01-26 10:07   ` Bruce Richardson
  0 siblings, 0 replies; 44+ messages in thread
From: Bruce Richardson @ 2023-01-26 10:07 UTC (permalink / raw)
  To: Tyler Retzlaff; +Cc: dev

On Wed, Jan 25, 2023 at 11:25:05AM -0800, Tyler Retzlaff wrote:
> Detect when MSVC toolset is available and tweak toolchain arguments
> where the meson build system offers no abstraction.
> 
> Signed-off-by: Tyler Retzlaff <roretzla@linux.microsoft.com>
> ---
Acked-by: Bruce Richardson <bruce.richardson@intel.com>

^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: [PATCH 2/3] build: determine execution environment at config time
  2023-01-25 19:25 ` [PATCH 2/3] build: determine execution environment at config time Tyler Retzlaff
@ 2023-01-26 10:09   ` Bruce Richardson
  0 siblings, 0 replies; 44+ messages in thread
From: Bruce Richardson @ 2023-01-26 10:09 UTC (permalink / raw)
  To: Tyler Retzlaff; +Cc: dev

On Wed, Jan 25, 2023 at 11:25:06AM -0800, Tyler Retzlaff wrote:
> Move execution environment determination and definitions to config. The
> RTE_EXEC_ENV macros are actually used by libraries built before EAL.
> 
> Currently it does not matter that this is determined in lib/eal since
> the definitions are consumed before anything is built including libs
> built before lib/eal. By moving this logic to config it allows kvargs
> and telemetry to be built without EAL.
> 
> No functional change intended.
> 
> Signed-off-by: Tyler Retzlaff <roretzla@linux.microsoft.com>
> ---
Good change. This should have been done when the code was added originally.

Acked-by: Bruce Richardson <bruce.richardson@intel.com>

^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: [PATCH 3/3] build: limit what is built when using MSVC compiler
  2023-01-25 19:25 ` [PATCH 3/3] build: limit what is built when using MSVC compiler Tyler Retzlaff
@ 2023-01-26 11:10   ` Bruce Richardson
  2023-01-26 17:28     ` Tyler Retzlaff
  0 siblings, 1 reply; 44+ messages in thread
From: Bruce Richardson @ 2023-01-26 11:10 UTC (permalink / raw)
  To: Tyler Retzlaff; +Cc: dev

On Wed, Jan 25, 2023 at 11:25:07AM -0800, Tyler Retzlaff wrote:
> Build only kvargs and telemetry when is_ms_compiler.
> 
> Signed-off-by: Tyler Retzlaff <roretzla@linux.microsoft.com>
> ---
>  lib/meson.build |  7 +++++++
>  meson.build     | 13 +++++++++----
>  2 files changed, 16 insertions(+), 4 deletions(-)
> 
> diff --git a/lib/meson.build b/lib/meson.build
> index 82e4666..8e99e21 100644
<snip>
> --- a/meson.build
> +++ b/meson.build
> @@ -76,11 +76,16 @@ subdir('config')
>  
>  # build libs and drivers
>  subdir('lib')
> -subdir('drivers')
>  
> -# build binaries and installable tools
> -subdir('usertools')
> -subdir('app')
> +if is_ms_compiler
> +    enabled_apps = []
> +else
> +    subdir('drivers')
> +
> +    # build binaries and installable tools
> +    subdir('usertools')
> +    subdir('app')
> +endif
>  

My own preference here would be to put the checks inside the
subdirectories, and try and keep the top-level meson.build file clean.
Would that work ok?

>  # build docs
>  subdir('doc')
> -- 
> 1.8.3.1
> 

^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: [PATCH 3/3] build: limit what is built when using MSVC compiler
  2023-01-26 11:10   ` Bruce Richardson
@ 2023-01-26 17:28     ` Tyler Retzlaff
  2023-01-26 17:34       ` Bruce Richardson
  0 siblings, 1 reply; 44+ messages in thread
From: Tyler Retzlaff @ 2023-01-26 17:28 UTC (permalink / raw)
  To: Bruce Richardson; +Cc: dev

On Thu, Jan 26, 2023 at 11:10:26AM +0000, Bruce Richardson wrote:
> On Wed, Jan 25, 2023 at 11:25:07AM -0800, Tyler Retzlaff wrote:
> > Build only kvargs and telemetry when is_ms_compiler.
> > 
> > Signed-off-by: Tyler Retzlaff <roretzla@linux.microsoft.com>
> > ---
> >  lib/meson.build |  7 +++++++
> >  meson.build     | 13 +++++++++----
> >  2 files changed, 16 insertions(+), 4 deletions(-)
> > 
> > diff --git a/lib/meson.build b/lib/meson.build
> > index 82e4666..8e99e21 100644
> <snip>
> > --- a/meson.build
> > +++ b/meson.build
> > @@ -76,11 +76,16 @@ subdir('config')
> >  
> >  # build libs and drivers
> >  subdir('lib')
> > -subdir('drivers')
> >  
> > -# build binaries and installable tools
> > -subdir('usertools')
> > -subdir('app')
> > +if is_ms_compiler
> > +    enabled_apps = []
> > +else
> > +    subdir('drivers')
> > +
> > +    # build binaries and installable tools
> > +    subdir('usertools')
> > +    subdir('app')
> > +endif
> >  
> 
> My own preference here would be to put the checks inside the
> subdirectories, and try and keep the top-level meson.build file clean.
> Would that work ok?

no objection. one clarification request though.

do you mean just for drivers, usertools and app or do you mean for every
lib/<foo> as well?

i'll send up a v2 once i get confirmation.

> 
> >  # build docs
> >  subdir('doc')
> > -- 
> > 1.8.3.1
> > 

^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: [PATCH 3/3] build: limit what is built when using MSVC compiler
  2023-01-26 17:28     ` Tyler Retzlaff
@ 2023-01-26 17:34       ` Bruce Richardson
  2023-01-26 17:36         ` Tyler Retzlaff
  0 siblings, 1 reply; 44+ messages in thread
From: Bruce Richardson @ 2023-01-26 17:34 UTC (permalink / raw)
  To: Tyler Retzlaff; +Cc: dev

On Thu, Jan 26, 2023 at 09:28:58AM -0800, Tyler Retzlaff wrote:
> On Thu, Jan 26, 2023 at 11:10:26AM +0000, Bruce Richardson wrote:
> > On Wed, Jan 25, 2023 at 11:25:07AM -0800, Tyler Retzlaff wrote:
> > > Build only kvargs and telemetry when is_ms_compiler.
> > > 
> > > Signed-off-by: Tyler Retzlaff <roretzla@linux.microsoft.com>
> > > ---
> > >  lib/meson.build |  7 +++++++
> > >  meson.build     | 13 +++++++++----
> > >  2 files changed, 16 insertions(+), 4 deletions(-)
> > > 
> > > diff --git a/lib/meson.build b/lib/meson.build
> > > index 82e4666..8e99e21 100644
> > <snip>
> > > --- a/meson.build
> > > +++ b/meson.build
> > > @@ -76,11 +76,16 @@ subdir('config')
> > >  
> > >  # build libs and drivers
> > >  subdir('lib')
> > > -subdir('drivers')
> > >  
> > > -# build binaries and installable tools
> > > -subdir('usertools')
> > > -subdir('app')
> > > +if is_ms_compiler
> > > +    enabled_apps = []
> > > +else
> > > +    subdir('drivers')
> > > +
> > > +    # build binaries and installable tools
> > > +    subdir('usertools')
> > > +    subdir('app')
> > > +endif
> > >  
> > 
> > My own preference here would be to put the checks inside the
> > subdirectories, and try and keep the top-level meson.build file clean.
> > Would that work ok?
> 
> no objection. one clarification request though.
> 
> do you mean just for drivers, usertools and app or do you mean for every
> lib/<foo> as well?
> 

No, not for every lib, there are far too many of them. What you have done
there makes most sense. But for drivers/apps/usertools, putting the check
in the subfolder help keep the top-level file cleaner.

^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: [PATCH 3/3] build: limit what is built when using MSVC compiler
  2023-01-26 17:34       ` Bruce Richardson
@ 2023-01-26 17:36         ` Tyler Retzlaff
  0 siblings, 0 replies; 44+ messages in thread
From: Tyler Retzlaff @ 2023-01-26 17:36 UTC (permalink / raw)
  To: Bruce Richardson; +Cc: dev

On Thu, Jan 26, 2023 at 05:34:50PM +0000, Bruce Richardson wrote:
> On Thu, Jan 26, 2023 at 09:28:58AM -0800, Tyler Retzlaff wrote:
> > On Thu, Jan 26, 2023 at 11:10:26AM +0000, Bruce Richardson wrote:
> > > On Wed, Jan 25, 2023 at 11:25:07AM -0800, Tyler Retzlaff wrote:
> > > > Build only kvargs and telemetry when is_ms_compiler.
> > > > 
> > > > Signed-off-by: Tyler Retzlaff <roretzla@linux.microsoft.com>
> > > > ---
> > > >  lib/meson.build |  7 +++++++
> > > >  meson.build     | 13 +++++++++----
> > > >  2 files changed, 16 insertions(+), 4 deletions(-)
> > > > 
> > > > diff --git a/lib/meson.build b/lib/meson.build
> > > > index 82e4666..8e99e21 100644
> > > <snip>
> > > > --- a/meson.build
> > > > +++ b/meson.build
> > > > @@ -76,11 +76,16 @@ subdir('config')
> > > >  
> > > >  # build libs and drivers
> > > >  subdir('lib')
> > > > -subdir('drivers')
> > > >  
> > > > -# build binaries and installable tools
> > > > -subdir('usertools')
> > > > -subdir('app')
> > > > +if is_ms_compiler
> > > > +    enabled_apps = []
> > > > +else
> > > > +    subdir('drivers')
> > > > +
> > > > +    # build binaries and installable tools
> > > > +    subdir('usertools')
> > > > +    subdir('app')
> > > > +endif
> > > >  
> > > 
> > > My own preference here would be to put the checks inside the
> > > subdirectories, and try and keep the top-level meson.build file clean.
> > > Would that work ok?
> > 
> > no objection. one clarification request though.
> > 
> > do you mean just for drivers, usertools and app or do you mean for every
> > lib/<foo> as well?
> > 
> 
> No, not for every lib, there are far too many of them. What you have done
> there makes most sense. But for drivers/apps/usertools, putting the check
> in the subfolder help keep the top-level file cleaner.

thanks, i'll fire up v2 sometime today.

^ permalink raw reply	[flat|nested] 44+ messages in thread

* [PATCH v2 0/3] unblock the use of the MSVC compiler
  2023-01-25 19:25 [PATCH 0/3] unblock the use of the MSVC compiler Tyler Retzlaff
                   ` (2 preceding siblings ...)
  2023-01-25 19:25 ` [PATCH 3/3] build: limit what is built when using MSVC compiler Tyler Retzlaff
@ 2023-01-26 18:03 ` Tyler Retzlaff
  2023-01-26 18:03   ` [PATCH v2 1/3] build: " Tyler Retzlaff
                     ` (3 more replies)
  2023-04-25 20:08 ` [PATCH v3 0/4] enable " Tyler Retzlaff
                   ` (2 subsequent siblings)
  6 siblings, 4 replies; 44+ messages in thread
From: Tyler Retzlaff @ 2023-01-26 18:03 UTC (permalink / raw)
  To: dev; +Cc: bruce.richardson, Tyler Retzlaff

Introduce minimum changes to the build system to allow use of the MSVC
compiler.

This change is intended to enable a phased approach to allowing DPDK to
built with MSVC. Building with MSVC removes barriers to enterprise
customers use of DPDK who have constraints around security policy,
compliance and functional requirements.

Tyler Retzlaff (3):
  build: unblock the use of the MSVC compiler
  build: determine execution environment at config time
  build: limit what is built when using MSVC compiler

 app/meson.build        |  5 +++++
 buildtools/meson.build | 10 +++++++---
 config/meson.build     | 29 ++++++++++++++++++++++-------
 config/x86/meson.build |  8 +++++---
 drivers/meson.build    |  4 ++++
 lib/eal/meson.build    |  8 --------
 lib/meson.build        | 20 +++++++++++++++++---
 usertools/meson.build  |  4 ++++
 8 files changed, 64 insertions(+), 24 deletions(-)

-- 
1.8.3.1


^ permalink raw reply	[flat|nested] 44+ messages in thread

* [PATCH v2 1/3] build: unblock the use of the MSVC compiler
  2023-01-26 18:03 ` [PATCH v2 0/3] unblock the use of the " Tyler Retzlaff
@ 2023-01-26 18:03   ` Tyler Retzlaff
  2023-01-26 18:03   ` [PATCH v2 2/3] build: determine execution environment at config time Tyler Retzlaff
                     ` (2 subsequent siblings)
  3 siblings, 0 replies; 44+ messages in thread
From: Tyler Retzlaff @ 2023-01-26 18:03 UTC (permalink / raw)
  To: dev; +Cc: bruce.richardson, Tyler Retzlaff

Detect when MSVC toolset is available and tweak toolchain arguments
where the meson build system offers no abstraction.

Signed-off-by: Tyler Retzlaff <roretzla@linux.microsoft.com>
Acked-by: Bruce Richardson <bruce.richardson@intel.com>
---
 buildtools/meson.build | 10 +++++++---
 config/meson.build     | 21 ++++++++++++++-------
 config/x86/meson.build |  8 +++++---
 lib/meson.build        | 13 ++++++++++---
 4 files changed, 36 insertions(+), 16 deletions(-)

diff --git a/buildtools/meson.build b/buildtools/meson.build
index e1c600e..838c39f 100644
--- a/buildtools/meson.build
+++ b/buildtools/meson.build
@@ -4,7 +4,9 @@
 pkgconf = find_program('pkg-config', 'pkgconf', required: false)
 check_symbols = find_program('check-symbols.sh')
 ldflags_ibverbs_static = find_program('options-ibverbs-static.sh')
-objdump = find_program('objdump', 'llvm-objdump')
+if cc.get_id() != 'msvc'
+    objdump = find_program('objdump', 'llvm-objdump')
+endif
 
 python3 = import('python').find_installation(required: false)
 if python3.found()
@@ -18,8 +20,10 @@ map_to_win_cmd = py3 + files('map_to_win.py')
 sphinx_wrapper = py3 + files('call-sphinx-build.py')
 get_cpu_count_cmd = py3 + files('get-cpu-count.py')
 get_numa_count_cmd = py3 + files('get-numa-count.py')
-binutils_avx512_check = (py3 + files('binutils-avx512-check.py') +
-                        [objdump] + cc.cmd_array())
+if cc.get_id() != 'msvc'
+    binutils_avx512_check = (py3 + files('binutils-avx512-check.py') +
+                            [objdump] + cc.cmd_array())
+endif
 
 # select library and object file format
 pmdinfo = py3 + files('gen-pmdinfo-cfile.py') + [meson.current_build_dir()]
diff --git a/config/meson.build b/config/meson.build
index 6d9ffd4..898b743 100644
--- a/config/meson.build
+++ b/config/meson.build
@@ -16,7 +16,8 @@ endforeach
 
 # MS linker requires special treatment.
 # TODO: use cc.get_linker_id() with Meson >= 0.54
-is_ms_linker = is_windows and (cc.get_id() == 'clang')
+is_ms_compiler = is_windows and (cc.get_id() == 'msvc')
+is_ms_linker = is_windows and (cc.get_id() == 'clang' or is_ms_compiler)
 
 # set the major version, which might be used by drivers and libraries
 # depending on the configuration options
@@ -130,11 +131,13 @@ dpdk_conf.set('RTE_MACHINE', cpu_instruction_set)
 machine_args = []
 
 # ppc64 does not support -march= at all, use -mcpu and -mtune for that
-if host_machine.cpu_family().startswith('ppc')
-    machine_args += '-mcpu=' + cpu_instruction_set
-    machine_args += '-mtune=' + cpu_instruction_set
-else
-    machine_args += '-march=' + cpu_instruction_set
+if not is_ms_compiler
+    if host_machine.cpu_family().startswith('ppc')
+        machine_args += '-mcpu=' + cpu_instruction_set
+        machine_args += '-mtune=' + cpu_instruction_set
+    else
+        machine_args += '-march=' + cpu_instruction_set
+    endif
 endif
 
 toolchain = cc.get_id()
@@ -252,7 +255,11 @@ if cc.get_id() == 'clang' and dpdk_conf.get('RTE_ARCH_64') == false
 endif
 
 # add -include rte_config to cflags
-add_project_arguments('-include', 'rte_config.h', language: 'c')
+if is_ms_compiler
+    add_project_arguments('/FI', 'rte_config.h', language: 'c')
+else
+    add_project_arguments('-include', 'rte_config.h', language: 'c')
+endif
 
 # enable extra warnings and disable any unwanted warnings
 # -Wall is added by default at warning level 1, and -Wextra
diff --git a/config/x86/meson.build b/config/x86/meson.build
index 54345c4..11f0bcc 100644
--- a/config/x86/meson.build
+++ b/config/x86/meson.build
@@ -25,9 +25,11 @@ if cc.has_argument('-mavx512f')
 endif
 
 # we require SSE4.2 for DPDK
-if cc.get_define('__SSE4_2__', args: machine_args) == ''
-    message('SSE 4.2 not enabled by default, explicitly enabling')
-    machine_args += '-msse4'
+if not is_ms_compiler
+    if cc.get_define('__SSE4_2__', args: machine_args) == ''
+        message('SSE 4.2 not enabled by default, explicitly enabling')
+        machine_args += '-msse4'
+    endif
 endif
 
 base_flags = ['SSE', 'SSE2', 'SSE3','SSSE3', 'SSE4_1', 'SSE4_2']
diff --git a/lib/meson.build b/lib/meson.build
index a90fee3..82e4666 100644
--- a/lib/meson.build
+++ b/lib/meson.build
@@ -235,9 +235,16 @@ foreach l:libraries
                 output: '@0@_exports.def'.format(libname))
         lk_deps += [def_file]
 
-        lk_args = ['-Wl,/def:' + def_file.full_path()]
-        if meson.version().version_compare('<0.54.0')
-            lk_args += ['-Wl,/implib:lib\\librte_' + l + '.dll.a']
+        if is_ms_compiler
+            lk_args = ['/def:' + def_file.full_path()]
+            if meson.version().version_compare('<0.54.0')
+                lk_args += ['/implib:lib\\librte_' + l + '.dll.a']
+            endif
+        else
+            lk_args = ['-Wl,/def:' + def_file.full_path()]
+            if meson.version().version_compare('<0.54.0')
+                lk_args += ['-Wl,/implib:lib\\librte_' + l + '.dll.a']
+            endif
         endif
     else
         if is_windows
-- 
1.8.3.1


^ permalink raw reply	[flat|nested] 44+ messages in thread

* [PATCH v2 2/3] build: determine execution environment at config time
  2023-01-26 18:03 ` [PATCH v2 0/3] unblock the use of the " Tyler Retzlaff
  2023-01-26 18:03   ` [PATCH v2 1/3] build: " Tyler Retzlaff
@ 2023-01-26 18:03   ` Tyler Retzlaff
  2023-01-26 18:03   ` [PATCH v2 3/3] build: limit what is built when using MSVC compiler Tyler Retzlaff
  2023-01-26 18:05   ` [PATCH v2 0/3] unblock the use of the " Tyler Retzlaff
  3 siblings, 0 replies; 44+ messages in thread
From: Tyler Retzlaff @ 2023-01-26 18:03 UTC (permalink / raw)
  To: dev; +Cc: bruce.richardson, Tyler Retzlaff

Move execution environment determination and definitions to config. The
RTE_EXEC_ENV macros are actually used by libraries built before EAL.

Currently it does not matter that this is determined in lib/eal since
the definitions are consumed before anything is built including libs
built before lib/eal. By moving this logic to config it allows kvargs
and telemetry to be built without EAL.

No functional change intended.

Signed-off-by: Tyler Retzlaff <roretzla@linux.microsoft.com>
Acked-by: Bruce Richardson <bruce.richardson@intel.com>
---
 config/meson.build  | 8 ++++++++
 lib/eal/meson.build | 8 --------
 2 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/config/meson.build b/config/meson.build
index 898b743..e0b9e4e 100644
--- a/config/meson.build
+++ b/config/meson.build
@@ -14,6 +14,14 @@ foreach env:supported_exec_envs
     set_variable('is_' + env, exec_env == env)
 endforeach
 
+exec_envs = {'freebsd': 0, 'linux': 1, 'windows': 2}
+foreach env, id:exec_envs
+    dpdk_conf.set('RTE_ENV_' + env.to_upper(), id)
+    dpdk_conf.set10('RTE_EXEC_ENV_IS_' + env.to_upper(), (exec_env == env))
+endforeach
+dpdk_conf.set('RTE_EXEC_ENV', exec_envs[exec_env])
+dpdk_conf.set('RTE_EXEC_ENV_' + exec_env.to_upper(), 1)
+
 # MS linker requires special treatment.
 # TODO: use cc.get_linker_id() with Meson >= 0.54
 is_ms_compiler = is_windows and (cc.get_id() == 'msvc')
diff --git a/lib/eal/meson.build b/lib/eal/meson.build
index 056beb9..26c638f 100644
--- a/lib/eal/meson.build
+++ b/lib/eal/meson.build
@@ -10,14 +10,6 @@ if not is_windows
     subdir('unix')
 endif
 
-exec_envs = {'freebsd': 0, 'linux': 1, 'windows': 2}
-foreach env, id:exec_envs
-    dpdk_conf.set('RTE_ENV_' + env.to_upper(), id)
-    dpdk_conf.set10('RTE_EXEC_ENV_IS_' + env.to_upper(), (exec_env == env))
-endforeach
-dpdk_conf.set('RTE_EXEC_ENV', exec_envs[exec_env])
-
-dpdk_conf.set('RTE_EXEC_ENV_' + exec_env.to_upper(), 1)
 subdir(exec_env)
 
 subdir(arch_subdir)
-- 
1.8.3.1


^ permalink raw reply	[flat|nested] 44+ messages in thread

* [PATCH v2 3/3] build: limit what is built when using MSVC compiler
  2023-01-26 18:03 ` [PATCH v2 0/3] unblock the use of the " Tyler Retzlaff
  2023-01-26 18:03   ` [PATCH v2 1/3] build: " Tyler Retzlaff
  2023-01-26 18:03   ` [PATCH v2 2/3] build: determine execution environment at config time Tyler Retzlaff
@ 2023-01-26 18:03   ` Tyler Retzlaff
  2023-01-26 18:18     ` Bruce Richardson
  2023-01-26 18:05   ` [PATCH v2 0/3] unblock the use of the " Tyler Retzlaff
  3 siblings, 1 reply; 44+ messages in thread
From: Tyler Retzlaff @ 2023-01-26 18:03 UTC (permalink / raw)
  To: dev; +Cc: bruce.richardson, Tyler Retzlaff

Build only kvargs and telemetry when is_ms_compiler.

Signed-off-by: Tyler Retzlaff <roretzla@linux.microsoft.com>
---
 app/meson.build       | 5 +++++
 drivers/meson.build   | 4 ++++
 lib/meson.build       | 7 +++++++
 usertools/meson.build | 4 ++++
 4 files changed, 20 insertions(+)

diff --git a/app/meson.build b/app/meson.build
index e32ea4b..a606510 100644
--- a/app/meson.build
+++ b/app/meson.build
@@ -1,6 +1,11 @@
 # SPDX-License-Identifier: BSD-3-Clause
 # Copyright(c) 2017-2019 Intel Corporation
 
+if is_ms_compiler
+    enabled_apps = []
+    subdir_done()
+endif
+
 disable_apps = ',' + get_option('disable_apps')
 disable_apps = run_command(list_dir_globs, disable_apps, check: true).stdout().split()
 
diff --git a/drivers/meson.build b/drivers/meson.build
index c6d6192..8ed1213 100644
--- a/drivers/meson.build
+++ b/drivers/meson.build
@@ -1,6 +1,10 @@
 # SPDX-License-Identifier: BSD-3-Clause
 # Copyright(c) 2017-2019 Intel Corporation
 
+if is_ms_compiler
+    subdir_done()
+endif
+
 fs = import('fs')
 
 # Defines the order of dependencies evaluation
diff --git a/lib/meson.build b/lib/meson.build
index 82e4666..8e99e21 100644
--- a/lib/meson.build
+++ b/lib/meson.build
@@ -65,6 +65,13 @@ libraries = [
         'node',
 ]
 
+if is_ms_compiler
+    libraries = [
+            'kvargs',
+            'telemetry',
+    ]
+endif
+
 optional_libs = [
         'bitratestats',
         'cfgfile',
diff --git a/usertools/meson.build b/usertools/meson.build
index b6271a2..1a56248 100644
--- a/usertools/meson.build
+++ b/usertools/meson.build
@@ -1,6 +1,10 @@
 # SPDX-License-Identifier: BSD-3-Clause
 # Copyright(c) 2017 Intel Corporation
 
+if is_ms_compiler
+    subdir_done()
+endif
+
 install_data([
             'dpdk-devbind.py',
             'dpdk-pmdinfo.py',
-- 
1.8.3.1


^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: [PATCH v2 0/3] unblock the use of the MSVC compiler
  2023-01-26 18:03 ` [PATCH v2 0/3] unblock the use of the " Tyler Retzlaff
                     ` (2 preceding siblings ...)
  2023-01-26 18:03   ` [PATCH v2 3/3] build: limit what is built when using MSVC compiler Tyler Retzlaff
@ 2023-01-26 18:05   ` Tyler Retzlaff
  3 siblings, 0 replies; 44+ messages in thread
From: Tyler Retzlaff @ 2023-01-26 18:05 UTC (permalink / raw)
  To: dev; +Cc: bruce.richardson

On Thu, Jan 26, 2023 at 10:03:21AM -0800, Tyler Retzlaff wrote:
> Introduce minimum changes to the build system to allow use of the MSVC
> compiler.
> 
> This change is intended to enable a phased approach to allowing DPDK to
> built with MSVC. Building with MSVC removes barriers to enterprise
> customers use of DPDK who have constraints around security policy,
> compliance and functional requirements.

oops, failed to update the cover letter.

v2:
  * moved checks to skip drivers, apps, usertools directories
    in to <dir>/meson.build file and removed conditional
    check from root meson.build (patch 3/3).
   
> 
> Tyler Retzlaff (3):
>   build: unblock the use of the MSVC compiler
>   build: determine execution environment at config time
>   build: limit what is built when using MSVC compiler
> 
>  app/meson.build        |  5 +++++
>  buildtools/meson.build | 10 +++++++---
>  config/meson.build     | 29 ++++++++++++++++++++++-------
>  config/x86/meson.build |  8 +++++---
>  drivers/meson.build    |  4 ++++
>  lib/eal/meson.build    |  8 --------
>  lib/meson.build        | 20 +++++++++++++++++---
>  usertools/meson.build  |  4 ++++
>  8 files changed, 64 insertions(+), 24 deletions(-)
> 
> -- 
> 1.8.3.1

^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: [PATCH v2 3/3] build: limit what is built when using MSVC compiler
  2023-01-26 18:03   ` [PATCH v2 3/3] build: limit what is built when using MSVC compiler Tyler Retzlaff
@ 2023-01-26 18:18     ` Bruce Richardson
  0 siblings, 0 replies; 44+ messages in thread
From: Bruce Richardson @ 2023-01-26 18:18 UTC (permalink / raw)
  To: Tyler Retzlaff; +Cc: dev

On Thu, Jan 26, 2023 at 10:03:24AM -0800, Tyler Retzlaff wrote:
> Build only kvargs and telemetry when is_ms_compiler.
> 
> Signed-off-by: Tyler Retzlaff <roretzla@linux.microsoft.com>
> ---
Thanks for v2

Acked-by: Bruce Richardson <bruce.richardson@intel.com>

^ permalink raw reply	[flat|nested] 44+ messages in thread

* [PATCH v3 0/4]  enable use of the MSVC compiler
  2023-01-25 19:25 [PATCH 0/3] unblock the use of the MSVC compiler Tyler Retzlaff
                   ` (3 preceding siblings ...)
  2023-01-26 18:03 ` [PATCH v2 0/3] unblock the use of the " Tyler Retzlaff
@ 2023-04-25 20:08 ` Tyler Retzlaff
  2023-04-25 20:08   ` [PATCH v3 1/4] build: unblock the " Tyler Retzlaff
                     ` (3 more replies)
  2023-08-11 18:24 ` [PATCH v4 0/4] enable use of the MSVC compiler Tyler Retzlaff
  2023-08-16 21:56 ` [PATCH v5 0/4] enable use of the MSVC compiler Tyler Retzlaff
  6 siblings, 4 replies; 44+ messages in thread
From: Tyler Retzlaff @ 2023-04-25 20:08 UTC (permalink / raw)
  To: dev; +Cc: bruce.richardson, david.marchand, thomas, Tyler Retzlaff

Introduce minimum changes to the build system to allow use of the MSVC
compiler.

This change is intended to enable a phased approach to allowing DPDK to
built with MSVC. Building with MSVC removes barriers to enterprise
customers use of DPDK who have constraints around security policy,
compliance and functional requirements.

v3:
  * enable compilation with C11 optional atomics
  * enable compilation with C23 typeof operator
  * disable microsoft secure crt checks (dpdk code fails)
  * force use of intrinsics
  
v2:
  * moved checks to skip drivers, apps, usertools directories
    in to <dir>/meson.build file and removed conditional
    check from root meson.build (patch 3/3).


Tyler Retzlaff (4):
  build: unblock the use of the MSVC compiler
  build: determine execution environment at config time
  build: limit what is built when using MSVC compiler
  build: enable MSVC specific compiler options

 app/meson.build        |  5 +++++
 buildtools/meson.build | 10 +++++++---
 config/meson.build     | 37 ++++++++++++++++++++++++++++++-------
 config/x86/meson.build |  8 +++++---
 drivers/meson.build    |  4 ++++
 lib/eal/meson.build    |  8 --------
 lib/meson.build        | 20 +++++++++++++++++---
 usertools/meson.build  |  4 ++++
 8 files changed, 72 insertions(+), 24 deletions(-)

-- 
1.8.3.1


^ permalink raw reply	[flat|nested] 44+ messages in thread

* [PATCH v3 1/4] build: unblock the use of the MSVC compiler
  2023-04-25 20:08 ` [PATCH v3 0/4] enable " Tyler Retzlaff
@ 2023-04-25 20:08   ` Tyler Retzlaff
  2023-08-11 13:31     ` David Marchand
  2023-04-25 20:08   ` [PATCH v3 2/4] build: determine execution environment at config time Tyler Retzlaff
                     ` (2 subsequent siblings)
  3 siblings, 1 reply; 44+ messages in thread
From: Tyler Retzlaff @ 2023-04-25 20:08 UTC (permalink / raw)
  To: dev; +Cc: bruce.richardson, david.marchand, thomas, Tyler Retzlaff

Detect when MSVC toolset is available and tweak toolchain arguments
where the meson build system offers no abstraction.

Signed-off-by: Tyler Retzlaff <roretzla@linux.microsoft.com>
Acked-by: Bruce Richardson <bruce.richardson@intel.com>
---
 buildtools/meson.build | 10 +++++++---
 config/meson.build     | 21 ++++++++++++++-------
 config/x86/meson.build |  8 +++++---
 lib/meson.build        | 13 ++++++++++---
 4 files changed, 36 insertions(+), 16 deletions(-)

diff --git a/buildtools/meson.build b/buildtools/meson.build
index e1c600e..838c39f 100644
--- a/buildtools/meson.build
+++ b/buildtools/meson.build
@@ -4,7 +4,9 @@
 pkgconf = find_program('pkg-config', 'pkgconf', required: false)
 check_symbols = find_program('check-symbols.sh')
 ldflags_ibverbs_static = find_program('options-ibverbs-static.sh')
-objdump = find_program('objdump', 'llvm-objdump')
+if cc.get_id() != 'msvc'
+    objdump = find_program('objdump', 'llvm-objdump')
+endif
 
 python3 = import('python').find_installation(required: false)
 if python3.found()
@@ -18,8 +20,10 @@ map_to_win_cmd = py3 + files('map_to_win.py')
 sphinx_wrapper = py3 + files('call-sphinx-build.py')
 get_cpu_count_cmd = py3 + files('get-cpu-count.py')
 get_numa_count_cmd = py3 + files('get-numa-count.py')
-binutils_avx512_check = (py3 + files('binutils-avx512-check.py') +
-                        [objdump] + cc.cmd_array())
+if cc.get_id() != 'msvc'
+    binutils_avx512_check = (py3 + files('binutils-avx512-check.py') +
+                            [objdump] + cc.cmd_array())
+endif
 
 # select library and object file format
 pmdinfo = py3 + files('gen-pmdinfo-cfile.py') + [meson.current_build_dir()]
diff --git a/config/meson.build b/config/meson.build
index fa730a1..9a3f499 100644
--- a/config/meson.build
+++ b/config/meson.build
@@ -16,7 +16,8 @@ endforeach
 
 # MS linker requires special treatment.
 # TODO: use cc.get_linker_id() with Meson >= 0.54
-is_ms_linker = is_windows and (cc.get_id() == 'clang')
+is_ms_compiler = is_windows and (cc.get_id() == 'msvc')
+is_ms_linker = is_windows and (cc.get_id() == 'clang' or is_ms_compiler)
 
 # set the major version, which might be used by drivers and libraries
 # depending on the configuration options
@@ -130,11 +131,13 @@ dpdk_conf.set('RTE_MACHINE', cpu_instruction_set)
 machine_args = []
 
 # ppc64 does not support -march= at all, use -mcpu and -mtune for that
-if host_machine.cpu_family().startswith('ppc')
-    machine_args += '-mcpu=' + cpu_instruction_set
-    machine_args += '-mtune=' + cpu_instruction_set
-else
-    machine_args += '-march=' + cpu_instruction_set
+if not is_ms_compiler
+    if host_machine.cpu_family().startswith('ppc')
+        machine_args += '-mcpu=' + cpu_instruction_set
+        machine_args += '-mtune=' + cpu_instruction_set
+    else
+        machine_args += '-march=' + cpu_instruction_set
+    endif
 endif
 
 toolchain = cc.get_id()
@@ -253,7 +256,11 @@ if cc.get_id() == 'clang' and dpdk_conf.get('RTE_ARCH_64') == false
 endif
 
 # add -include rte_config to cflags
-add_project_arguments('-include', 'rte_config.h', language: 'c')
+if is_ms_compiler
+    add_project_arguments('/FI', 'rte_config.h', language: 'c')
+else
+    add_project_arguments('-include', 'rte_config.h', language: 'c')
+endif
 
 # enable extra warnings and disable any unwanted warnings
 # -Wall is added by default at warning level 1, and -Wextra
diff --git a/config/x86/meson.build b/config/x86/meson.build
index 54345c4..11f0bcc 100644
--- a/config/x86/meson.build
+++ b/config/x86/meson.build
@@ -25,9 +25,11 @@ if cc.has_argument('-mavx512f')
 endif
 
 # we require SSE4.2 for DPDK
-if cc.get_define('__SSE4_2__', args: machine_args) == ''
-    message('SSE 4.2 not enabled by default, explicitly enabling')
-    machine_args += '-msse4'
+if not is_ms_compiler
+    if cc.get_define('__SSE4_2__', args: machine_args) == ''
+        message('SSE 4.2 not enabled by default, explicitly enabling')
+        machine_args += '-msse4'
+    endif
 endif
 
 base_flags = ['SSE', 'SSE2', 'SSE3','SSSE3', 'SSE4_1', 'SSE4_2']
diff --git a/lib/meson.build b/lib/meson.build
index dc8aa4a..40c632a 100644
--- a/lib/meson.build
+++ b/lib/meson.build
@@ -241,9 +241,16 @@ foreach l:libraries
                 output: '@0@_exports.def'.format(libname))
         lk_deps += [def_file]
 
-        lk_args = ['-Wl,/def:' + def_file.full_path()]
-        if meson.version().version_compare('<0.54.0')
-            lk_args += ['-Wl,/implib:lib\\librte_' + l + '.dll.a']
+        if is_ms_compiler
+            lk_args = ['/def:' + def_file.full_path()]
+            if meson.version().version_compare('<0.54.0')
+                lk_args += ['/implib:lib\\librte_' + l + '.dll.a']
+            endif
+        else
+            lk_args = ['-Wl,/def:' + def_file.full_path()]
+            if meson.version().version_compare('<0.54.0')
+                lk_args += ['-Wl,/implib:lib\\librte_' + l + '.dll.a']
+            endif
         endif
     else
         if is_windows
-- 
1.8.3.1


^ permalink raw reply	[flat|nested] 44+ messages in thread

* [PATCH v3 2/4] build: determine execution environment at config time
  2023-04-25 20:08 ` [PATCH v3 0/4] enable " Tyler Retzlaff
  2023-04-25 20:08   ` [PATCH v3 1/4] build: unblock the " Tyler Retzlaff
@ 2023-04-25 20:08   ` Tyler Retzlaff
  2023-04-25 20:08   ` [PATCH v3 3/4] build: limit what is built when using MSVC compiler Tyler Retzlaff
  2023-04-25 20:08   ` [PATCH v3 4/4] build: enable MSVC specific compiler options Tyler Retzlaff
  3 siblings, 0 replies; 44+ messages in thread
From: Tyler Retzlaff @ 2023-04-25 20:08 UTC (permalink / raw)
  To: dev; +Cc: bruce.richardson, david.marchand, thomas, Tyler Retzlaff

Move execution environment determination and definitions to config. The
RTE_EXEC_ENV macros are actually used by libraries built before EAL.

Currently it does not matter that this is determined in lib/eal since
the definitions are consumed before anything is built including libs
built before lib/eal. By moving this logic to config it allows kvargs
and telemetry to be built without EAL.

No functional change intended.

Signed-off-by: Tyler Retzlaff <roretzla@linux.microsoft.com>
Acked-by: Bruce Richardson <bruce.richardson@intel.com>
---
 config/meson.build  | 8 ++++++++
 lib/eal/meson.build | 8 --------
 2 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/config/meson.build b/config/meson.build
index 9a3f499..d2b12db 100644
--- a/config/meson.build
+++ b/config/meson.build
@@ -14,6 +14,14 @@ foreach env:supported_exec_envs
     set_variable('is_' + env, exec_env == env)
 endforeach
 
+exec_envs = {'freebsd': 0, 'linux': 1, 'windows': 2}
+foreach env, id:exec_envs
+    dpdk_conf.set('RTE_ENV_' + env.to_upper(), id)
+    dpdk_conf.set10('RTE_EXEC_ENV_IS_' + env.to_upper(), (exec_env == env))
+endforeach
+dpdk_conf.set('RTE_EXEC_ENV', exec_envs[exec_env])
+dpdk_conf.set('RTE_EXEC_ENV_' + exec_env.to_upper(), 1)
+
 # MS linker requires special treatment.
 # TODO: use cc.get_linker_id() with Meson >= 0.54
 is_ms_compiler = is_windows and (cc.get_id() == 'msvc')
diff --git a/lib/eal/meson.build b/lib/eal/meson.build
index 9aa941a..d5eeb07 100644
--- a/lib/eal/meson.build
+++ b/lib/eal/meson.build
@@ -10,14 +10,6 @@ if not is_windows
     subdir('unix')
 endif
 
-exec_envs = {'freebsd': 0, 'linux': 1, 'windows': 2}
-foreach env, id:exec_envs
-    dpdk_conf.set('RTE_ENV_' + env.to_upper(), id)
-    dpdk_conf.set10('RTE_EXEC_ENV_IS_' + env.to_upper(), (exec_env == env))
-endforeach
-dpdk_conf.set('RTE_EXEC_ENV', exec_envs[exec_env])
-
-dpdk_conf.set('RTE_EXEC_ENV_' + exec_env.to_upper(), 1)
 subdir(exec_env)
 
 subdir(arch_subdir)
-- 
1.8.3.1


^ permalink raw reply	[flat|nested] 44+ messages in thread

* [PATCH v3 3/4] build: limit what is built when using MSVC compiler
  2023-04-25 20:08 ` [PATCH v3 0/4] enable " Tyler Retzlaff
  2023-04-25 20:08   ` [PATCH v3 1/4] build: unblock the " Tyler Retzlaff
  2023-04-25 20:08   ` [PATCH v3 2/4] build: determine execution environment at config time Tyler Retzlaff
@ 2023-04-25 20:08   ` Tyler Retzlaff
  2023-08-11 13:31     ` David Marchand
  2023-04-25 20:08   ` [PATCH v3 4/4] build: enable MSVC specific compiler options Tyler Retzlaff
  3 siblings, 1 reply; 44+ messages in thread
From: Tyler Retzlaff @ 2023-04-25 20:08 UTC (permalink / raw)
  To: dev; +Cc: bruce.richardson, david.marchand, thomas, Tyler Retzlaff

Build only kvargs and telemetry when is_ms_compiler.

Signed-off-by: Tyler Retzlaff <roretzla@linux.microsoft.com>
Acked-by: Bruce Richardson <bruce.richardson@intel.com>
---
 app/meson.build       | 5 +++++
 drivers/meson.build   | 4 ++++
 lib/meson.build       | 7 +++++++
 usertools/meson.build | 4 ++++
 4 files changed, 20 insertions(+)

diff --git a/app/meson.build b/app/meson.build
index 74d2420..94fd7c9 100644
--- a/app/meson.build
+++ b/app/meson.build
@@ -1,6 +1,11 @@
 # SPDX-License-Identifier: BSD-3-Clause
 # Copyright(c) 2017-2019 Intel Corporation
 
+if is_ms_compiler
+    enabled_apps = []
+    subdir_done()
+endif
+
 disable_apps = ',' + get_option('disable_apps')
 disable_apps = run_command(list_dir_globs, disable_apps, check: true).stdout().split()
 
diff --git a/drivers/meson.build b/drivers/meson.build
index 74ae8cb..749ec20 100644
--- a/drivers/meson.build
+++ b/drivers/meson.build
@@ -1,6 +1,10 @@
 # SPDX-License-Identifier: BSD-3-Clause
 # Copyright(c) 2017-2019 Intel Corporation
 
+if is_ms_compiler
+    subdir_done()
+endif
+
 fs = import('fs')
 
 # Defines the order of dependencies evaluation
diff --git a/lib/meson.build b/lib/meson.build
index 40c632a..777d3d3 100644
--- a/lib/meson.build
+++ b/lib/meson.build
@@ -66,6 +66,13 @@ libraries = [
         'node',
 ]
 
+if is_ms_compiler
+    libraries = [
+            'kvargs',
+            'telemetry',
+    ]
+endif
+
 optional_libs = [
         'bitratestats',
         'cfgfile',
diff --git a/usertools/meson.build b/usertools/meson.build
index b6271a2..1a56248 100644
--- a/usertools/meson.build
+++ b/usertools/meson.build
@@ -1,6 +1,10 @@
 # SPDX-License-Identifier: BSD-3-Clause
 # Copyright(c) 2017 Intel Corporation
 
+if is_ms_compiler
+    subdir_done()
+endif
+
 install_data([
             'dpdk-devbind.py',
             'dpdk-pmdinfo.py',
-- 
1.8.3.1


^ permalink raw reply	[flat|nested] 44+ messages in thread

* [PATCH v3 4/4] build: enable MSVC specific compiler options
  2023-04-25 20:08 ` [PATCH v3 0/4] enable " Tyler Retzlaff
                     ` (2 preceding siblings ...)
  2023-04-25 20:08   ` [PATCH v3 3/4] build: limit what is built when using MSVC compiler Tyler Retzlaff
@ 2023-04-25 20:08   ` Tyler Retzlaff
  3 siblings, 0 replies; 44+ messages in thread
From: Tyler Retzlaff @ 2023-04-25 20:08 UTC (permalink / raw)
  To: dev; +Cc: bruce.richardson, david.marchand, thomas, Tyler Retzlaff

* Enable optional use of C11 atomics support.
* Enable use of C23 typeof operator.
* Explicitly force intrinsics when building with MSVC.
* Disable MSVC C runtime checks.

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

diff --git a/config/meson.build b/config/meson.build
index d2b12db..9484449 100644
--- a/config/meson.build
+++ b/config/meson.build
@@ -27,6 +27,14 @@ dpdk_conf.set('RTE_EXEC_ENV_' + exec_env.to_upper(), 1)
 is_ms_compiler = is_windows and (cc.get_id() == 'msvc')
 is_ms_linker = is_windows and (cc.get_id() == 'clang' or is_ms_compiler)
 
+# MS compiler (except x86) does not support inline assembly
+if is_ms_compiler
+    dpdk_conf.set('_CRT_SECURE_NO_WARNINGS', 1)
+    dpdk_conf.set('RTE_FORCE_INTRINSICS', 1)
+    add_project_arguments('/experimental:c11atomics', language: 'c')
+    add_project_arguments('/d1experimental:typeof', language: 'c')
+endif
+
 # set the major version, which might be used by drivers and libraries
 # depending on the configuration options
 pver = meson.project_version().split('.')
-- 
1.8.3.1


^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: [PATCH v3 1/4] build: unblock the use of the MSVC compiler
  2023-04-25 20:08   ` [PATCH v3 1/4] build: unblock the " Tyler Retzlaff
@ 2023-08-11 13:31     ` David Marchand
  0 siblings, 0 replies; 44+ messages in thread
From: David Marchand @ 2023-08-11 13:31 UTC (permalink / raw)
  To: Tyler Retzlaff, bruce.richardson; +Cc: dev, thomas

On Tue, Apr 25, 2023 at 10:08 PM Tyler Retzlaff
<roretzla@linux.microsoft.com> wrote:
>
> Detect when MSVC toolset is available and tweak toolchain arguments
> where the meson build system offers no abstraction.
>
> Signed-off-by: Tyler Retzlaff <roretzla@linux.microsoft.com>
> Acked-by: Bruce Richardson <bruce.richardson@intel.com>
> ---
>  buildtools/meson.build | 10 +++++++---
>  config/meson.build     | 21 ++++++++++++++-------
>  config/x86/meson.build |  8 +++++---
>  lib/meson.build        | 13 ++++++++++---
>  4 files changed, 36 insertions(+), 16 deletions(-)
>
> diff --git a/buildtools/meson.build b/buildtools/meson.build
> index e1c600e..838c39f 100644
> --- a/buildtools/meson.build
> +++ b/buildtools/meson.build
> @@ -4,7 +4,9 @@
>  pkgconf = find_program('pkg-config', 'pkgconf', required: false)
>  check_symbols = find_program('check-symbols.sh')

I don't expect check-symbols.sh to work if objdump is not available.

>  ldflags_ibverbs_static = find_program('options-ibverbs-static.sh')
> -objdump = find_program('objdump', 'llvm-objdump')
> +if cc.get_id() != 'msvc'
> +    objdump = find_program('objdump', 'llvm-objdump')
> +endif

Looking at objdump users in meson, I only see the avx512 stuff.
The avx512 check is only called under a gcc check in
config/x86/meson.build, so I would move both definitions (and
potentially the script itself) under config/x86.
Something like:
https://patchwork.dpdk.org/project/dpdk/patch/20230811131024.2285366-1-david.marchand@redhat.com/


>
>  python3 = import('python').find_installation(required: false)
>  if python3.found()
> @@ -18,8 +20,10 @@ map_to_win_cmd = py3 + files('map_to_win.py')
>  sphinx_wrapper = py3 + files('call-sphinx-build.py')
>  get_cpu_count_cmd = py3 + files('get-cpu-count.py')
>  get_numa_count_cmd = py3 + files('get-numa-count.py')
> -binutils_avx512_check = (py3 + files('binutils-avx512-check.py') +
> -                        [objdump] + cc.cmd_array())
> +if cc.get_id() != 'msvc'
> +    binutils_avx512_check = (py3 + files('binutils-avx512-check.py') +
> +                            [objdump] + cc.cmd_array())
> +endif
>
>  # select library and object file format
>  pmdinfo = py3 + files('gen-pmdinfo-cfile.py') + [meson.current_build_dir()]
> diff --git a/config/meson.build b/config/meson.build
> index fa730a1..9a3f499 100644
> --- a/config/meson.build
> +++ b/config/meson.build
> @@ -16,7 +16,8 @@ endforeach
>
>  # MS linker requires special treatment.
>  # TODO: use cc.get_linker_id() with Meson >= 0.54
> -is_ms_linker = is_windows and (cc.get_id() == 'clang')
> +is_ms_compiler = is_windows and (cc.get_id() == 'msvc')
> +is_ms_linker = is_windows and (cc.get_id() == 'clang' or is_ms_compiler)
>
>  # set the major version, which might be used by drivers and libraries
>  # depending on the configuration options
> @@ -130,11 +131,13 @@ dpdk_conf.set('RTE_MACHINE', cpu_instruction_set)
>  machine_args = []
>
>  # ppc64 does not support -march= at all, use -mcpu and -mtune for that

This comment can be moved in the block too.

> -if host_machine.cpu_family().startswith('ppc')
> -    machine_args += '-mcpu=' + cpu_instruction_set
> -    machine_args += '-mtune=' + cpu_instruction_set
> -else
> -    machine_args += '-march=' + cpu_instruction_set
> +if not is_ms_compiler
> +    if host_machine.cpu_family().startswith('ppc')
> +        machine_args += '-mcpu=' + cpu_instruction_set
> +        machine_args += '-mtune=' + cpu_instruction_set
> +    else
> +        machine_args += '-march=' + cpu_instruction_set
> +    endif
>  endif
>
>  toolchain = cc.get_id()
> @@ -253,7 +256,11 @@ if cc.get_id() == 'clang' and dpdk_conf.get('RTE_ARCH_64') == false
>  endif
>
>  # add -include rte_config to cflags
> -add_project_arguments('-include', 'rte_config.h', language: 'c')
> +if is_ms_compiler
> +    add_project_arguments('/FI', 'rte_config.h', language: 'c')
> +else
> +    add_project_arguments('-include', 'rte_config.h', language: 'c')
> +endif
>
>  # enable extra warnings and disable any unwanted warnings
>  # -Wall is added by default at warning level 1, and -Wextra
> diff --git a/config/x86/meson.build b/config/x86/meson.build
> index 54345c4..11f0bcc 100644
> --- a/config/x86/meson.build
> +++ b/config/x86/meson.build
> @@ -25,9 +25,11 @@ if cc.has_argument('-mavx512f')
>  endif
>
>  # we require SSE4.2 for DPDK

Are there requirements we announce for MSVC builds?
In any case, please move this comment in the block.


> -if cc.get_define('__SSE4_2__', args: machine_args) == ''
> -    message('SSE 4.2 not enabled by default, explicitly enabling')
> -    machine_args += '-msse4'
> +if not is_ms_compiler
> +    if cc.get_define('__SSE4_2__', args: machine_args) == ''
> +        message('SSE 4.2 not enabled by default, explicitly enabling')
> +        machine_args += '-msse4'
> +    endif
>  endif
>
>  base_flags = ['SSE', 'SSE2', 'SSE3','SSSE3', 'SSE4_1', 'SSE4_2']
> diff --git a/lib/meson.build b/lib/meson.build
> index dc8aa4a..40c632a 100644
> --- a/lib/meson.build
> +++ b/lib/meson.build
> @@ -241,9 +241,16 @@ foreach l:libraries
>                  output: '@0@_exports.def'.format(libname))
>          lk_deps += [def_file]
>
> -        lk_args = ['-Wl,/def:' + def_file.full_path()]
> -        if meson.version().version_compare('<0.54.0')
> -            lk_args += ['-Wl,/implib:lib\\librte_' + l + '.dll.a']
> +        if is_ms_compiler
> +            lk_args = ['/def:' + def_file.full_path()]
> +            if meson.version().version_compare('<0.54.0')
> +                lk_args += ['/implib:lib\\librte_' + l + '.dll.a']
> +            endif
> +        else
> +            lk_args = ['-Wl,/def:' + def_file.full_path()]
> +            if meson.version().version_compare('<0.54.0')
> +                lk_args += ['-Wl,/implib:lib\\librte_' + l + '.dll.a']
> +            endif
>          endif
>      else
>          if is_windows
> --
> 1.8.3.1
>


-- 
David Marchand


^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: [PATCH v3 3/4] build: limit what is built when using MSVC compiler
  2023-04-25 20:08   ` [PATCH v3 3/4] build: limit what is built when using MSVC compiler Tyler Retzlaff
@ 2023-08-11 13:31     ` David Marchand
  0 siblings, 0 replies; 44+ messages in thread
From: David Marchand @ 2023-08-11 13:31 UTC (permalink / raw)
  To: Tyler Retzlaff; +Cc: dev, bruce.richardson, thomas

On Tue, Apr 25, 2023 at 10:08 PM Tyler Retzlaff
<roretzla@linux.microsoft.com> wrote:
>
> Build only kvargs and telemetry when is_ms_compiler.
>
> Signed-off-by: Tyler Retzlaff <roretzla@linux.microsoft.com>
> Acked-by: Bruce Richardson <bruce.richardson@intel.com>
> ---
>  app/meson.build       | 5 +++++
>  drivers/meson.build   | 4 ++++
>  lib/meson.build       | 7 +++++++
>  usertools/meson.build | 4 ++++
>  4 files changed, 20 insertions(+)
>
> diff --git a/app/meson.build b/app/meson.build
> index 74d2420..94fd7c9 100644
> --- a/app/meson.build
> +++ b/app/meson.build
> @@ -1,6 +1,11 @@
>  # SPDX-License-Identifier: BSD-3-Clause
>  # Copyright(c) 2017-2019 Intel Corporation
>
> +if is_ms_compiler
> +    enabled_apps = []

Nit: This could be moved to the top of the tree meson.build:
https://patchwork.dpdk.org/project/dpdk/patch/20230811132805.2434448-1-david.marchand@redhat.com/


> +    subdir_done()
> +endif
> +
>  disable_apps = ',' + get_option('disable_apps')
>  disable_apps = run_command(list_dir_globs, disable_apps, check: true).stdout().split()
>
> diff --git a/drivers/meson.build b/drivers/meson.build
> index 74ae8cb..749ec20 100644
> --- a/drivers/meson.build
> +++ b/drivers/meson.build
> @@ -1,6 +1,10 @@
>  # SPDX-License-Identifier: BSD-3-Clause
>  # Copyright(c) 2017-2019 Intel Corporation
>
> +if is_ms_compiler
> +    subdir_done()
> +endif
> +
>  fs = import('fs')
>
>  # Defines the order of dependencies evaluation
> diff --git a/lib/meson.build b/lib/meson.build
> index 40c632a..777d3d3 100644
> --- a/lib/meson.build
> +++ b/lib/meson.build
> @@ -66,6 +66,13 @@ libraries = [
>          'node',
>  ]
>
> +if is_ms_compiler
> +    libraries = [

The log library must be added here, now that telemetry depends on it.



> +            'kvargs',
> +            'telemetry',
> +    ]
> +endif
> +
>  optional_libs = [
>          'bitratestats',
>          'cfgfile',
> diff --git a/usertools/meson.build b/usertools/meson.build
> index b6271a2..1a56248 100644
> --- a/usertools/meson.build
> +++ b/usertools/meson.build
> @@ -1,6 +1,10 @@
>  # SPDX-License-Identifier: BSD-3-Clause
>  # Copyright(c) 2017 Intel Corporation
>
> +if is_ms_compiler
> +    subdir_done()
> +endif
> +
>  install_data([
>              'dpdk-devbind.py',
>              'dpdk-pmdinfo.py',
> --
> 1.8.3.1
>


-- 
David Marchand


^ permalink raw reply	[flat|nested] 44+ messages in thread

* [PATCH v4 0/4] enable use of the MSVC compiler
  2023-01-25 19:25 [PATCH 0/3] unblock the use of the MSVC compiler Tyler Retzlaff
                   ` (4 preceding siblings ...)
  2023-04-25 20:08 ` [PATCH v3 0/4] enable " Tyler Retzlaff
@ 2023-08-11 18:24 ` Tyler Retzlaff
  2023-08-11 18:24   ` [PATCH v4 1/4] build: unblock the " Tyler Retzlaff
                     ` (3 more replies)
  2023-08-16 21:56 ` [PATCH v5 0/4] enable use of the MSVC compiler Tyler Retzlaff
  6 siblings, 4 replies; 44+ messages in thread
From: Tyler Retzlaff @ 2023-08-11 18:24 UTC (permalink / raw)
  To: dev
  Cc: Bruce Richardson, Konstantin Ananyev, david.marchand, thomas,
	Tyler Retzlaff

Introduce minimum changes to the build system to allow use of the MSVC
compiler.

This change is intended to enable a phased approach to allowing DPDK to
built with MSVC. Building with MSVC removes barriers to enterprise
customers use of DPDK who have constraints around security policy,
compliance and functional requirements.

v4:
  * Remove conditional if cc.get_id() != 'msvc' for assignment of
    objdump and binutils_avx512_check in anticipation of merge of
    patch from David Marchand
    https://patchwork.dpdk.org/project/dpdk/patch/20230811131024.2285366-1-david.marchand@redhat.com
    Note:
      I'm aware that none of the shell scripts here are usable on the
      windows build, it's a gap we hope to fill in the future for now
      we hap hazardly rely on the linux builds.
  * Remove enabled_apps = [] apps when skipping apps/meson.build for
    is_ms_compiler in anticipation of merge of patch from David Marchand
    https://patchwork.dpdk.org/project/dpdk/patch/20230811132805.2434448-1-david.marchand@redhat.com
  * Rebase series and include 'log' library as it is now required by
    kvargs and telemetry libs
  * Move 2 comments into block scope ehre they apply
    Note:
      There are no requirements specifically for msvc compiler
      beyond those that would cause build to fail when the
      currently experimental options are used. when i know the
      final version of the compiler needed it will be documented
      in the windows quick start guide.

v3:
  * enable compilation with C11 optional atomics
  * enable compilation with C23 typeof operator
  * disable microsoft secure crt checks (dpdk code fails)
  * force use of intrinsics

v2:
  * moved checks to skip drivers, apps, usertools directories
    in to <dir>/meson.build file and removed conditional
    check from root meson.build (patch 3/3)

Tyler Retzlaff (4):
  build: unblock the use of the MSVC compiler
  build: determine execution environment at config time
  build: limit what is built when using MSVC compiler
  build: enable MSVC specific compiler options

 app/meson.build        |  6 ++++--
 config/meson.build     | 39 +++++++++++++++++++++++++++++++--------
 config/x86/meson.build | 10 ++++++----
 drivers/meson.build    |  4 ++++
 lib/eal/meson.build    |  8 --------
 lib/meson.build        | 21 ++++++++++++++++++---
 usertools/meson.build  |  4 ++++
 7 files changed, 67 insertions(+), 25 deletions(-)

-- 
1.8.3.1


^ permalink raw reply	[flat|nested] 44+ messages in thread

* [PATCH v4 1/4] build: unblock the use of the MSVC compiler
  2023-08-11 18:24 ` [PATCH v4 0/4] enable use of the MSVC compiler Tyler Retzlaff
@ 2023-08-11 18:24   ` Tyler Retzlaff
  2023-08-14  8:27     ` Bruce Richardson
  2023-08-11 18:24   ` [PATCH v4 2/4] build: determine execution environment at config time Tyler Retzlaff
                     ` (2 subsequent siblings)
  3 siblings, 1 reply; 44+ messages in thread
From: Tyler Retzlaff @ 2023-08-11 18:24 UTC (permalink / raw)
  To: dev
  Cc: Bruce Richardson, Konstantin Ananyev, david.marchand, thomas,
	Tyler Retzlaff

Detect when MSVC toolset is available and tweak toolchain arguments
where the meson build system offers no abstraction.

Signed-off-by: Tyler Retzlaff <roretzla@linux.microsoft.com>
Acked-by: Bruce Richardson <bruce.richardson@intel.com>
---
 config/meson.build     | 23 +++++++++++++++--------
 config/x86/meson.build | 10 ++++++----
 lib/meson.build        | 13 ++++++++++---
 3 files changed, 31 insertions(+), 15 deletions(-)

diff --git a/config/meson.build b/config/meson.build
index d822371..b6c7d48 100644
--- a/config/meson.build
+++ b/config/meson.build
@@ -16,7 +16,8 @@ endforeach
 
 # MS linker requires special treatment.
 # TODO: use cc.get_linker_id() with Meson >= 0.54
-is_ms_linker = is_windows and (cc.get_id() == 'clang')
+is_ms_compiler = is_windows and (cc.get_id() == 'msvc')
+is_ms_linker = is_windows and (cc.get_id() == 'clang' or is_ms_compiler)
 
 # set the major version, which might be used by drivers and libraries
 # depending on the configuration options
@@ -129,12 +130,14 @@ endif
 dpdk_conf.set('RTE_MACHINE', cpu_instruction_set)
 machine_args = []
 
-# ppc64 does not support -march= at all, use -mcpu and -mtune for that
-if host_machine.cpu_family().startswith('ppc')
-    machine_args += '-mcpu=' + cpu_instruction_set
-    machine_args += '-mtune=' + cpu_instruction_set
-else
-    machine_args += '-march=' + cpu_instruction_set
+if not is_ms_compiler
+    # ppc64 does not support -march= at all, use -mcpu and -mtune for that
+    if host_machine.cpu_family().startswith('ppc')
+        machine_args += '-mcpu=' + cpu_instruction_set
+        machine_args += '-mtune=' + cpu_instruction_set
+    else
+        machine_args += '-march=' + cpu_instruction_set
+    endif
 endif
 
 toolchain = cc.get_id()
@@ -253,7 +256,11 @@ if cc.get_id() == 'clang' and dpdk_conf.get('RTE_ARCH_64') == false
 endif
 
 # add -include rte_config to cflags
-add_project_arguments('-include', 'rte_config.h', language: 'c')
+if is_ms_compiler
+    add_project_arguments('/FI', 'rte_config.h', language: 'c')
+else
+    add_project_arguments('-include', 'rte_config.h', language: 'c')
+endif
 
 # enable extra warnings and disable any unwanted warnings
 # -Wall is added by default at warning level 1, and -Wextra
diff --git a/config/x86/meson.build b/config/x86/meson.build
index 54345c4..38cc1e3 100644
--- a/config/x86/meson.build
+++ b/config/x86/meson.build
@@ -24,10 +24,12 @@ if cc.has_argument('-mavx512f')
     endif
 endif
 
-# we require SSE4.2 for DPDK
-if cc.get_define('__SSE4_2__', args: machine_args) == ''
-    message('SSE 4.2 not enabled by default, explicitly enabling')
-    machine_args += '-msse4'
+if not is_ms_compiler
+    # we require SSE4.2 for DPDK
+    if cc.get_define('__SSE4_2__', args: machine_args) == ''
+        message('SSE 4.2 not enabled by default, explicitly enabling')
+        machine_args += '-msse4'
+    endif
 endif
 
 base_flags = ['SSE', 'SSE2', 'SSE3','SSSE3', 'SSE4_1', 'SSE4_2']
diff --git a/lib/meson.build b/lib/meson.build
index 92cbd6b..7da3698 100644
--- a/lib/meson.build
+++ b/lib/meson.build
@@ -230,9 +230,16 @@ foreach l:libraries
                 output: '@0@_exports.def'.format(libname))
         lk_deps += [def_file]
 
-        lk_args = ['-Wl,/def:' + def_file.full_path()]
-        if meson.version().version_compare('<0.54.0')
-            lk_args += ['-Wl,/implib:lib\\librte_' + l + '.dll.a']
+        if is_ms_compiler
+            lk_args = ['/def:' + def_file.full_path()]
+            if meson.version().version_compare('<0.54.0')
+                lk_args += ['/implib:lib\\librte_' + l + '.dll.a']
+            endif
+        else
+            lk_args = ['-Wl,/def:' + def_file.full_path()]
+            if meson.version().version_compare('<0.54.0')
+                lk_args += ['-Wl,/implib:lib\\librte_' + l + '.dll.a']
+            endif
         endif
     else
         if is_windows
-- 
1.8.3.1


^ permalink raw reply	[flat|nested] 44+ messages in thread

* [PATCH v4 2/4] build: determine execution environment at config time
  2023-08-11 18:24 ` [PATCH v4 0/4] enable use of the MSVC compiler Tyler Retzlaff
  2023-08-11 18:24   ` [PATCH v4 1/4] build: unblock the " Tyler Retzlaff
@ 2023-08-11 18:24   ` Tyler Retzlaff
  2023-08-11 18:24   ` [PATCH v4 3/4] build: limit what is built when using MSVC compiler Tyler Retzlaff
  2023-08-11 18:24   ` [PATCH v4 4/4] build: enable MSVC specific compiler options Tyler Retzlaff
  3 siblings, 0 replies; 44+ messages in thread
From: Tyler Retzlaff @ 2023-08-11 18:24 UTC (permalink / raw)
  To: dev
  Cc: Bruce Richardson, Konstantin Ananyev, david.marchand, thomas,
	Tyler Retzlaff

Move execution environment determination and definitions to config. The
RTE_EXEC_ENV macros are actually used by libraries built before EAL.

Currently it does not matter that this is determined in lib/eal since
the definitions are consumed before anything is built including libs
built before lib/eal. By moving this logic to config it allows kvargs
and telemetry to be built without EAL.

No functional change intended.

Signed-off-by: Tyler Retzlaff <roretzla@linux.microsoft.com>
Acked-by: Bruce Richardson <bruce.richardson@intel.com>
---
 config/meson.build  | 8 ++++++++
 lib/eal/meson.build | 8 --------
 2 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/config/meson.build b/config/meson.build
index b6c7d48..821a1c3 100644
--- a/config/meson.build
+++ b/config/meson.build
@@ -14,6 +14,14 @@ foreach env:supported_exec_envs
     set_variable('is_' + env, exec_env == env)
 endforeach
 
+exec_envs = {'freebsd': 0, 'linux': 1, 'windows': 2}
+foreach env, id:exec_envs
+    dpdk_conf.set('RTE_ENV_' + env.to_upper(), id)
+    dpdk_conf.set10('RTE_EXEC_ENV_IS_' + env.to_upper(), (exec_env == env))
+endforeach
+dpdk_conf.set('RTE_EXEC_ENV', exec_envs[exec_env])
+dpdk_conf.set('RTE_EXEC_ENV_' + exec_env.to_upper(), 1)
+
 # MS linker requires special treatment.
 # TODO: use cc.get_linker_id() with Meson >= 0.54
 is_ms_compiler = is_windows and (cc.get_id() == 'msvc')
diff --git a/lib/eal/meson.build b/lib/eal/meson.build
index 0fb974c..9942104 100644
--- a/lib/eal/meson.build
+++ b/lib/eal/meson.build
@@ -10,14 +10,6 @@ if not is_windows
     subdir('unix')
 endif
 
-exec_envs = {'freebsd': 0, 'linux': 1, 'windows': 2}
-foreach env, id:exec_envs
-    dpdk_conf.set('RTE_ENV_' + env.to_upper(), id)
-    dpdk_conf.set10('RTE_EXEC_ENV_IS_' + env.to_upper(), (exec_env == env))
-endforeach
-dpdk_conf.set('RTE_EXEC_ENV', exec_envs[exec_env])
-
-dpdk_conf.set('RTE_EXEC_ENV_' + exec_env.to_upper(), 1)
 subdir(exec_env)
 
 subdir(arch_subdir)
-- 
1.8.3.1


^ permalink raw reply	[flat|nested] 44+ messages in thread

* [PATCH v4 3/4] build: limit what is built when using MSVC compiler
  2023-08-11 18:24 ` [PATCH v4 0/4] enable use of the MSVC compiler Tyler Retzlaff
  2023-08-11 18:24   ` [PATCH v4 1/4] build: unblock the " Tyler Retzlaff
  2023-08-11 18:24   ` [PATCH v4 2/4] build: determine execution environment at config time Tyler Retzlaff
@ 2023-08-11 18:24   ` Tyler Retzlaff
  2023-08-11 18:26     ` Tyler Retzlaff
  2023-08-11 18:24   ` [PATCH v4 4/4] build: enable MSVC specific compiler options Tyler Retzlaff
  3 siblings, 1 reply; 44+ messages in thread
From: Tyler Retzlaff @ 2023-08-11 18:24 UTC (permalink / raw)
  To: dev
  Cc: Bruce Richardson, Konstantin Ananyev, david.marchand, thomas,
	Tyler Retzlaff

Build only kvargs and telemetry when is_ms_compiler.

Signed-off-by: Tyler Retzlaff <roretzla@linux.microsoft.com>
Acked-by: Bruce Richardson <bruce.richardson@intel.com>
---
 app/meson.build       | 6 ++++--
 drivers/meson.build   | 4 ++++
 lib/meson.build       | 8 ++++++++
 usertools/meson.build | 4 ++++
 4 files changed, 20 insertions(+), 2 deletions(-)

diff --git a/app/meson.build b/app/meson.build
index 4fc1a83..23a9d2e 100644
--- a/app/meson.build
+++ b/app/meson.build
@@ -1,6 +1,10 @@
 # SPDX-License-Identifier: BSD-3-Clause
 # Copyright(c) 2017-2019 Intel Corporation
 
+if is_ms_compiler
+    subdir_done()
+endif
+
 disable_apps = ',' + get_option('disable_apps')
 disable_apps = run_command(list_dir_globs, disable_apps, check: true).stdout().split()
 
@@ -38,8 +42,6 @@ if get_option('default_library') == 'static' and not is_windows
     default_ldflags += ['-Wl,--export-dynamic']
 endif
 
-enabled_apps = [] # used to print summary at the end
-
 foreach app:apps
     name = app
     build = true
diff --git a/drivers/meson.build b/drivers/meson.build
index c909070..417b64b 100644
--- a/drivers/meson.build
+++ b/drivers/meson.build
@@ -1,6 +1,10 @@
 # SPDX-License-Identifier: BSD-3-Clause
 # Copyright(c) 2017-2019 Intel Corporation
 
+if is_ms_compiler
+    subdir_done()
+endif
+
 fs = import('fs')
 
 # Defines the order of dependencies evaluation
diff --git a/lib/meson.build b/lib/meson.build
index 7da3698..77c3e74 100644
--- a/lib/meson.build
+++ b/lib/meson.build
@@ -66,6 +66,14 @@ libraries = [
         'node',
 ]
 
+if is_ms_compiler
+    libraries = [
+            'log',
+            'kvargs',
+            'telemetry',
+    ]
+endif
+
 optional_libs = [
         'bitratestats',
         'cfgfile',
diff --git a/usertools/meson.build b/usertools/meson.build
index 0efa4a8..740b483 100644
--- a/usertools/meson.build
+++ b/usertools/meson.build
@@ -1,6 +1,10 @@
 # SPDX-License-Identifier: BSD-3-Clause
 # Copyright(c) 2017 Intel Corporation
 
+if is_ms_compiler
+    subdir_done()
+endif
+
 install_data([
             'dpdk-devbind.py',
             'dpdk-pmdinfo.py',
-- 
1.8.3.1


^ permalink raw reply	[flat|nested] 44+ messages in thread

* [PATCH v4 4/4] build: enable MSVC specific compiler options
  2023-08-11 18:24 ` [PATCH v4 0/4] enable use of the MSVC compiler Tyler Retzlaff
                     ` (2 preceding siblings ...)
  2023-08-11 18:24   ` [PATCH v4 3/4] build: limit what is built when using MSVC compiler Tyler Retzlaff
@ 2023-08-11 18:24   ` Tyler Retzlaff
  2023-08-14  8:30     ` Bruce Richardson
  2023-08-15 13:21     ` David Marchand
  3 siblings, 2 replies; 44+ messages in thread
From: Tyler Retzlaff @ 2023-08-11 18:24 UTC (permalink / raw)
  To: dev
  Cc: Bruce Richardson, Konstantin Ananyev, david.marchand, thomas,
	Tyler Retzlaff

* Enable optional use of C11 atomics support.
* Enable use of C23 typeof operator.
* Explicitly force intrinsics when building with MSVC.
* Disable MSVC C runtime checks.

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

diff --git a/config/meson.build b/config/meson.build
index 821a1c3..839057a 100644
--- a/config/meson.build
+++ b/config/meson.build
@@ -27,6 +27,14 @@ dpdk_conf.set('RTE_EXEC_ENV_' + exec_env.to_upper(), 1)
 is_ms_compiler = is_windows and (cc.get_id() == 'msvc')
 is_ms_linker = is_windows and (cc.get_id() == 'clang' or is_ms_compiler)
 
+# MS compiler (except x86) does not support inline assembly
+if is_ms_compiler
+    dpdk_conf.set('_CRT_SECURE_NO_WARNINGS', 1)
+    dpdk_conf.set('RTE_FORCE_INTRINSICS', 1)
+    add_project_arguments('/experimental:c11atomics', language: 'c')
+    add_project_arguments('/d1experimental:typeof', language: 'c')
+endif
+
 # set the major version, which might be used by drivers and libraries
 # depending on the configuration options
 pver = meson.project_version().split('.')
-- 
1.8.3.1


^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: [PATCH v4 3/4] build: limit what is built when using MSVC compiler
  2023-08-11 18:24   ` [PATCH v4 3/4] build: limit what is built when using MSVC compiler Tyler Retzlaff
@ 2023-08-11 18:26     ` Tyler Retzlaff
  0 siblings, 0 replies; 44+ messages in thread
From: Tyler Retzlaff @ 2023-08-11 18:26 UTC (permalink / raw)
  To: dev; +Cc: Bruce Richardson, Konstantin Ananyev, david.marchand, thomas

On Fri, Aug 11, 2023 at 11:24:46AM -0700, Tyler Retzlaff wrote:
> Build only kvargs and telemetry when is_ms_compiler.
> 
> Signed-off-by: Tyler Retzlaff <roretzla@linux.microsoft.com>
> Acked-by: Bruce Richardson <bruce.richardson@intel.com>
> ---
>  app/meson.build       | 6 ++++--
>  drivers/meson.build   | 4 ++++
>  lib/meson.build       | 8 ++++++++
>  usertools/meson.build | 4 ++++
>  4 files changed, 20 insertions(+), 2 deletions(-)
> 
> diff --git a/app/meson.build b/app/meson.build
> index 4fc1a83..23a9d2e 100644
> --- a/app/meson.build
> +++ b/app/meson.build
> @@ -1,6 +1,10 @@
>  # SPDX-License-Identifier: BSD-3-Clause
>  # Copyright(c) 2017-2019 Intel Corporation
>  
> +if is_ms_compiler
> +    subdir_done()
> +endif
> +
>  disable_apps = ',' + get_option('disable_apps')
>  disable_apps = run_command(list_dir_globs, disable_apps, check: true).stdout().split()
>  
> @@ -38,8 +42,6 @@ if get_option('default_library') == 'static' and not is_windows
>      default_ldflags += ['-Wl,--export-dynamic']
>  endif
>  
> -enabled_apps = [] # used to print summary at the end
> -

oops, i shouldn't have removed this since David's patch removes it
already. please ignore this removal when reviewing.


^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: [PATCH v4 1/4] build: unblock the use of the MSVC compiler
  2023-08-11 18:24   ` [PATCH v4 1/4] build: unblock the " Tyler Retzlaff
@ 2023-08-14  8:27     ` Bruce Richardson
  2023-08-14  9:07       ` Dmitry Kozlyuk
  0 siblings, 1 reply; 44+ messages in thread
From: Bruce Richardson @ 2023-08-14  8:27 UTC (permalink / raw)
  To: Tyler Retzlaff; +Cc: dev, Konstantin Ananyev, david.marchand, thomas

On Fri, Aug 11, 2023 at 11:24:44AM -0700, Tyler Retzlaff wrote:
> Detect when MSVC toolset is available and tweak toolchain arguments
> where the meson build system offers no abstraction.
> 
> Signed-off-by: Tyler Retzlaff <roretzla@linux.microsoft.com>
> Acked-by: Bruce Richardson <bruce.richardson@intel.com>
> ---
>  config/meson.build     | 23 +++++++++++++++--------
>  config/x86/meson.build | 10 ++++++----
>  lib/meson.build        | 13 ++++++++++---
>  3 files changed, 31 insertions(+), 15 deletions(-)
> 
> diff --git a/config/meson.build b/config/meson.build
> index d822371..b6c7d48 100644
> --- a/config/meson.build
> +++ b/config/meson.build
> @@ -16,7 +16,8 @@ endforeach
>  
>  # MS linker requires special treatment.
>  # TODO: use cc.get_linker_id() with Meson >= 0.54
> -is_ms_linker = is_windows and (cc.get_id() == 'clang')
> +is_ms_compiler = is_windows and (cc.get_id() == 'msvc')
> +is_ms_linker = is_windows and (cc.get_id() == 'clang' or is_ms_compiler)

Question out of interest, what other linker option do we have on windows?
When is the second part of this conditional false?

/Bruce

^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: [PATCH v4 4/4] build: enable MSVC specific compiler options
  2023-08-11 18:24   ` [PATCH v4 4/4] build: enable MSVC specific compiler options Tyler Retzlaff
@ 2023-08-14  8:30     ` Bruce Richardson
  2023-08-14 16:10       ` Tyler Retzlaff
  2023-08-15 13:21     ` David Marchand
  1 sibling, 1 reply; 44+ messages in thread
From: Bruce Richardson @ 2023-08-14  8:30 UTC (permalink / raw)
  To: Tyler Retzlaff; +Cc: dev, Konstantin Ananyev, david.marchand, thomas

On Fri, Aug 11, 2023 at 11:24:47AM -0700, Tyler Retzlaff wrote:
> * Enable optional use of C11 atomics support.
> * Enable use of C23 typeof operator.
> * Explicitly force intrinsics when building with MSVC.
> * Disable MSVC C runtime checks.
> 
> Signed-off-by: Tyler Retzlaff <roretzla@linux.microsoft.com>

Acked-by: Bruce Richardson <bruce.richardson@intel.com>

If there is going to be a lot of this type of special handling for MSVC, we
could look to add a separate config/msvc (and config/gcc-like) directory
with separate meson.build files for the different toolchains. Might help
centralize all such definitions in one place rather than having
conditionals everywhere.

/Bruce

> ---
>  config/meson.build | 8 ++++++++
>  1 file changed, 8 insertions(+)
> 
> diff --git a/config/meson.build b/config/meson.build
> index 821a1c3..839057a 100644
> --- a/config/meson.build
> +++ b/config/meson.build
> @@ -27,6 +27,14 @@ dpdk_conf.set('RTE_EXEC_ENV_' + exec_env.to_upper(), 1)
>  is_ms_compiler = is_windows and (cc.get_id() == 'msvc')
>  is_ms_linker = is_windows and (cc.get_id() == 'clang' or is_ms_compiler)
>  
> +# MS compiler (except x86) does not support inline assembly
> +if is_ms_compiler
> +    dpdk_conf.set('_CRT_SECURE_NO_WARNINGS', 1)
> +    dpdk_conf.set('RTE_FORCE_INTRINSICS', 1)
> +    add_project_arguments('/experimental:c11atomics', language: 'c')
> +    add_project_arguments('/d1experimental:typeof', language: 'c')
> +endif
> +
>  # set the major version, which might be used by drivers and libraries
>  # depending on the configuration options
>  pver = meson.project_version().split('.')
> -- 
> 1.8.3.1
> 

^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: [PATCH v4 1/4] build: unblock the use of the MSVC compiler
  2023-08-14  8:27     ` Bruce Richardson
@ 2023-08-14  9:07       ` Dmitry Kozlyuk
  2023-08-14  9:12         ` Bruce Richardson
  0 siblings, 1 reply; 44+ messages in thread
From: Dmitry Kozlyuk @ 2023-08-14  9:07 UTC (permalink / raw)
  To: Bruce Richardson
  Cc: Tyler Retzlaff, dev, Konstantin Ananyev, david.marchand, thomas

2023-08-14 09:27 (UTC+0100), Bruce Richardson:
> On Fri, Aug 11, 2023 at 11:24:44AM -0700, Tyler Retzlaff wrote:
> > Detect when MSVC toolset is available and tweak toolchain arguments
> > where the meson build system offers no abstraction.
> > 
> > Signed-off-by: Tyler Retzlaff <roretzla@linux.microsoft.com>
> > Acked-by: Bruce Richardson <bruce.richardson@intel.com>
> > ---
> >  config/meson.build     | 23 +++++++++++++++--------
> >  config/x86/meson.build | 10 ++++++----
> >  lib/meson.build        | 13 ++++++++++---
> >  3 files changed, 31 insertions(+), 15 deletions(-)
> > 
> > diff --git a/config/meson.build b/config/meson.build
> > index d822371..b6c7d48 100644
> > --- a/config/meson.build
> > +++ b/config/meson.build
> > @@ -16,7 +16,8 @@ endforeach
> >  
> >  # MS linker requires special treatment.
> >  # TODO: use cc.get_linker_id() with Meson >= 0.54
> > -is_ms_linker = is_windows and (cc.get_id() == 'clang')
> > +is_ms_compiler = is_windows and (cc.get_id() == 'msvc')
> > +is_ms_linker = is_windows and (cc.get_id() == 'clang' or is_ms_compiler)  
> 
> Question out of interest, what other linker option do we have on windows?
> When is the second part of this conditional false?

MinGW: GCC    + GNU ld (the second conditional is false)
Clang: clang  + link.exe
MSVC:  cl.exe + link.exe

^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: [PATCH v4 1/4] build: unblock the use of the MSVC compiler
  2023-08-14  9:07       ` Dmitry Kozlyuk
@ 2023-08-14  9:12         ` Bruce Richardson
  0 siblings, 0 replies; 44+ messages in thread
From: Bruce Richardson @ 2023-08-14  9:12 UTC (permalink / raw)
  To: Dmitry Kozlyuk
  Cc: Tyler Retzlaff, dev, Konstantin Ananyev, david.marchand, thomas

On Mon, Aug 14, 2023 at 12:07:34PM +0300, Dmitry Kozlyuk wrote:
> 2023-08-14 09:27 (UTC+0100), Bruce Richardson:
> > On Fri, Aug 11, 2023 at 11:24:44AM -0700, Tyler Retzlaff wrote:
> > > Detect when MSVC toolset is available and tweak toolchain arguments
> > > where the meson build system offers no abstraction.
> > > 
> > > Signed-off-by: Tyler Retzlaff <roretzla@linux.microsoft.com>
> > > Acked-by: Bruce Richardson <bruce.richardson@intel.com>
> > > ---
> > >  config/meson.build     | 23 +++++++++++++++--------
> > >  config/x86/meson.build | 10 ++++++----
> > >  lib/meson.build        | 13 ++++++++++---
> > >  3 files changed, 31 insertions(+), 15 deletions(-)
> > > 
> > > diff --git a/config/meson.build b/config/meson.build
> > > index d822371..b6c7d48 100644
> > > --- a/config/meson.build
> > > +++ b/config/meson.build
> > > @@ -16,7 +16,8 @@ endforeach
> > >  
> > >  # MS linker requires special treatment.
> > >  # TODO: use cc.get_linker_id() with Meson >= 0.54
> > > -is_ms_linker = is_windows and (cc.get_id() == 'clang')
> > > +is_ms_compiler = is_windows and (cc.get_id() == 'msvc')
> > > +is_ms_linker = is_windows and (cc.get_id() == 'clang' or is_ms_compiler)  
> > 
> > Question out of interest, what other linker option do we have on windows?
> > When is the second part of this conditional false?
> 
> MinGW: GCC    + GNU ld (the second conditional is false)
> Clang: clang  + link.exe
> MSVC:  cl.exe + link.exe

Thanks. I'd forgottena bout mingw!

^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: [PATCH v4 4/4] build: enable MSVC specific compiler options
  2023-08-14  8:30     ` Bruce Richardson
@ 2023-08-14 16:10       ` Tyler Retzlaff
  2023-08-14 16:46         ` Bruce Richardson
  0 siblings, 1 reply; 44+ messages in thread
From: Tyler Retzlaff @ 2023-08-14 16:10 UTC (permalink / raw)
  To: Bruce Richardson; +Cc: dev, Konstantin Ananyev, david.marchand, thomas

On Mon, Aug 14, 2023 at 09:30:20AM +0100, Bruce Richardson wrote:
> On Fri, Aug 11, 2023 at 11:24:47AM -0700, Tyler Retzlaff wrote:
> > * Enable optional use of C11 atomics support.
> > * Enable use of C23 typeof operator.
> > * Explicitly force intrinsics when building with MSVC.
> > * Disable MSVC C runtime checks.
> > 
> > Signed-off-by: Tyler Retzlaff <roretzla@linux.microsoft.com>
> 
> Acked-by: Bruce Richardson <bruce.richardson@intel.com>
> 
> If there is going to be a lot of this type of special handling for MSVC, we
> could look to add a separate config/msvc (and config/gcc-like) directory
> with separate meson.build files for the different toolchains. Might help
> centralize all such definitions in one place rather than having
> conditionals everywhere.

i think that would probably be a good idea. it would untangle the
toolchain detail from the flow of the build files.

i don't propose introducing it in this series but when this is merged
i would like to reach out and get your thoughts on how to properly set
up a config/toolchain-xxx. in addition to the compiler flags and
definitions below it would be good to suppress (for now) warnings until
i have an opportunity to evaluate and address the code raising them.


^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: [PATCH v4 4/4] build: enable MSVC specific compiler options
  2023-08-14 16:10       ` Tyler Retzlaff
@ 2023-08-14 16:46         ` Bruce Richardson
  2023-08-14 18:28           ` Morten Brørup
  0 siblings, 1 reply; 44+ messages in thread
From: Bruce Richardson @ 2023-08-14 16:46 UTC (permalink / raw)
  To: Tyler Retzlaff; +Cc: dev, Konstantin Ananyev, david.marchand, thomas

On Mon, Aug 14, 2023 at 09:10:53AM -0700, Tyler Retzlaff wrote:
> On Mon, Aug 14, 2023 at 09:30:20AM +0100, Bruce Richardson wrote:
> > On Fri, Aug 11, 2023 at 11:24:47AM -0700, Tyler Retzlaff wrote:
> > > * Enable optional use of C11 atomics support.  * Enable use of C23
> > > typeof operator.  * Explicitly force intrinsics when building with
> > > MSVC.  * Disable MSVC C runtime checks.
> > > 
> > > Signed-off-by: Tyler Retzlaff <roretzla@linux.microsoft.com>
> > 
> > Acked-by: Bruce Richardson <bruce.richardson@intel.com>
> > 
> > If there is going to be a lot of this type of special handling for
> > MSVC, we could look to add a separate config/msvc (and config/gcc-like)
> > directory with separate meson.build files for the different toolchains.
> > Might help centralize all such definitions in one place rather than
> > having conditionals everywhere.
> 
> i think that would probably be a good idea. it would untangle the
> toolchain detail from the flow of the build files.
> 
> i don't propose introducing it in this series but when this is merged i
> would like to reach out and get your thoughts on how to properly set up a
> config/toolchain-xxx. in addition to the compiler flags and definitions
> below it would be good to suppress (for now) warnings until i have an
> opportunity to evaluate and address the code raising them.
> 
Agree on not requiring it for this set. I'm not exactly sure how to split
up the toolchain files, especially given that gcc and clang (and other
llvm-based compilers like icx) are so very, very similar in what we have to
do for them. It would be very wasteful to have individual toolchain files
for each one, duplicating lots of settings. That's why my initial
suggestion was for msvc and "gcc-like" compilers. Any suggestions for a
better name for the latter, welcome! :-)

^ permalink raw reply	[flat|nested] 44+ messages in thread

* RE: [PATCH v4 4/4] build: enable MSVC specific compiler options
  2023-08-14 16:46         ` Bruce Richardson
@ 2023-08-14 18:28           ` Morten Brørup
  0 siblings, 0 replies; 44+ messages in thread
From: Morten Brørup @ 2023-08-14 18:28 UTC (permalink / raw)
  To: Bruce Richardson, Tyler Retzlaff
  Cc: dev, Konstantin Ananyev, david.marchand, thomas

> From: Bruce Richardson [mailto:bruce.richardson@intel.com]
> Sent: Monday, 14 August 2023 18.47
> 
> On Mon, Aug 14, 2023 at 09:10:53AM -0700, Tyler Retzlaff wrote:
> > On Mon, Aug 14, 2023 at 09:30:20AM +0100, Bruce Richardson wrote:
> > > On Fri, Aug 11, 2023 at 11:24:47AM -0700, Tyler Retzlaff wrote:
> > > > * Enable optional use of C11 atomics support.  * Enable use of C23
> > > > typeof operator.  * Explicitly force intrinsics when building with
> > > > MSVC.  * Disable MSVC C runtime checks.
> > > >
> > > > Signed-off-by: Tyler Retzlaff <roretzla@linux.microsoft.com>
> > >
> > > Acked-by: Bruce Richardson <bruce.richardson@intel.com>
> > >
> > > If there is going to be a lot of this type of special handling for
> > > MSVC, we could look to add a separate config/msvc (and config/gcc-
> like)
> > > directory with separate meson.build files for the different
> toolchains.
> > > Might help centralize all such definitions in one place rather than
> > > having conditionals everywhere.

Please think twice before splitting into per-toolchain files! You must consider the ratio of differences vs. similarities.

<rant on>
For reference, consider the EAL, which has per-arch subdirectories basically containing the same files, whereof many contain nearly similar content for the different architectures.
And much of it is not even arch-specific at all, but plain C.
There is way too much copy-paste in this design pattern.
Although a "default fallback" implementation could alleviate some of this, minor arch-specific deviations in a function would still require a full copy-paste of the function's remaining code.
In my opinion, a lot of this would be better having in unified files with #ifdefs where required by one or more architectures. It would also allow arch A and arch B to share one implementation, while arch C and arch D share another, and arch E has its own.
<rant off>

The EAL might be a really bad comparison here, but it's a good example of a differences/similarities ratio moving in an unfavorable direction for the design pattern.
I also hope it serves as an example of how not to do it.

That being said, I admit that it could probably be done right. In this case, it's a mostly matter of taste if you prefer keeping the differences together in one file, or having the differences spread out at the locations where they have their actual effect.

> >
> > i think that would probably be a good idea. it would untangle the
> > toolchain detail from the flow of the build files.
> >
> > i don't propose introducing it in this series but when this is merged
> i
> > would like to reach out and get your thoughts on how to properly set
> up a
> > config/toolchain-xxx. in addition to the compiler flags and
> definitions
> > below it would be good to suppress (for now) warnings until i have an
> > opportunity to evaluate and address the code raising them.
> >
> Agree on not requiring it for this set. I'm not exactly sure how to
> split
> up the toolchain files, especially given that gcc and clang (and other
> llvm-based compilers like icx) are so very, very similar in what we have
> to
> do for them. It would be very wasteful to have individual toolchain
> files
> for each one, duplicating lots of settings. That's why my initial
> suggestion was for msvc and "gcc-like" compilers. Any suggestions for a
> better name for the latter, welcome! :-)

^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: [PATCH v4 4/4] build: enable MSVC specific compiler options
  2023-08-11 18:24   ` [PATCH v4 4/4] build: enable MSVC specific compiler options Tyler Retzlaff
  2023-08-14  8:30     ` Bruce Richardson
@ 2023-08-15 13:21     ` David Marchand
  1 sibling, 0 replies; 44+ messages in thread
From: David Marchand @ 2023-08-15 13:21 UTC (permalink / raw)
  To: Tyler Retzlaff; +Cc: dev, Bruce Richardson, Konstantin Ananyev, thomas

Hello Tyler,

On Fri, Aug 11, 2023 at 8:24 PM Tyler Retzlaff
<roretzla@linux.microsoft.com> wrote:
>
> * Enable optional use of C11 atomics support.
> * Enable use of C23 typeof operator.
> * Explicitly force intrinsics when building with MSVC.
> * Disable MSVC C runtime checks.
>
> Signed-off-by: Tyler Retzlaff <roretzla@linux.microsoft.com>
> ---
>  config/meson.build | 8 ++++++++
>  1 file changed, 8 insertions(+)
>
> diff --git a/config/meson.build b/config/meson.build
> index 821a1c3..839057a 100644
> --- a/config/meson.build
> +++ b/config/meson.build
> @@ -27,6 +27,14 @@ dpdk_conf.set('RTE_EXEC_ENV_' + exec_env.to_upper(), 1)
>  is_ms_compiler = is_windows and (cc.get_id() == 'msvc')
>  is_ms_linker = is_windows and (cc.get_id() == 'clang' or is_ms_compiler)
>
> +# MS compiler (except x86) does not support inline assembly

One last (hopefully) small question, what does this comment apply to?
Forced use of intrinsics?

> +if is_ms_compiler
> +    dpdk_conf.set('_CRT_SECURE_NO_WARNINGS', 1)
> +    dpdk_conf.set('RTE_FORCE_INTRINSICS', 1)
> +    add_project_arguments('/experimental:c11atomics', language: 'c')
> +    add_project_arguments('/d1experimental:typeof', language: 'c')
> +endif
> +
>  # set the major version, which might be used by drivers and libraries
>  # depending on the configuration options
>  pver = meson.project_version().split('.')
> --
> 1.8.3.1
>


-- 
David Marchand


^ permalink raw reply	[flat|nested] 44+ messages in thread

* [PATCH v5 0/4] enable use of the MSVC compiler
  2023-01-25 19:25 [PATCH 0/3] unblock the use of the MSVC compiler Tyler Retzlaff
                   ` (5 preceding siblings ...)
  2023-08-11 18:24 ` [PATCH v4 0/4] enable use of the MSVC compiler Tyler Retzlaff
@ 2023-08-16 21:56 ` Tyler Retzlaff
  2023-08-16 21:56   ` [PATCH v5 1/4] build: unblock the " Tyler Retzlaff
                     ` (4 more replies)
  6 siblings, 5 replies; 44+ messages in thread
From: Tyler Retzlaff @ 2023-08-16 21:56 UTC (permalink / raw)
  To: dev
  Cc: Bruce Richardson, Konstantin Ananyev, david.marchand, thomas,
	Tyler Retzlaff

Introduce minimum changes to the build system to allow use of the MSVC
compiler.

This change is intended to enable a phased approach to allowing DPDK to
built with MSVC. Building with MSVC removes barriers to enterprise
customers use of DPDK who have constraints around security policy,
compliance and functional requirements.

v5:
  * Clean up comments in config/meson.build for project arguments and
    dpdk_conf defines when is_ms_compiler
  * Restore incorrectly removed enabled_apps = [] in v4

v4:
  * Remove conditional if cc.get_id() != 'msvc' for assignment of
    objdump and binutils_avx512_check in anticipation of merge of
    patch from David Marchand
    https://patchwork.dpdk.org/project/dpdk/patch/20230811131024.2285366-1-david.marchand@redhat.com
    Note:
      I'm aware that none of the shell scripts here are usable on the
      windows build, it's a gap we hope to fill in the future for now
      we hap hazardly rely on the linux builds.
  * Remove enabled_apps = [] apps when skipping apps/meson.build for
    is_ms_compiler in anticipation of merge of patch from David Marchand
    https://patchwork.dpdk.org/project/dpdk/patch/20230811132805.2434448-1-david.marchand@redhat.com
  * Rebase series and include 'log' library as it is now required by
    kvargs and telemetry libs
  * Move 2 comments into block scope ehre they apply
    Note:
      There are no requirements specifically for msvc compiler
      beyond those that would cause build to fail when the
      currently experimental options are used. when i know the
      final version of the compiler needed it will be documented
      in the windows quick start guide.

v3:
  * enable compilation with C11 optional atomics
  * enable compilation with C23 typeof operator
  * disable microsoft secure crt checks (dpdk code fails)
  * force use of intrinsics

v2:
  * moved checks to skip drivers, apps, usertools directories
    in to <dir>/meson.build file and removed conditional
    check from root meson.build (patch 3/3)

Tyler Retzlaff (4):
  build: unblock the use of the MSVC compiler
  build: determine execution environment at config time
  build: limit what is built when using MSVC compiler
  build: enable MSVC specific compiler options

 app/meson.build        |  4 ++++
 config/meson.build     | 47 +++++++++++++++++++++++++++++++++++++++--------
 config/x86/meson.build | 10 ++++++----
 drivers/meson.build    |  4 ++++
 lib/eal/meson.build    |  8 --------
 lib/meson.build        | 21 ++++++++++++++++++---
 usertools/meson.build  |  4 ++++
 7 files changed, 75 insertions(+), 23 deletions(-)

-- 
1.8.3.1


^ permalink raw reply	[flat|nested] 44+ messages in thread

* [PATCH v5 1/4] build: unblock the use of the MSVC compiler
  2023-08-16 21:56 ` [PATCH v5 0/4] enable use of the MSVC compiler Tyler Retzlaff
@ 2023-08-16 21:56   ` Tyler Retzlaff
  2023-08-16 21:56   ` [PATCH v5 2/4] build: determine execution environment at config time Tyler Retzlaff
                     ` (3 subsequent siblings)
  4 siblings, 0 replies; 44+ messages in thread
From: Tyler Retzlaff @ 2023-08-16 21:56 UTC (permalink / raw)
  To: dev
  Cc: Bruce Richardson, Konstantin Ananyev, david.marchand, thomas,
	Tyler Retzlaff

Detect when MSVC toolset is available and tweak toolchain arguments
where the meson build system offers no abstraction.

Signed-off-by: Tyler Retzlaff <roretzla@linux.microsoft.com>
Acked-by: Bruce Richardson <bruce.richardson@intel.com>
---
 config/meson.build     | 23 +++++++++++++++--------
 config/x86/meson.build | 10 ++++++----
 lib/meson.build        | 13 ++++++++++---
 3 files changed, 31 insertions(+), 15 deletions(-)

diff --git a/config/meson.build b/config/meson.build
index d822371..b6c7d48 100644
--- a/config/meson.build
+++ b/config/meson.build
@@ -16,7 +16,8 @@ endforeach
 
 # MS linker requires special treatment.
 # TODO: use cc.get_linker_id() with Meson >= 0.54
-is_ms_linker = is_windows and (cc.get_id() == 'clang')
+is_ms_compiler = is_windows and (cc.get_id() == 'msvc')
+is_ms_linker = is_windows and (cc.get_id() == 'clang' or is_ms_compiler)
 
 # set the major version, which might be used by drivers and libraries
 # depending on the configuration options
@@ -129,12 +130,14 @@ endif
 dpdk_conf.set('RTE_MACHINE', cpu_instruction_set)
 machine_args = []
 
-# ppc64 does not support -march= at all, use -mcpu and -mtune for that
-if host_machine.cpu_family().startswith('ppc')
-    machine_args += '-mcpu=' + cpu_instruction_set
-    machine_args += '-mtune=' + cpu_instruction_set
-else
-    machine_args += '-march=' + cpu_instruction_set
+if not is_ms_compiler
+    # ppc64 does not support -march= at all, use -mcpu and -mtune for that
+    if host_machine.cpu_family().startswith('ppc')
+        machine_args += '-mcpu=' + cpu_instruction_set
+        machine_args += '-mtune=' + cpu_instruction_set
+    else
+        machine_args += '-march=' + cpu_instruction_set
+    endif
 endif
 
 toolchain = cc.get_id()
@@ -253,7 +256,11 @@ if cc.get_id() == 'clang' and dpdk_conf.get('RTE_ARCH_64') == false
 endif
 
 # add -include rte_config to cflags
-add_project_arguments('-include', 'rte_config.h', language: 'c')
+if is_ms_compiler
+    add_project_arguments('/FI', 'rte_config.h', language: 'c')
+else
+    add_project_arguments('-include', 'rte_config.h', language: 'c')
+endif
 
 # enable extra warnings and disable any unwanted warnings
 # -Wall is added by default at warning level 1, and -Wextra
diff --git a/config/x86/meson.build b/config/x86/meson.build
index 54345c4..38cc1e3 100644
--- a/config/x86/meson.build
+++ b/config/x86/meson.build
@@ -24,10 +24,12 @@ if cc.has_argument('-mavx512f')
     endif
 endif
 
-# we require SSE4.2 for DPDK
-if cc.get_define('__SSE4_2__', args: machine_args) == ''
-    message('SSE 4.2 not enabled by default, explicitly enabling')
-    machine_args += '-msse4'
+if not is_ms_compiler
+    # we require SSE4.2 for DPDK
+    if cc.get_define('__SSE4_2__', args: machine_args) == ''
+        message('SSE 4.2 not enabled by default, explicitly enabling')
+        machine_args += '-msse4'
+    endif
 endif
 
 base_flags = ['SSE', 'SSE2', 'SSE3','SSSE3', 'SSE4_1', 'SSE4_2']
diff --git a/lib/meson.build b/lib/meson.build
index 92cbd6b..7da3698 100644
--- a/lib/meson.build
+++ b/lib/meson.build
@@ -230,9 +230,16 @@ foreach l:libraries
                 output: '@0@_exports.def'.format(libname))
         lk_deps += [def_file]
 
-        lk_args = ['-Wl,/def:' + def_file.full_path()]
-        if meson.version().version_compare('<0.54.0')
-            lk_args += ['-Wl,/implib:lib\\librte_' + l + '.dll.a']
+        if is_ms_compiler
+            lk_args = ['/def:' + def_file.full_path()]
+            if meson.version().version_compare('<0.54.0')
+                lk_args += ['/implib:lib\\librte_' + l + '.dll.a']
+            endif
+        else
+            lk_args = ['-Wl,/def:' + def_file.full_path()]
+            if meson.version().version_compare('<0.54.0')
+                lk_args += ['-Wl,/implib:lib\\librte_' + l + '.dll.a']
+            endif
         endif
     else
         if is_windows
-- 
1.8.3.1


^ permalink raw reply	[flat|nested] 44+ messages in thread

* [PATCH v5 2/4] build: determine execution environment at config time
  2023-08-16 21:56 ` [PATCH v5 0/4] enable use of the MSVC compiler Tyler Retzlaff
  2023-08-16 21:56   ` [PATCH v5 1/4] build: unblock the " Tyler Retzlaff
@ 2023-08-16 21:56   ` Tyler Retzlaff
  2023-08-16 21:56   ` [PATCH v5 3/4] build: limit what is built when using MSVC compiler Tyler Retzlaff
                     ` (2 subsequent siblings)
  4 siblings, 0 replies; 44+ messages in thread
From: Tyler Retzlaff @ 2023-08-16 21:56 UTC (permalink / raw)
  To: dev
  Cc: Bruce Richardson, Konstantin Ananyev, david.marchand, thomas,
	Tyler Retzlaff

Move execution environment determination and definitions to config. The
RTE_EXEC_ENV macros are actually used by libraries built before EAL.

Currently it does not matter that this is determined in lib/eal since
the definitions are consumed before anything is built including libs
built before lib/eal. By moving this logic to config it allows kvargs
and telemetry to be built without EAL.

No functional change intended.

Signed-off-by: Tyler Retzlaff <roretzla@linux.microsoft.com>
Acked-by: Bruce Richardson <bruce.richardson@intel.com>
---
 config/meson.build  | 8 ++++++++
 lib/eal/meson.build | 8 --------
 2 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/config/meson.build b/config/meson.build
index b6c7d48..821a1c3 100644
--- a/config/meson.build
+++ b/config/meson.build
@@ -14,6 +14,14 @@ foreach env:supported_exec_envs
     set_variable('is_' + env, exec_env == env)
 endforeach
 
+exec_envs = {'freebsd': 0, 'linux': 1, 'windows': 2}
+foreach env, id:exec_envs
+    dpdk_conf.set('RTE_ENV_' + env.to_upper(), id)
+    dpdk_conf.set10('RTE_EXEC_ENV_IS_' + env.to_upper(), (exec_env == env))
+endforeach
+dpdk_conf.set('RTE_EXEC_ENV', exec_envs[exec_env])
+dpdk_conf.set('RTE_EXEC_ENV_' + exec_env.to_upper(), 1)
+
 # MS linker requires special treatment.
 # TODO: use cc.get_linker_id() with Meson >= 0.54
 is_ms_compiler = is_windows and (cc.get_id() == 'msvc')
diff --git a/lib/eal/meson.build b/lib/eal/meson.build
index 0fb974c..9942104 100644
--- a/lib/eal/meson.build
+++ b/lib/eal/meson.build
@@ -10,14 +10,6 @@ if not is_windows
     subdir('unix')
 endif
 
-exec_envs = {'freebsd': 0, 'linux': 1, 'windows': 2}
-foreach env, id:exec_envs
-    dpdk_conf.set('RTE_ENV_' + env.to_upper(), id)
-    dpdk_conf.set10('RTE_EXEC_ENV_IS_' + env.to_upper(), (exec_env == env))
-endforeach
-dpdk_conf.set('RTE_EXEC_ENV', exec_envs[exec_env])
-
-dpdk_conf.set('RTE_EXEC_ENV_' + exec_env.to_upper(), 1)
 subdir(exec_env)
 
 subdir(arch_subdir)
-- 
1.8.3.1


^ permalink raw reply	[flat|nested] 44+ messages in thread

* [PATCH v5 3/4] build: limit what is built when using MSVC compiler
  2023-08-16 21:56 ` [PATCH v5 0/4] enable use of the MSVC compiler Tyler Retzlaff
  2023-08-16 21:56   ` [PATCH v5 1/4] build: unblock the " Tyler Retzlaff
  2023-08-16 21:56   ` [PATCH v5 2/4] build: determine execution environment at config time Tyler Retzlaff
@ 2023-08-16 21:56   ` Tyler Retzlaff
  2023-08-16 21:56   ` [PATCH v5 4/4] build: enable MSVC specific compiler options Tyler Retzlaff
  2023-08-25  8:43   ` [PATCH v5 0/4] enable use of the MSVC compiler David Marchand
  4 siblings, 0 replies; 44+ messages in thread
From: Tyler Retzlaff @ 2023-08-16 21:56 UTC (permalink / raw)
  To: dev
  Cc: Bruce Richardson, Konstantin Ananyev, david.marchand, thomas,
	Tyler Retzlaff

Build only kvargs and telemetry when is_ms_compiler.

Signed-off-by: Tyler Retzlaff <roretzla@linux.microsoft.com>
Acked-by: Bruce Richardson <bruce.richardson@intel.com>
---
 app/meson.build       | 4 ++++
 drivers/meson.build   | 4 ++++
 lib/meson.build       | 8 ++++++++
 usertools/meson.build | 4 ++++
 4 files changed, 20 insertions(+)

diff --git a/app/meson.build b/app/meson.build
index 4fc1a83..ccf6f78 100644
--- a/app/meson.build
+++ b/app/meson.build
@@ -1,6 +1,10 @@
 # SPDX-License-Identifier: BSD-3-Clause
 # Copyright(c) 2017-2019 Intel Corporation
 
+if is_ms_compiler
+    subdir_done()
+endif
+
 disable_apps = ',' + get_option('disable_apps')
 disable_apps = run_command(list_dir_globs, disable_apps, check: true).stdout().split()
 
diff --git a/drivers/meson.build b/drivers/meson.build
index c909070..417b64b 100644
--- a/drivers/meson.build
+++ b/drivers/meson.build
@@ -1,6 +1,10 @@
 # SPDX-License-Identifier: BSD-3-Clause
 # Copyright(c) 2017-2019 Intel Corporation
 
+if is_ms_compiler
+    subdir_done()
+endif
+
 fs = import('fs')
 
 # Defines the order of dependencies evaluation
diff --git a/lib/meson.build b/lib/meson.build
index 7da3698..77c3e74 100644
--- a/lib/meson.build
+++ b/lib/meson.build
@@ -66,6 +66,14 @@ libraries = [
         'node',
 ]
 
+if is_ms_compiler
+    libraries = [
+            'log',
+            'kvargs',
+            'telemetry',
+    ]
+endif
+
 optional_libs = [
         'bitratestats',
         'cfgfile',
diff --git a/usertools/meson.build b/usertools/meson.build
index 0efa4a8..740b483 100644
--- a/usertools/meson.build
+++ b/usertools/meson.build
@@ -1,6 +1,10 @@
 # SPDX-License-Identifier: BSD-3-Clause
 # Copyright(c) 2017 Intel Corporation
 
+if is_ms_compiler
+    subdir_done()
+endif
+
 install_data([
             'dpdk-devbind.py',
             'dpdk-pmdinfo.py',
-- 
1.8.3.1


^ permalink raw reply	[flat|nested] 44+ messages in thread

* [PATCH v5 4/4] build: enable MSVC specific compiler options
  2023-08-16 21:56 ` [PATCH v5 0/4] enable use of the MSVC compiler Tyler Retzlaff
                     ` (2 preceding siblings ...)
  2023-08-16 21:56   ` [PATCH v5 3/4] build: limit what is built when using MSVC compiler Tyler Retzlaff
@ 2023-08-16 21:56   ` Tyler Retzlaff
  2023-08-17  8:33     ` Bruce Richardson
  2023-08-25  8:43   ` [PATCH v5 0/4] enable use of the MSVC compiler David Marchand
  4 siblings, 1 reply; 44+ messages in thread
From: Tyler Retzlaff @ 2023-08-16 21:56 UTC (permalink / raw)
  To: dev
  Cc: Bruce Richardson, Konstantin Ananyev, david.marchand, thomas,
	Tyler Retzlaff

* Enable optional use of C11 atomics support.
* Enable use of C23 typeof operator.
* Explicitly force intrinsics when building with MSVC.
* Disable MSVC C runtime checks.

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

diff --git a/config/meson.build b/config/meson.build
index 821a1c3..7a04347 100644
--- a/config/meson.build
+++ b/config/meson.build
@@ -27,6 +27,22 @@ dpdk_conf.set('RTE_EXEC_ENV_' + exec_env.to_upper(), 1)
 is_ms_compiler = is_windows and (cc.get_id() == 'msvc')
 is_ms_linker = is_windows and (cc.get_id() == 'clang' or is_ms_compiler)
 
+if is_ms_compiler
+    # force the use of intrinsics the MSVC compiler (except x86)
+    # does not support inline assembly
+    dpdk_conf.set('RTE_FORCE_INTRINSICS', 1)
+
+    # suppress warnings raised for using standard library functions
+    # the MSVC compiler regards as unsafe but are used by DPDK
+    dpdk_conf.set('_CRT_SECURE_NO_WARNINGS', 1)
+
+    # enable non-locking atomic operations
+    add_project_arguments('/experimental:c11atomics', language: 'c')
+
+    # enable typeof operator
+    add_project_arguments('/d1experimental:typeof', language: 'c')
+endif
+
 # set the major version, which might be used by drivers and libraries
 # depending on the configuration options
 pver = meson.project_version().split('.')
-- 
1.8.3.1


^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: [PATCH v5 4/4] build: enable MSVC specific compiler options
  2023-08-16 21:56   ` [PATCH v5 4/4] build: enable MSVC specific compiler options Tyler Retzlaff
@ 2023-08-17  8:33     ` Bruce Richardson
  0 siblings, 0 replies; 44+ messages in thread
From: Bruce Richardson @ 2023-08-17  8:33 UTC (permalink / raw)
  To: Tyler Retzlaff; +Cc: dev, Konstantin Ananyev, david.marchand, thomas

On Wed, Aug 16, 2023 at 02:56:16PM -0700, Tyler Retzlaff wrote:
> * Enable optional use of C11 atomics support.
> * Enable use of C23 typeof operator.
> * Explicitly force intrinsics when building with MSVC.
> * Disable MSVC C runtime checks.
> 
> Signed-off-by: Tyler Retzlaff <roretzla@linux.microsoft.com>
> ---
Acked-by: Bruce Richardson <bruce.richardson@intel.com>

^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: [PATCH v5 0/4] enable use of the MSVC compiler
  2023-08-16 21:56 ` [PATCH v5 0/4] enable use of the MSVC compiler Tyler Retzlaff
                     ` (3 preceding siblings ...)
  2023-08-16 21:56   ` [PATCH v5 4/4] build: enable MSVC specific compiler options Tyler Retzlaff
@ 2023-08-25  8:43   ` David Marchand
  4 siblings, 0 replies; 44+ messages in thread
From: David Marchand @ 2023-08-25  8:43 UTC (permalink / raw)
  To: Tyler Retzlaff; +Cc: dev, Bruce Richardson, Konstantin Ananyev, thomas

On Wed, Aug 16, 2023 at 11:56 PM Tyler Retzlaff
<roretzla@linux.microsoft.com> wrote:
>
> Introduce minimum changes to the build system to allow use of the MSVC
> compiler.
>
> This change is intended to enable a phased approach to allowing DPDK to
> built with MSVC. Building with MSVC removes barriers to enterprise
> customers use of DPDK who have constraints around security policy,
> compliance and functional requirements.

Series applied, thanks Tyler.
Here we go with MSVC!


-- 
David Marchand


^ permalink raw reply	[flat|nested] 44+ messages in thread

end of thread, other threads:[~2023-08-25  8:43 UTC | newest]

Thread overview: 44+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-01-25 19:25 [PATCH 0/3] unblock the use of the MSVC compiler Tyler Retzlaff
2023-01-25 19:25 ` [PATCH 1/3] build: " Tyler Retzlaff
2023-01-26 10:07   ` Bruce Richardson
2023-01-25 19:25 ` [PATCH 2/3] build: determine execution environment at config time Tyler Retzlaff
2023-01-26 10:09   ` Bruce Richardson
2023-01-25 19:25 ` [PATCH 3/3] build: limit what is built when using MSVC compiler Tyler Retzlaff
2023-01-26 11:10   ` Bruce Richardson
2023-01-26 17:28     ` Tyler Retzlaff
2023-01-26 17:34       ` Bruce Richardson
2023-01-26 17:36         ` Tyler Retzlaff
2023-01-26 18:03 ` [PATCH v2 0/3] unblock the use of the " Tyler Retzlaff
2023-01-26 18:03   ` [PATCH v2 1/3] build: " Tyler Retzlaff
2023-01-26 18:03   ` [PATCH v2 2/3] build: determine execution environment at config time Tyler Retzlaff
2023-01-26 18:03   ` [PATCH v2 3/3] build: limit what is built when using MSVC compiler Tyler Retzlaff
2023-01-26 18:18     ` Bruce Richardson
2023-01-26 18:05   ` [PATCH v2 0/3] unblock the use of the " Tyler Retzlaff
2023-04-25 20:08 ` [PATCH v3 0/4] enable " Tyler Retzlaff
2023-04-25 20:08   ` [PATCH v3 1/4] build: unblock the " Tyler Retzlaff
2023-08-11 13:31     ` David Marchand
2023-04-25 20:08   ` [PATCH v3 2/4] build: determine execution environment at config time Tyler Retzlaff
2023-04-25 20:08   ` [PATCH v3 3/4] build: limit what is built when using MSVC compiler Tyler Retzlaff
2023-08-11 13:31     ` David Marchand
2023-04-25 20:08   ` [PATCH v3 4/4] build: enable MSVC specific compiler options Tyler Retzlaff
2023-08-11 18:24 ` [PATCH v4 0/4] enable use of the MSVC compiler Tyler Retzlaff
2023-08-11 18:24   ` [PATCH v4 1/4] build: unblock the " Tyler Retzlaff
2023-08-14  8:27     ` Bruce Richardson
2023-08-14  9:07       ` Dmitry Kozlyuk
2023-08-14  9:12         ` Bruce Richardson
2023-08-11 18:24   ` [PATCH v4 2/4] build: determine execution environment at config time Tyler Retzlaff
2023-08-11 18:24   ` [PATCH v4 3/4] build: limit what is built when using MSVC compiler Tyler Retzlaff
2023-08-11 18:26     ` Tyler Retzlaff
2023-08-11 18:24   ` [PATCH v4 4/4] build: enable MSVC specific compiler options Tyler Retzlaff
2023-08-14  8:30     ` Bruce Richardson
2023-08-14 16:10       ` Tyler Retzlaff
2023-08-14 16:46         ` Bruce Richardson
2023-08-14 18:28           ` Morten Brørup
2023-08-15 13:21     ` David Marchand
2023-08-16 21:56 ` [PATCH v5 0/4] enable use of the MSVC compiler Tyler Retzlaff
2023-08-16 21:56   ` [PATCH v5 1/4] build: unblock the " Tyler Retzlaff
2023-08-16 21:56   ` [PATCH v5 2/4] build: determine execution environment at config time Tyler Retzlaff
2023-08-16 21:56   ` [PATCH v5 3/4] build: limit what is built when using MSVC compiler Tyler Retzlaff
2023-08-16 21:56   ` [PATCH v5 4/4] build: enable MSVC specific compiler options Tyler Retzlaff
2023-08-17  8:33     ` Bruce Richardson
2023-08-25  8:43   ` [PATCH v5 0/4] enable use of the MSVC compiler David Marchand

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).