[RFC] build/pkg-config: remove machine arch flag

Message ID 20201211155111.145279-1-bruce.richardson@intel.com (mailing list archive)
State Changes Requested, archived
Delegated to: Thomas Monjalon
Headers
Series [RFC] build/pkg-config: remove machine arch flag |

Checks

Context Check Description
ci/checkpatch warning coding style issues
ci/Intel-compilation success Compilation OK

Commit Message

Bruce Richardson Dec. 11, 2020, 3:51 p.m. UTC
  Traditionally any apps built using DPDK had to support the same
instruction sets as supported when the DPDK SDK itself was built, since
that was "leaked" through to the end-app and DPDK headers via
RTE_MACHINE_CPUFLAG_* values. Therefore, when converting over to meson
for app build correctness the "-march=" flag was included in the
pkg-config cflags output.

However, since the DPDK-specific CPU flags are now obsolete, and we
instead check directly for compiler-defined flags, we should no longer
need to force the exact same architecture match in all cases. To
faciliate such flexibility, a new pkg_config_machine_args array - which
defaults to the existing machine_args array has been defined. The
individual architectures - x86, arm and ppc - can choose if and how to
override this value themselves.

For x86, since SSE4.2 is the minimum instruction-set level needed to run
DPDK, and since some header files assume that minimum level of
instruction set support, we override the "-march=" value with "-msse4"
for the pkg-config file. This allows end applications to set their own
"march" value while still ensuring valid DPDK compilation.

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

CC: Jerin Jacob <jerinj@marvell.com>
CC: Ruifeng Wang <ruifeng.wang@arm.com>
CC: Honnappa Nagarahalli <honnappa.nagarahalli@arm.com>
CC: David Christensen <drc@linux.vnet.ibm.com>
Feedback requested from ARM and PPC maintainers as to this change
and what flags, if any, need to be in the .pc file for DPDK on such
platforms. For example - is setting 'pkg_config_machine_args' to
'machine_args' by default necessary behaviour?

---
 buildtools/pkg-config/meson.build | 2 +-
 config/meson.build                | 1 +
 config/x86/meson.build            | 3 +++
 3 files changed, 5 insertions(+), 1 deletion(-)

--
2.27.0
  

Comments

David Christensen Dec. 16, 2020, 6:45 p.m. UTC | #1
On 12/11/20 7:51 AM, Bruce Richardson wrote:
> Traditionally any apps built using DPDK had to support the same
> instruction sets as supported when the DPDK SDK itself was built, since
> that was "leaked" through to the end-app and DPDK headers via
> RTE_MACHINE_CPUFLAG_* values. Therefore, when converting over to meson
> for app build correctness the "-march=" flag was included in the
> pkg-config cflags output.
> 
> However, since the DPDK-specific CPU flags are now obsolete, and we
> instead check directly for compiler-defined flags, we should no longer
> need to force the exact same architecture match in all cases. To
> faciliate such flexibility, a new pkg_config_machine_args array - which
> defaults to the existing machine_args array has been defined. The
> individual architectures - x86, arm and ppc - can choose if and how to
> override this value themselves.
> 
> For x86, since SSE4.2 is the minimum instruction-set level needed to run
> DPDK, and since some header files assume that minimum level of
> instruction set support, we override the "-march=" value with "-msse4"
> for the pkg-config file. This allows end applications to set their own
> "march" value while still ensuring valid DPDK compilation.
> 
> Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
> ---
> 
> CC: Jerin Jacob <jerinj@marvell.com>
> CC: Ruifeng Wang <ruifeng.wang@arm.com>
> CC: Honnappa Nagarahalli <honnappa.nagarahalli@arm.com>
> CC: David Christensen <drc@linux.vnet.ibm.com>
> Feedback requested from ARM and PPC maintainers as to this change
> and what flags, if any, need to be in the .pc file for DPDK on such
> platforms. For example - is setting 'pkg_config_machine_args' to
> 'machine_args' by default necessary behaviour?

Support for Altivec would be the equivalent here for PPC and I'm not 
aware of any additional flags required for supported POWER CPUs on DPDK. 
  I can't speak to P10 requirements yet but the proposed change is a 
don't care for me.

Dave
  
Bruce Richardson Sept. 15, 2021, 4:28 p.m. UTC | #2
On Fri, Dec 11, 2020 at 03:51:11PM +0000, Bruce Richardson wrote:
> Traditionally any apps built using DPDK had to support the same
> instruction sets as supported when the DPDK SDK itself was built, since
> that was "leaked" through to the end-app and DPDK headers via
> RTE_MACHINE_CPUFLAG_* values. Therefore, when converting over to meson
> for app build correctness the "-march=" flag was included in the
> pkg-config cflags output.
> 
> However, since the DPDK-specific CPU flags are now obsolete, and we
> instead check directly for compiler-defined flags, we should no longer
> need to force the exact same architecture match in all cases. To
> faciliate such flexibility, a new pkg_config_machine_args array - which
> defaults to the existing machine_args array has been defined. The
> individual architectures - x86, arm and ppc - can choose if and how to
> override this value themselves.
> 
> For x86, since SSE4.2 is the minimum instruction-set level needed to run
> DPDK, and since some header files assume that minimum level of
> instruction set support, we override the "-march=" value with "-msse4"
> for the pkg-config file. This allows end applications to set their own
> "march" value while still ensuring valid DPDK compilation.
> 
> Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
> ---
> 
> CC: Jerin Jacob <jerinj@marvell.com>
> CC: Ruifeng Wang <ruifeng.wang@arm.com>
> CC: Honnappa Nagarahalli <honnappa.nagarahalli@arm.com>
> CC: David Christensen <drc@linux.vnet.ibm.com>
> Feedback requested from ARM and PPC maintainers as to this change
> and what flags, if any, need to be in the .pc file for DPDK on such
> platforms. For example - is setting 'pkg_config_machine_args' to
> 'machine_args' by default necessary behaviour?
> 

Ping for further thoughts or input on this patch.

/Bruce

> ---
>  buildtools/pkg-config/meson.build | 2 +-
>  config/meson.build                | 1 +
>  config/x86/meson.build            | 3 +++
>  3 files changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/buildtools/pkg-config/meson.build b/buildtools/pkg-config/meson.build
> index 5f1930428..8e2e24681 100644
> --- a/buildtools/pkg-config/meson.build
> +++ b/buildtools/pkg-config/meson.build
> @@ -2,7 +2,7 @@
>  # Copyright(c) 2020 Intel Corporation
> 
>  pkg = import('pkgconfig')
> -pkg_extra_cflags = ['-include', 'rte_config.h'] + machine_args
> +pkg_extra_cflags = ['-include', 'rte_config.h'] + pkg_config_machine_args
>  if is_freebsd
>  	pkg_extra_cflags += ['-D__BSD_VISIBLE']
>  endif
> diff --git a/config/meson.build b/config/meson.build
> index 3ddcc3539..d58ff781d 100644
> --- a/config/meson.build
> +++ b/config/meson.build
> @@ -100,6 +100,7 @@ if host_machine.cpu_family().startswith('ppc')
>  else
>  	machine_args += '-march=' + machine
>  endif
> +pkg_config_machine_args = machine_args # may be overriden late per arch
> 
>  toolchain = cc.get_id()
>  dpdk_conf.set_quoted('RTE_TOOLCHAIN', toolchain)
> diff --git a/config/x86/meson.build b/config/x86/meson.build
> index 31bfa63b1..fcd75502e 100644
> --- a/config/x86/meson.build
> +++ b/config/x86/meson.build
> @@ -16,6 +16,9 @@ if cc.get_define('__SSE4_2__', args: machine_args) == ''
>  	machine_args += '-msse4'
>  endif
> 
> +# require SSE4.2 in pkg-config file - don't use -march
> +pkg_config_machine_args = ['-msse4']
> +
>  base_flags = ['SSE', 'SSE2', 'SSE3','SSSE3', 'SSE4_1', 'SSE4_2']
>  foreach f:base_flags
>  	compile_time_cpuflags += ['RTE_CPUFLAG_' + f]
> --
> 2.27.0
>
  
David Christensen Sept. 15, 2021, 9:23 p.m. UTC | #3
On 9/15/21 9:28 AM, Bruce Richardson wrote:
> On Fri, Dec 11, 2020 at 03:51:11PM +0000, Bruce Richardson wrote:
>> Traditionally any apps built using DPDK had to support the same
>> instruction sets as supported when the DPDK SDK itself was built, since
>> that was "leaked" through to the end-app and DPDK headers via
>> RTE_MACHINE_CPUFLAG_* values. Therefore, when converting over to meson
>> for app build correctness the "-march=" flag was included in the
>> pkg-config cflags output.
>>
>> However, since the DPDK-specific CPU flags are now obsolete, and we
>> instead check directly for compiler-defined flags, we should no longer
>> need to force the exact same architecture match in all cases. To
>> faciliate such flexibility, a new pkg_config_machine_args array - which
>> defaults to the existing machine_args array has been defined. The
>> individual architectures - x86, arm and ppc - can choose if and how to
>> override this value themselves.
>>
>> For x86, since SSE4.2 is the minimum instruction-set level needed to run
>> DPDK, and since some header files assume that minimum level of
>> instruction set support, we override the "-march=" value with "-msse4"
>> for the pkg-config file. This allows end applications to set their own
>> "march" value while still ensuring valid DPDK compilation.
>>
>> Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
>> ---
>>
>> CC: Jerin Jacob <jerinj@marvell.com>
>> CC: Ruifeng Wang <ruifeng.wang@arm.com>
>> CC: Honnappa Nagarahalli <honnappa.nagarahalli@arm.com>
>> CC: David Christensen <drc@linux.vnet.ibm.com> for 
>> Feedback requested from ARM and PPC maintainers as to this change
>> and what flags, if any, need to be in the .pc file for DPDK on such
>> platforms. For example - is setting 'pkg_config_machine_args' to
>> 'machine_args' by default necessary behaviour?
>>
> 
> Ping for further thoughts or input on this patch.

On initial inspection I don't see any additional value for PPC systems. 
  Selection of a CPU through -mcpu implies a full ISA for that CPU, 
including things like vector extensions, at least with respect to the 
minimum supported POWER8 CPU (ISA 2.07) and later ISAs.  The values of 
machine_args and pkg_config_machine_args should be identical in all 
cases I can think of.

If a third party OpenPOWER CPU comes along some time in the future then 
the requirements may change.

Dave
  
Jerin Jacob Sept. 16, 2021, 3:43 a.m. UTC | #4
On Thu, Sep 16, 2021 at 2:53 AM David Christensen
<drc@linux.vnet.ibm.com> wrote:
>
>
>
> On 9/15/21 9:28 AM, Bruce Richardson wrote:
> > On Fri, Dec 11, 2020 at 03:51:11PM +0000, Bruce Richardson wrote:
> >> Traditionally any apps built using DPDK had to support the same
> >> instruction sets as supported when the DPDK SDK itself was built, since
> >> that was "leaked" through to the end-app and DPDK headers via
> >> RTE_MACHINE_CPUFLAG_* values. Therefore, when converting over to meson
> >> for app build correctness the "-march=" flag was included in the
> >> pkg-config cflags output.
> >>
> >> However, since the DPDK-specific CPU flags are now obsolete, and we
> >> instead check directly for compiler-defined flags, we should no longer
> >> need to force the exact same architecture match in all cases. To
> >> faciliate such flexibility, a new pkg_config_machine_args array - which
> >> defaults to the existing machine_args array has been defined. The
> >> individual architectures - x86, arm and ppc - can choose if and how to
> >> override this value themselves.
> >>
> >> For x86, since SSE4.2 is the minimum instruction-set level needed to run
> >> DPDK, and since some header files assume that minimum level of
> >> instruction set support, we override the "-march=" value with "-msse4"
> >> for the pkg-config file. This allows end applications to set their own
> >> "march" value while still ensuring valid DPDK compilation.
> >>
> >> Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
> >> ---
> >>
> >> CC: Jerin Jacob <jerinj@marvell.com>
> >> CC: Ruifeng Wang <ruifeng.wang@arm.com>
> >> CC: Honnappa Nagarahalli <honnappa.nagarahalli@arm.com>
> >> CC: David Christensen <drc@linux.vnet.ibm.com> for
> >> Feedback requested from ARM and PPC maintainers as to this change
> >> and what flags, if any, need to be in the .pc file for DPDK on such
> >> platforms. For example - is setting 'pkg_config_machine_args' to
> >> 'machine_args' by default necessary behaviour?
> >>
> >
> > Ping for further thoughts or input on this patch.

Armv8 has dedicated config(taken least cpu flags which supports all
armv8) for this purpose config/arm/arm64_armv8_linux_gcc.
So this change looks good to me. @Ruifeng Wang (Arm Technology China)
Any comments?


>
> On initial inspection I don't see any additional value for PPC systems.
>   Selection of a CPU through -mcpu implies a full ISA for that CPU,
> including things like vector extensions, at least with respect to the
> minimum supported POWER8 CPU (ISA 2.07) and later ISAs.  The values of
> machine_args and pkg_config_machine_args should be identical in all
> cases I can think of.
>
> If a third party OpenPOWER CPU comes along some time in the future then
> the requirements may change.




>
> Dave
  
Ruifeng Wang Sept. 16, 2021, 10:16 a.m. UTC | #5
> -----Original Message-----
> From: Jerin Jacob <jerinjacobk@gmail.com>
> Sent: Thursday, September 16, 2021 11:43 AM
> To: David Christensen <drc@linux.vnet.ibm.com>
> Cc: Bruce Richardson <bruce.richardson@intel.com>; dpdk-dev
> <dev@dpdk.org>; Luca Boccassi <bluca@debian.org>; David Marchand
> <david.marchand@redhat.com>; ian.stokes@intel.com; Ilya Maximets
> <i.maximets@ovn.org>; jerinj@marvell.com; Ruifeng Wang
> <Ruifeng.Wang@arm.com>; Honnappa Nagarahalli
> <Honnappa.Nagarahalli@arm.com>; Ananyev, Konstantin
> <konstantin.ananyev@intel.com>; Ferruh Yigit <ferruh.yigit@intel.com>
> Subject: Re: [dpdk-dev] [RFC PATCH] build/pkg-config: remove machine arch
> flag
> 
> On Thu, Sep 16, 2021 at 2:53 AM David Christensen <drc@linux.vnet.ibm.com>
> wrote:
> >
> >
> >
> > On 9/15/21 9:28 AM, Bruce Richardson wrote:
> > > On Fri, Dec 11, 2020 at 03:51:11PM +0000, Bruce Richardson wrote:
> > >> Traditionally any apps built using DPDK had to support the same
> > >> instruction sets as supported when the DPDK SDK itself was built,
> > >> since that was "leaked" through to the end-app and DPDK headers via
> > >> RTE_MACHINE_CPUFLAG_* values. Therefore, when converting over to
> > >> meson for app build correctness the "-march=" flag was included in
> > >> the pkg-config cflags output.
> > >>
> > >> However, since the DPDK-specific CPU flags are now obsolete, and we
> > >> instead check directly for compiler-defined flags, we should no
> > >> longer need to force the exact same architecture match in all
> > >> cases. To faciliate such flexibility, a new pkg_config_machine_args
> > >> array - which defaults to the existing machine_args array has been
> > >> defined. The individual architectures - x86, arm and ppc - can
> > >> choose if and how to override this value themselves.
> > >>
> > >> For x86, since SSE4.2 is the minimum instruction-set level needed
> > >> to run DPDK, and since some header files assume that minimum level
> > >> of instruction set support, we override the "-march=" value with "-
> msse4"
> > >> for the pkg-config file. This allows end applications to set their
> > >> own "march" value while still ensuring valid DPDK compilation.
> > >>
> > >> Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
> > >> ---
> > >>
> > >> CC: Jerin Jacob <jerinj@marvell.com>
> > >> CC: Ruifeng Wang <ruifeng.wang@arm.com>
> > >> CC: Honnappa Nagarahalli <honnappa.nagarahalli@arm.com>
> > >> CC: David Christensen <drc@linux.vnet.ibm.com> for Feedback
> > >> requested from ARM and PPC maintainers as to this change and what
> > >> flags, if any, need to be in the .pc file for DPDK on such
> > >> platforms. For example - is setting 'pkg_config_machine_args' to
> > >> 'machine_args' by default necessary behaviour?
> > >>
> > >
> > > Ping for further thoughts or input on this patch.
> 
> Armv8 has dedicated config(taken least cpu flags which supports all
> armv8) for this purpose config/arm/arm64_armv8_linux_gcc.
> So this change looks good to me. @Ruifeng Wang (Arm Technology China)
> Any comments?
> 

Agree. For distro build, only armv8-a is requested. The change looks fine.

Thanks,
Ruifeng
> 
> >
> > On initial inspection I don't see any additional value for PPC systems.
> >   Selection of a CPU through -mcpu implies a full ISA for that CPU,
> > including things like vector extensions, at least with respect to the
> > minimum supported POWER8 CPU (ISA 2.07) and later ISAs.  The values of
> > machine_args and pkg_config_machine_args should be identical in all
> > cases I can think of.
> >
> > If a third party OpenPOWER CPU comes along some time in the future
> > then the requirements may change.
> 
> 
> 
> 
> >
> > Dave
  
Ruifeng Wang Sept. 16, 2021, 2:11 p.m. UTC | #6
> -----Original Message-----
> From: dev <dev-bounces@dpdk.org> On Behalf Of Ruifeng Wang
> Sent: Thursday, September 16, 2021 6:17 PM
> To: Jerin Jacob <jerinjacobk@gmail.com>; David Christensen
> <drc@linux.vnet.ibm.com>
> Cc: Bruce Richardson <bruce.richardson@intel.com>; dpdk-dev
> <dev@dpdk.org>; Luca Boccassi <bluca@debian.org>; David Marchand
> <david.marchand@redhat.com>; ian.stokes@intel.com; Ilya Maximets
> <i.maximets@ovn.org>; jerinj@marvell.com; Honnappa Nagarahalli
> <Honnappa.Nagarahalli@arm.com>; Ananyev, Konstantin
> <konstantin.ananyev@intel.com>; Ferruh Yigit <ferruh.yigit@intel.com>; nd
> <nd@arm.com>
> Subject: Re: [dpdk-dev] [RFC PATCH] build/pkg-config: remove machine arch
> flag
> 
> > -----Original Message-----
> > From: Jerin Jacob <jerinjacobk@gmail.com>
> > Sent: Thursday, September 16, 2021 11:43 AM
> > To: David Christensen <drc@linux.vnet.ibm.com>
> > Cc: Bruce Richardson <bruce.richardson@intel.com>; dpdk-dev
> > <dev@dpdk.org>; Luca Boccassi <bluca@debian.org>; David Marchand
> > <david.marchand@redhat.com>; ian.stokes@intel.com; Ilya Maximets
> > <i.maximets@ovn.org>; jerinj@marvell.com; Ruifeng Wang
> > <Ruifeng.Wang@arm.com>; Honnappa Nagarahalli
> > <Honnappa.Nagarahalli@arm.com>; Ananyev, Konstantin
> > <konstantin.ananyev@intel.com>; Ferruh Yigit <ferruh.yigit@intel.com>
> > Subject: Re: [dpdk-dev] [RFC PATCH] build/pkg-config: remove machine
> > arch flag
> >
> > On Thu, Sep 16, 2021 at 2:53 AM David Christensen
> > <drc@linux.vnet.ibm.com>
> > wrote:
> > >
> > >
> > >
> > > On 9/15/21 9:28 AM, Bruce Richardson wrote:
> > > > On Fri, Dec 11, 2020 at 03:51:11PM +0000, Bruce Richardson wrote:
> > > >> Traditionally any apps built using DPDK had to support the same
> > > >> instruction sets as supported when the DPDK SDK itself was built,
> > > >> since that was "leaked" through to the end-app and DPDK headers
> > > >> via
> > > >> RTE_MACHINE_CPUFLAG_* values. Therefore, when converting over
> to
> > > >> meson for app build correctness the "-march=" flag was included
> > > >> in the pkg-config cflags output.
> > > >>
> > > >> However, since the DPDK-specific CPU flags are now obsolete, and
> > > >> we instead check directly for compiler-defined flags, we should
> > > >> no longer need to force the exact same architecture match in all
> > > >> cases. To faciliate such flexibility, a new
> > > >> pkg_config_machine_args array - which defaults to the existing
> > > >> machine_args array has been defined. The individual architectures
> > > >> - x86, arm and ppc - can choose if and how to override this value
> themselves.
> > > >>
> > > >> For x86, since SSE4.2 is the minimum instruction-set level needed
> > > >> to run DPDK, and since some header files assume that minimum
> > > >> level of instruction set support, we override the "-march=" value
> > > >> with "-
> > msse4"
> > > >> for the pkg-config file. This allows end applications to set
> > > >> their own "march" value while still ensuring valid DPDK compilation.
> > > >>
> > > >> Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
> > > >> ---
> > > >>
> > > >> CC: Jerin Jacob <jerinj@marvell.com>
> > > >> CC: Ruifeng Wang <ruifeng.wang@arm.com>
> > > >> CC: Honnappa Nagarahalli <honnappa.nagarahalli@arm.com>
> > > >> CC: David Christensen <drc@linux.vnet.ibm.com> for Feedback
> > > >> requested from ARM and PPC maintainers as to this change and what
> > > >> flags, if any, need to be in the .pc file for DPDK on such
> > > >> platforms. For example - is setting 'pkg_config_machine_args' to
> > > >> 'machine_args' by default necessary behaviour?
> > > >>
> > > >
> > > > Ping for further thoughts or input on this patch.
> >
> > Armv8 has dedicated config(taken least cpu flags which supports all
> > armv8) for this purpose config/arm/arm64_armv8_linux_gcc.
> > So this change looks good to me. @Ruifeng Wang (Arm Technology China)
> > Any comments?
> >
> 
> Agree. For distro build, only armv8-a is requested. The change looks fine.

This is fine if "cross-file" is provided when doing distro build. 
However, when "-Dmachine=default"/"-Dplatform=default" is used instead of "cross-file" to do distro build, current change in config/meson.build
will lead to " pkg_config_machine_args = -march=generic". This is because generic build is handled by subsequent arch specific config on Arm.

I think moving the change in config/meson.build down below line #307 subdir(arch_subdir) will address aforementioned issue. As by the time,
machine_args has been updated with proper value.

> 
> Thanks,
> Ruifeng
> >
> > >
> > > On initial inspection I don't see any additional value for PPC systems.
> > >   Selection of a CPU through -mcpu implies a full ISA for that CPU,
> > > including things like vector extensions, at least with respect to
> > > the minimum supported POWER8 CPU (ISA 2.07) and later ISAs.  The
> > > values of machine_args and pkg_config_machine_args should be
> > > identical in all cases I can think of.
> > >
> > > If a third party OpenPOWER CPU comes along some time in the future
> > > then the requirements may change.
> >
> >
> >
> >
> > >
> > > Dave
  
Stephen Hemminger June 14, 2023, 7:33 p.m. UTC | #7
On Fri, 11 Dec 2020 15:51:11 +0000
Bruce Richardson <bruce.richardson@intel.com> wrote:

> Traditionally any apps built using DPDK had to support the same
> instruction sets as supported when the DPDK SDK itself was built, since
> that was "leaked" through to the end-app and DPDK headers via
> RTE_MACHINE_CPUFLAG_* values. Therefore, when converting over to meson
> for app build correctness the "-march=" flag was included in the
> pkg-config cflags output.
> 
> However, since the DPDK-specific CPU flags are now obsolete, and we
> instead check directly for compiler-defined flags, we should no longer
> need to force the exact same architecture match in all cases. To
> faciliate such flexibility, a new pkg_config_machine_args array - which
> defaults to the existing machine_args array has been defined. The
> individual architectures - x86, arm and ppc - can choose if and how to
> override this value themselves.
> 
> For x86, since SSE4.2 is the minimum instruction-set level needed to run
> DPDK, and since some header files assume that minimum level of
> instruction set support, we override the "-march=" value with "-msse4"
> for the pkg-config file. This allows end applications to set their own
> "march" value while still ensuring valid DPDK compilation.
> 
> Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>

This looks fine, and can see no negatives in the comments.
Could you rebase and resubmit a new version if still relevant?
  
Bruce Richardson June 15, 2023, 8:44 a.m. UTC | #8
On Wed, Jun 14, 2023 at 12:33:10PM -0700, Stephen Hemminger wrote:
> On Fri, 11 Dec 2020 15:51:11 +0000
> Bruce Richardson <bruce.richardson@intel.com> wrote:
> 
> > Traditionally any apps built using DPDK had to support the same
> > instruction sets as supported when the DPDK SDK itself was built, since
> > that was "leaked" through to the end-app and DPDK headers via
> > RTE_MACHINE_CPUFLAG_* values. Therefore, when converting over to meson
> > for app build correctness the "-march=" flag was included in the
> > pkg-config cflags output.
> > 
> > However, since the DPDK-specific CPU flags are now obsolete, and we
> > instead check directly for compiler-defined flags, we should no longer
> > need to force the exact same architecture match in all cases. To
> > faciliate such flexibility, a new pkg_config_machine_args array - which
> > defaults to the existing machine_args array has been defined. The
> > individual architectures - x86, arm and ppc - can choose if and how to
> > override this value themselves.
> > 
> > For x86, since SSE4.2 is the minimum instruction-set level needed to run
> > DPDK, and since some header files assume that minimum level of
> > instruction set support, we override the "-march=" value with "-msse4"
> > for the pkg-config file. This allows end applications to set their own
> > "march" value while still ensuring valid DPDK compilation.
> > 
> > Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
> 
> This looks fine, and can see no negatives in the comments.
> Could you rebase and resubmit a new version if still relevant?
> 
There seemed to be a general lack of interest in it, sadly, so not sure
I'll resubmit.
  

Patch

diff --git a/buildtools/pkg-config/meson.build b/buildtools/pkg-config/meson.build
index 5f1930428..8e2e24681 100644
--- a/buildtools/pkg-config/meson.build
+++ b/buildtools/pkg-config/meson.build
@@ -2,7 +2,7 @@ 
 # Copyright(c) 2020 Intel Corporation

 pkg = import('pkgconfig')
-pkg_extra_cflags = ['-include', 'rte_config.h'] + machine_args
+pkg_extra_cflags = ['-include', 'rte_config.h'] + pkg_config_machine_args
 if is_freebsd
 	pkg_extra_cflags += ['-D__BSD_VISIBLE']
 endif
diff --git a/config/meson.build b/config/meson.build
index 3ddcc3539..d58ff781d 100644
--- a/config/meson.build
+++ b/config/meson.build
@@ -100,6 +100,7 @@  if host_machine.cpu_family().startswith('ppc')
 else
 	machine_args += '-march=' + machine
 endif
+pkg_config_machine_args = machine_args # may be overriden late per arch

 toolchain = cc.get_id()
 dpdk_conf.set_quoted('RTE_TOOLCHAIN', toolchain)
diff --git a/config/x86/meson.build b/config/x86/meson.build
index 31bfa63b1..fcd75502e 100644
--- a/config/x86/meson.build
+++ b/config/x86/meson.build
@@ -16,6 +16,9 @@  if cc.get_define('__SSE4_2__', args: machine_args) == ''
 	machine_args += '-msse4'
 endif

+# require SSE4.2 in pkg-config file - don't use -march
+pkg_config_machine_args = ['-msse4']
+
 base_flags = ['SSE', 'SSE2', 'SSE3','SSSE3', 'SSE4_1', 'SSE4_2']
 foreach f:base_flags
 	compile_time_cpuflags += ['RTE_CPUFLAG_' + f]