DPDK patches and discussions
 help / color / mirror / Atom feed
* [PATCH] build: fix build on FreeBSD with Meson 0.61.1
@ 2022-02-14 11:43 Karl Bonde Torp
  2022-02-14 13:48 ` Bruce Richardson
  2022-02-15 15:31 ` Bruce Richardson
  0 siblings, 2 replies; 10+ messages in thread
From: Karl Bonde Torp @ 2022-02-14 11:43 UTC (permalink / raw)
  To: dev; +Cc: Karl Bonde Torp

When building with Meson 0.61.1 on FreeBSD some archives become
corrupted. This can be avoided by using 'llvm-ar' instead of 'ar'.

Signed-off-by: Karl Bonde Torp <k.torp@samsung.com>
---
 buildtools/meson.build | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/buildtools/meson.build b/buildtools/meson.build
index 400b88f251..e1c600e40f 100644
--- a/buildtools/meson.build
+++ b/buildtools/meson.build
@@ -31,6 +31,9 @@ if host_machine.system() == 'windows'
         pmdinfo += 'llvm-ar'
     endif
     pmdinfogen += 'coff'
+elif host_machine.system() == 'freebsd'
+    pmdinfo += 'llvm-ar'
+    pmdinfogen += 'elf'
 else
     pmdinfo += 'ar'
     pmdinfogen += 'elf'
-- 
2.35.1


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

* Re: [PATCH] build: fix build on FreeBSD with Meson 0.61.1
  2022-02-14 11:43 [PATCH] build: fix build on FreeBSD with Meson 0.61.1 Karl Bonde Torp
@ 2022-02-14 13:48 ` Bruce Richardson
  2022-02-15 11:07   ` Karl Bonde Torp
  2022-02-15 15:31 ` Bruce Richardson
  1 sibling, 1 reply; 10+ messages in thread
From: Bruce Richardson @ 2022-02-14 13:48 UTC (permalink / raw)
  To: Karl Bonde Torp; +Cc: dev, Karl Bonde Torp

On Mon, Feb 14, 2022 at 12:43:13PM +0100, Karl Bonde Torp wrote:
> When building with Meson 0.61.1 on FreeBSD some archives become
> corrupted. This can be avoided by using 'llvm-ar' instead of 'ar'.
> 
> Signed-off-by: Karl Bonde Torp <k.torp@samsung.com>
> ---

Hi,

thanks for the patch. Can you perhaps provide some instructions or more
details as to how/when you see this issue? A clean build of mine on FreeBSD
with meson 0.61.1 didn't seem to flag up any problems and I'd like to
reproduce the issue to verify the fix.

/Bruce

>  buildtools/meson.build | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/buildtools/meson.build b/buildtools/meson.build
> index 400b88f251..e1c600e40f 100644
> --- a/buildtools/meson.build
> +++ b/buildtools/meson.build
> @@ -31,6 +31,9 @@ if host_machine.system() == 'windows'
>          pmdinfo += 'llvm-ar'
>      endif
>      pmdinfogen += 'coff'
> +elif host_machine.system() == 'freebsd'
> +    pmdinfo += 'llvm-ar'
> +    pmdinfogen += 'elf'
>  else
>      pmdinfo += 'ar'
>      pmdinfogen += 'elf'
> -- 
> 2.35.1
> 

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

* Re: [PATCH] build: fix build on FreeBSD with Meson 0.61.1
  2022-02-14 13:48 ` Bruce Richardson
@ 2022-02-15 11:07   ` Karl Bonde Torp
  2022-02-15 11:27     ` Bruce Richardson
  0 siblings, 1 reply; 10+ messages in thread
From: Karl Bonde Torp @ 2022-02-15 11:07 UTC (permalink / raw)
  To: Bruce Richardson; +Cc: dev, Karl Bonde Torp

On Mon, 14 Feb 2022 at 14:48, Bruce Richardson
<bruce.richardson@intel.com> wrote:
>
> On Mon, Feb 14, 2022 at 12:43:13PM +0100, Karl Bonde Torp wrote:
> > When building with Meson 0.61.1 on FreeBSD some archives become
> > corrupted. This can be avoided by using 'llvm-ar' instead of 'ar'.
> >
> > Signed-off-by: Karl Bonde Torp <k.torp@samsung.com>
> > ---
>
> Can you perhaps provide some instructions or more details as to
> how/when you see this issue?

Some background info:
I'm working on xNVMe and that depends on SPDK which in turn depends
on DPDK. These are includes as subprojects on github which is why the
FreeBSD port of DPDK is not an option for me.

The steps I took to reproduce the issue are listed below, this assumes
a clean img of FreeBSD 13:
(I know some of them may be obvious, but I tried to avoid ambiguity)

* install git and the pkg manager:
pkg install git
* get kernel source:
git clone https://git.freebsd.org/src.git /usr/src
* get ports:
git clone https://git.freebsd.org/ports.git /usr/ports
* install dependencies (except meson) with pkg:
pkg install py38-pyelftools ninja pkgconf binutils
* build meson 0.61.1 from port:
cd /usr/ports/devel/meson/ && make install clean
* clone dpdk repo:
git clone https://github.com/DPDK/dpdk.git
* inside dpdk folder run:
meson builddir && meson compile -C builddir
* encounter error:
[466/1915] Generating drivers/rte_common_cpt.pmd.c with a custom
command
FAILED: drivers/rte_common_cpt.pmd.c
/usr/local/bin/python3.8 ../buildtools/gen-pmdinfo-cfile.py
/root/dpdk/builddir/buildtools ar
/root/dpdk/builddir/drivers/libtmp_rte_common_cpt.a
drivers/rte_common_cpt.pmd.c /usr/local/bin/python3.8
../buildtools/pmdinfogen.py elf
ar: fatal: Unrecognized archive format: Inappropriate file type or
format
Traceback (most recent call last):
  File "../buildtools/gen-pmdinfo-cfile.py", line 13, in <module>
    for name in subprocess.run([ar, "t", archive],
    stdout=subprocess.PIPE,
  File "/usr/local/lib/python3.8/subprocess.py", line 516, in run
    raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command '['ar', 't',
'/root/dpdk/builddir/drivers/libtmp_rte_common_cpt.a']' returned
non-zero exit status 70.

> A clean build of mine on FreeBSD with meson 0.61.1 didn't seem to
> flag up any problems and I'd like to reproduce the issue to verify the fix.
I'm guessing you're refering to the port of DPDK here.
If not I am very interested to hear how you go about this.

> >  buildtools/meson.build | 3 +++
> >  1 file changed, 3 insertions(+)
> >
> > diff --git a/buildtools/meson.build b/buildtools/meson.build
> > index 400b88f251..e1c600e40f 100644
> > --- a/buildtools/meson.build
> > +++ b/buildtools/meson.build
> > @@ -31,6 +31,9 @@ if host_machine.system() == 'windows'
> >          pmdinfo += 'llvm-ar'
> >      endif
> >      pmdinfogen += 'coff'
> > +elif host_machine.system() == 'freebsd'
> > +    pmdinfo += 'llvm-ar'
> > +    pmdinfogen += 'elf'
> >  else
> >      pmdinfo += 'ar'
> >      pmdinfogen += 'elf'
> > --
> > 2.35.1
> >

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

* Re: [PATCH] build: fix build on FreeBSD with Meson 0.61.1
  2022-02-15 11:07   ` Karl Bonde Torp
@ 2022-02-15 11:27     ` Bruce Richardson
  2022-02-15 13:50       ` Karl Bonde Torp
  0 siblings, 1 reply; 10+ messages in thread
From: Bruce Richardson @ 2022-02-15 11:27 UTC (permalink / raw)
  To: Karl Bonde Torp; +Cc: dev, Karl Bonde Torp

On Tue, Feb 15, 2022 at 12:07:55PM +0100, Karl Bonde Torp wrote:
> On Mon, 14 Feb 2022 at 14:48, Bruce Richardson
> <bruce.richardson@intel.com> wrote:
> >
> > On Mon, Feb 14, 2022 at 12:43:13PM +0100, Karl Bonde Torp wrote:
> > > When building with Meson 0.61.1 on FreeBSD some archives become
> > > corrupted. This can be avoided by using 'llvm-ar' instead of 'ar'.
> > >
> > > Signed-off-by: Karl Bonde Torp <k.torp@samsung.com>
> > > ---
> >
> > Can you perhaps provide some instructions or more details as to
> > how/when you see this issue?
> 
> Some background info:
> I'm working on xNVMe and that depends on SPDK which in turn depends
> on DPDK. These are includes as subprojects on github which is why the
> FreeBSD port of DPDK is not an option for me.
> 
> The steps I took to reproduce the issue are listed below, this assumes
> a clean img of FreeBSD 13:
> (I know some of them may be obvious, but I tried to avoid ambiguity)
> 
> * install git and the pkg manager:
> pkg install git
> * get kernel source:
> git clone https://git.freebsd.org/src.git /usr/src
> * get ports:
> git clone https://git.freebsd.org/ports.git /usr/ports
> * install dependencies (except meson) with pkg:
> pkg install py38-pyelftools ninja pkgconf binutils
> * build meson 0.61.1 from port:
> cd /usr/ports/devel/meson/ && make install clean
> * clone dpdk repo:
> git clone https://github.com/DPDK/dpdk.git
> * inside dpdk folder run:
> meson builddir && meson compile -C builddir
> * encounter error:
> [466/1915] Generating drivers/rte_common_cpt.pmd.c with a custom
> command
> FAILED: drivers/rte_common_cpt.pmd.c
> /usr/local/bin/python3.8 ../buildtools/gen-pmdinfo-cfile.py
> /root/dpdk/builddir/buildtools ar
> /root/dpdk/builddir/drivers/libtmp_rte_common_cpt.a
> drivers/rte_common_cpt.pmd.c /usr/local/bin/python3.8
> ../buildtools/pmdinfogen.py elf
> ar: fatal: Unrecognized archive format: Inappropriate file type or
> format
> Traceback (most recent call last):
>   File "../buildtools/gen-pmdinfo-cfile.py", line 13, in <module>
>     for name in subprocess.run([ar, "t", archive],
>     stdout=subprocess.PIPE,
>   File "/usr/local/lib/python3.8/subprocess.py", line 516, in run
>     raise CalledProcessError(retcode, process.args,
> subprocess.CalledProcessError: Command '['ar', 't',
> '/root/dpdk/builddir/drivers/libtmp_rte_common_cpt.a']' returned
> non-zero exit status 70.
> 
> > A clean build of mine on FreeBSD with meson 0.61.1 didn't seem to
> > flag up any problems and I'd like to reproduce the issue to verify the fix.
> I'm guessing you're refering to the port of DPDK here.
> If not I am very interested to hear how you go about this.
>

I tested with latest DPDK on a FreeBSD machine also, not using the BSD
ports version. Unfortunately it wasn't a clean install, but still a fairly
new one. I updated the BSD pkg config to use "latest" rather than
"quarterly" snapshot and then ran an "pkg upgrade". This gave me meson
0.61.1, and updated other packages too. Build of DPDK then ran cleanly.

I wonder if the version of binutils or some other package might be the
difference. The version I have is "GNU ar (GNU Binutils) 2.37". What
version of binutils is installed on your system?

I'll create a new vm image of BSD 13 and try and reproduce using your
instructions above.

/Bruce

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

* Re: [PATCH] build: fix build on FreeBSD with Meson 0.61.1
  2022-02-15 11:27     ` Bruce Richardson
@ 2022-02-15 13:50       ` Karl Bonde Torp
  2022-02-15 15:34         ` Bruce Richardson
  0 siblings, 1 reply; 10+ messages in thread
From: Karl Bonde Torp @ 2022-02-15 13:50 UTC (permalink / raw)
  To: Bruce Richardson; +Cc: dev, Karl Bonde Torp

On Tue, 15 Feb 2022 at 12:27, Bruce Richardson
<bruce.richardson@intel.com> wrote:
>
> On Tue, Feb 15, 2022 at 12:07:55PM +0100, Karl Bonde Torp wrote:
> > On Mon, 14 Feb 2022 at 14:48, Bruce Richardson
> > <bruce.richardson@intel.com> wrote:
> > >
> > > On Mon, Feb 14, 2022 at 12:43:13PM +0100, Karl Bonde Torp wrote:
> > > > When building with Meson 0.61.1 on FreeBSD some archives become
> > > > corrupted. This can be avoided by using 'llvm-ar' instead of 'ar'.
> > > >
> > > > Signed-off-by: Karl Bonde Torp <k.torp@samsung.com>
> > > > ---
> > >
> > > Can you perhaps provide some instructions or more details as to
> > > how/when you see this issue?
> >
> > Some background info:
> > I'm working on xNVMe and that depends on SPDK which in turn depends
> > on DPDK. These are includes as subprojects on github which is why the
> > FreeBSD port of DPDK is not an option for me.
> >
> > The steps I took to reproduce the issue are listed below, this assumes
> > a clean img of FreeBSD 13:
> > (I know some of them may be obvious, but I tried to avoid ambiguity)
> >
> > * install git and the pkg manager:
> > pkg install git
> > * get kernel source:
> > git clone https://git.freebsd.org/src.git /usr/src
> > * get ports:
> > git clone https://git.freebsd.org/ports.git /usr/ports
> > * install dependencies (except meson) with pkg:
> > pkg install py38-pyelftools ninja pkgconf binutils
> > * build meson 0.61.1 from port:
> > cd /usr/ports/devel/meson/ && make install clean
> > * clone dpdk repo:
> > git clone https://github.com/DPDK/dpdk.git
> > * inside dpdk folder run:
> > meson builddir && meson compile -C builddir
> > * encounter error:
> > [466/1915] Generating drivers/rte_common_cpt.pmd.c with a custom
> > command
> > FAILED: drivers/rte_common_cpt.pmd.c
> > /usr/local/bin/python3.8 ../buildtools/gen-pmdinfo-cfile.py
> > /root/dpdk/builddir/buildtools ar
> > /root/dpdk/builddir/drivers/libtmp_rte_common_cpt.a
> > drivers/rte_common_cpt.pmd.c /usr/local/bin/python3.8
> > ../buildtools/pmdinfogen.py elf
> > ar: fatal: Unrecognized archive format: Inappropriate file type or
> > format
> > Traceback (most recent call last):
> >   File "../buildtools/gen-pmdinfo-cfile.py", line 13, in <module>
> >     for name in subprocess.run([ar, "t", archive],
> >     stdout=subprocess.PIPE,
> >   File "/usr/local/lib/python3.8/subprocess.py", line 516, in run
> >     raise CalledProcessError(retcode, process.args,
> > subprocess.CalledProcessError: Command '['ar', 't',
> > '/root/dpdk/builddir/drivers/libtmp_rte_common_cpt.a']' returned
> > non-zero exit status 70.
> >
> > > A clean build of mine on FreeBSD with meson 0.61.1 didn't seem to
> > > flag up any problems and I'd like to reproduce the issue to verify the fix.
> > I'm guessing you're refering to the port of DPDK here.
> > If not I am very interested to hear how you go about this.
> >
>
> I tested with latest DPDK on a FreeBSD machine also, not using the BSD
> ports version. Unfortunately it wasn't a clean install, but still a fairly
> new one. I updated the BSD pkg config to use "latest" rather than
> "quarterly" snapshot and then ran an "pkg upgrade". This gave me meson
> 0.61.1, and updated other packages too. Build of DPDK then ran cleanly.
>
> I wonder if the version of binutils or some other package might be the
> difference. The version I have is "GNU ar (GNU Binutils) 2.37". What
> version of binutils is installed on your system?
My version of binutils is 2.37_2,1, so that is the same.
However, I think you're onto something here. When I run "ar --version" I
get "BSD ar 1.1.0 - libarchive 3.5.1".
The problem my patch aimed to solve was 'BSD ar' behaving differently
than 'GNU ar'. So if you somehow got the 'ar' command to invoke 'GNU
ar' on your system, maybe I just need to do the same.
> I'll create a new vm image of BSD 13 and try and reproduce using your
> instructions above.
>
> /Bruce

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

* Re: [PATCH] build: fix build on FreeBSD with Meson 0.61.1
  2022-02-14 11:43 [PATCH] build: fix build on FreeBSD with Meson 0.61.1 Karl Bonde Torp
  2022-02-14 13:48 ` Bruce Richardson
@ 2022-02-15 15:31 ` Bruce Richardson
  2022-03-08 14:39   ` Thomas Monjalon
  1 sibling, 1 reply; 10+ messages in thread
From: Bruce Richardson @ 2022-02-15 15:31 UTC (permalink / raw)
  To: Karl Bonde Torp; +Cc: dev, Karl Bonde Torp

On Mon, Feb 14, 2022 at 12:43:13PM +0100, Karl Bonde Torp wrote:
> When building with Meson 0.61.1 on FreeBSD some archives become
> corrupted. This can be avoided by using 'llvm-ar' instead of 'ar'.
> 
> Signed-off-by: Karl Bonde Torp <k.torp@samsung.com>
> ---
>  buildtools/meson.build | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/buildtools/meson.build b/buildtools/meson.build
> index 400b88f251..e1c600e40f 100644
> --- a/buildtools/meson.build
> +++ b/buildtools/meson.build
> @@ -31,6 +31,9 @@ if host_machine.system() == 'windows'
>          pmdinfo += 'llvm-ar'
>      endif
>      pmdinfogen += 'coff'
> +elif host_machine.system() == 'freebsd'
> +    pmdinfo += 'llvm-ar'
> +    pmdinfogen += 'elf'
>  else
>      pmdinfo += 'ar'
>      pmdinfogen += 'elf'
> -- 

Based off the instructions you posted later in the thread, I've reproduced
the issue - and then done a little extra investigation. Here is my
understanding:

* By default on FreeBSD the linking is being done by llvm-ar
* The resulting libraries are being linked as thin archives and "ar" binary
  does not seem to be able to process them.
* When building with CC=gcc on FreeBSD, "ar" is used as a linker, and the
  resulting archives are regular .a files.
* On Linux, whether building with clang or gcc, "ar" seems to be used as
  linker.

The ideal situation here would be if we could use meson to report itself
what the static linker in use is, but unfortunately while we can query the
dynamic linker using "meson.compiler().get_linker_id()", there doesn't seem
to be an equivalent for the static linker. Therefore, the only option seems
to be a fix as here. Only question remains as to whether we want to only
use llvm-ar for clang builds on FreeBSD or use if for all builds on FreeBSD.
I'm not sure it makes much difference either way, but I'd tend towards
limiting the use of llvm-ar to only clang builds.

With or without this suggested change,

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

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

* Re: [PATCH] build: fix build on FreeBSD with Meson 0.61.1
  2022-02-15 13:50       ` Karl Bonde Torp
@ 2022-02-15 15:34         ` Bruce Richardson
  2022-03-07 16:43           ` Thomas Monjalon
  0 siblings, 1 reply; 10+ messages in thread
From: Bruce Richardson @ 2022-02-15 15:34 UTC (permalink / raw)
  To: Karl Bonde Torp; +Cc: dev, Karl Bonde Torp

On Tue, Feb 15, 2022 at 02:50:48PM +0100, Karl Bonde Torp wrote:
> On Tue, 15 Feb 2022 at 12:27, Bruce Richardson
> <bruce.richardson@intel.com> wrote:
> >
> > On Tue, Feb 15, 2022 at 12:07:55PM +0100, Karl Bonde Torp wrote:
> > > On Mon, 14 Feb 2022 at 14:48, Bruce Richardson
> > > <bruce.richardson@intel.com> wrote:
> > > >
> > > > On Mon, Feb 14, 2022 at 12:43:13PM +0100, Karl Bonde Torp wrote:
> > > > > When building with Meson 0.61.1 on FreeBSD some archives become
> > > > > corrupted. This can be avoided by using 'llvm-ar' instead of 'ar'.
> > > > >
> > > > > Signed-off-by: Karl Bonde Torp <k.torp@samsung.com>
> > > > > ---
> > > >
> > > > Can you perhaps provide some instructions or more details as to
> > > > how/when you see this issue?
> > >
> > > Some background info:
> > > I'm working on xNVMe and that depends on SPDK which in turn depends
> > > on DPDK. These are includes as subprojects on github which is why the
> > > FreeBSD port of DPDK is not an option for me.
> > >
> > > The steps I took to reproduce the issue are listed below, this assumes
> > > a clean img of FreeBSD 13:
> > > (I know some of them may be obvious, but I tried to avoid ambiguity)
> > >
> > > * install git and the pkg manager:
> > > pkg install git
> > > * get kernel source:
> > > git clone https://git.freebsd.org/src.git /usr/src
> > > * get ports:
> > > git clone https://git.freebsd.org/ports.git /usr/ports
> > > * install dependencies (except meson) with pkg:
> > > pkg install py38-pyelftools ninja pkgconf binutils
> > > * build meson 0.61.1 from port:
> > > cd /usr/ports/devel/meson/ && make install clean
> > > * clone dpdk repo:
> > > git clone https://github.com/DPDK/dpdk.git
> > > * inside dpdk folder run:
> > > meson builddir && meson compile -C builddir
> > > * encounter error:
> > > [466/1915] Generating drivers/rte_common_cpt.pmd.c with a custom
> > > command
> > > FAILED: drivers/rte_common_cpt.pmd.c
> > > /usr/local/bin/python3.8 ../buildtools/gen-pmdinfo-cfile.py
> > > /root/dpdk/builddir/buildtools ar
> > > /root/dpdk/builddir/drivers/libtmp_rte_common_cpt.a
> > > drivers/rte_common_cpt.pmd.c /usr/local/bin/python3.8
> > > ../buildtools/pmdinfogen.py elf
> > > ar: fatal: Unrecognized archive format: Inappropriate file type or
> > > format
> > > Traceback (most recent call last):
> > >   File "../buildtools/gen-pmdinfo-cfile.py", line 13, in <module>
> > >     for name in subprocess.run([ar, "t", archive],
> > >     stdout=subprocess.PIPE,
> > >   File "/usr/local/lib/python3.8/subprocess.py", line 516, in run
> > >     raise CalledProcessError(retcode, process.args,
> > > subprocess.CalledProcessError: Command '['ar', 't',
> > > '/root/dpdk/builddir/drivers/libtmp_rte_common_cpt.a']' returned
> > > non-zero exit status 70.
> > >
> > > > A clean build of mine on FreeBSD with meson 0.61.1 didn't seem to
> > > > flag up any problems and I'd like to reproduce the issue to verify the fix.
> > > I'm guessing you're refering to the port of DPDK here.
> > > If not I am very interested to hear how you go about this.
> > >
> >
> > I tested with latest DPDK on a FreeBSD machine also, not using the BSD
> > ports version. Unfortunately it wasn't a clean install, but still a fairly
> > new one. I updated the BSD pkg config to use "latest" rather than
> > "quarterly" snapshot and then ran an "pkg upgrade". This gave me meson
> > 0.61.1, and updated other packages too. Build of DPDK then ran cleanly.
> >
> > I wonder if the version of binutils or some other package might be the
> > difference. The version I have is "GNU ar (GNU Binutils) 2.37". What
> > version of binutils is installed on your system?
> My version of binutils is 2.37_2,1, so that is the same.
> However, I think you're onto something here. When I run "ar --version" I
> get "BSD ar 1.1.0 - libarchive 3.5.1".
> The problem my patch aimed to solve was 'BSD ar' behaving differently
> than 'GNU ar'. So if you somehow got the 'ar' command to invoke 'GNU
> ar' on your system, maybe I just need to do the same.

Good point, I had missed that. BSD ar is in /usr/bin and GNU ar is
installed by binutils in /usr/local/bin/ar.

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

* Re: [PATCH] build: fix build on FreeBSD with Meson 0.61.1
  2022-02-15 15:34         ` Bruce Richardson
@ 2022-03-07 16:43           ` Thomas Monjalon
  2022-03-07 16:52             ` Bruce Richardson
  0 siblings, 1 reply; 10+ messages in thread
From: Thomas Monjalon @ 2022-03-07 16:43 UTC (permalink / raw)
  To: Karl Bonde Torp; +Cc: dev, Bruce Richardson

15/02/2022 16:34, Bruce Richardson:
> On Tue, Feb 15, 2022 at 02:50:48PM +0100, Karl Bonde Torp wrote:
> > On Tue, 15 Feb 2022 at 12:27, Bruce Richardson
> > <bruce.richardson@intel.com> wrote:
> > >
> > > On Tue, Feb 15, 2022 at 12:07:55PM +0100, Karl Bonde Torp wrote:
> > > > On Mon, 14 Feb 2022 at 14:48, Bruce Richardson
> > > > <bruce.richardson@intel.com> wrote:
> > > > >
> > > > > On Mon, Feb 14, 2022 at 12:43:13PM +0100, Karl Bonde Torp wrote:
> > > > > > When building with Meson 0.61.1 on FreeBSD some archives become
> > > > > > corrupted. This can be avoided by using 'llvm-ar' instead of 'ar'.
> > > > > >
> > > > > > Signed-off-by: Karl Bonde Torp <k.torp@samsung.com>
> > > > > > ---
> > > > >
> > > > > Can you perhaps provide some instructions or more details as to
> > > > > how/when you see this issue?
> > > >
> > > > Some background info:
> > > > I'm working on xNVMe and that depends on SPDK which in turn depends
> > > > on DPDK. These are includes as subprojects on github which is why the
> > > > FreeBSD port of DPDK is not an option for me.
> > > >
> > > > The steps I took to reproduce the issue are listed below, this assumes
> > > > a clean img of FreeBSD 13:
> > > > (I know some of them may be obvious, but I tried to avoid ambiguity)
> > > >
> > > > * install git and the pkg manager:
> > > > pkg install git
> > > > * get kernel source:
> > > > git clone https://git.freebsd.org/src.git /usr/src
> > > > * get ports:
> > > > git clone https://git.freebsd.org/ports.git /usr/ports
> > > > * install dependencies (except meson) with pkg:
> > > > pkg install py38-pyelftools ninja pkgconf binutils
> > > > * build meson 0.61.1 from port:
> > > > cd /usr/ports/devel/meson/ && make install clean
> > > > * clone dpdk repo:
> > > > git clone https://github.com/DPDK/dpdk.git
> > > > * inside dpdk folder run:
> > > > meson builddir && meson compile -C builddir
> > > > * encounter error:
> > > > [466/1915] Generating drivers/rte_common_cpt.pmd.c with a custom
> > > > command
> > > > FAILED: drivers/rte_common_cpt.pmd.c
> > > > /usr/local/bin/python3.8 ../buildtools/gen-pmdinfo-cfile.py
> > > > /root/dpdk/builddir/buildtools ar
> > > > /root/dpdk/builddir/drivers/libtmp_rte_common_cpt.a
> > > > drivers/rte_common_cpt.pmd.c /usr/local/bin/python3.8
> > > > ../buildtools/pmdinfogen.py elf
> > > > ar: fatal: Unrecognized archive format: Inappropriate file type or
> > > > format
> > > > Traceback (most recent call last):
> > > >   File "../buildtools/gen-pmdinfo-cfile.py", line 13, in <module>
> > > >     for name in subprocess.run([ar, "t", archive],
> > > >     stdout=subprocess.PIPE,
> > > >   File "/usr/local/lib/python3.8/subprocess.py", line 516, in run
> > > >     raise CalledProcessError(retcode, process.args,
> > > > subprocess.CalledProcessError: Command '['ar', 't',
> > > > '/root/dpdk/builddir/drivers/libtmp_rte_common_cpt.a']' returned
> > > > non-zero exit status 70.
> > > >
> > > > > A clean build of mine on FreeBSD with meson 0.61.1 didn't seem to
> > > > > flag up any problems and I'd like to reproduce the issue to verify the fix.
> > > > I'm guessing you're refering to the port of DPDK here.
> > > > If not I am very interested to hear how you go about this.
> > > >
> > >
> > > I tested with latest DPDK on a FreeBSD machine also, not using the BSD
> > > ports version. Unfortunately it wasn't a clean install, but still a fairly
> > > new one. I updated the BSD pkg config to use "latest" rather than
> > > "quarterly" snapshot and then ran an "pkg upgrade". This gave me meson
> > > 0.61.1, and updated other packages too. Build of DPDK then ran cleanly.
> > >
> > > I wonder if the version of binutils or some other package might be the
> > > difference. The version I have is "GNU ar (GNU Binutils) 2.37". What
> > > version of binutils is installed on your system?
> > My version of binutils is 2.37_2,1, so that is the same.
> > However, I think you're onto something here. When I run "ar --version" I
> > get "BSD ar 1.1.0 - libarchive 3.5.1".
> > The problem my patch aimed to solve was 'BSD ar' behaving differently
> > than 'GNU ar'. So if you somehow got the 'ar' command to invoke 'GNU
> > ar' on your system, maybe I just need to do the same.
> 
> Good point, I had missed that. BSD ar is in /usr/bin and GNU ar is
> installed by binutils in /usr/local/bin/ar.

I'm confused.
Should we apply this patch as is?




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

* Re: [PATCH] build: fix build on FreeBSD with Meson 0.61.1
  2022-03-07 16:43           ` Thomas Monjalon
@ 2022-03-07 16:52             ` Bruce Richardson
  0 siblings, 0 replies; 10+ messages in thread
From: Bruce Richardson @ 2022-03-07 16:52 UTC (permalink / raw)
  To: Thomas Monjalon; +Cc: Karl Bonde Torp, dev

On Mon, Mar 07, 2022 at 05:43:51PM +0100, Thomas Monjalon wrote:
> 15/02/2022 16:34, Bruce Richardson:
> > On Tue, Feb 15, 2022 at 02:50:48PM +0100, Karl Bonde Torp wrote:
> > > On Tue, 15 Feb 2022 at 12:27, Bruce Richardson
> > > <bruce.richardson@intel.com> wrote:
> > > >
> > > > On Tue, Feb 15, 2022 at 12:07:55PM +0100, Karl Bonde Torp wrote:
> > > > > On Mon, 14 Feb 2022 at 14:48, Bruce Richardson
> > > > > <bruce.richardson@intel.com> wrote:
> > > > > >
> > > > > > On Mon, Feb 14, 2022 at 12:43:13PM +0100, Karl Bonde Torp wrote:
> > > > > > > When building with Meson 0.61.1 on FreeBSD some archives become
> > > > > > > corrupted. This can be avoided by using 'llvm-ar' instead of 'ar'.
> > > > > > >
> > > > > > > Signed-off-by: Karl Bonde Torp <k.torp@samsung.com>
> > > > > > > ---
> > > > > >
> > > > > > Can you perhaps provide some instructions or more details as to
> > > > > > how/when you see this issue?
> > > > >
> > > > > Some background info:
> > > > > I'm working on xNVMe and that depends on SPDK which in turn depends
> > > > > on DPDK. These are includes as subprojects on github which is why the
> > > > > FreeBSD port of DPDK is not an option for me.
> > > > >
> > > > > The steps I took to reproduce the issue are listed below, this assumes
> > > > > a clean img of FreeBSD 13:
> > > > > (I know some of them may be obvious, but I tried to avoid ambiguity)
> > > > >
> > > > > * install git and the pkg manager:
> > > > > pkg install git
> > > > > * get kernel source:
> > > > > git clone https://git.freebsd.org/src.git /usr/src
> > > > > * get ports:
> > > > > git clone https://git.freebsd.org/ports.git /usr/ports
> > > > > * install dependencies (except meson) with pkg:
> > > > > pkg install py38-pyelftools ninja pkgconf binutils
> > > > > * build meson 0.61.1 from port:
> > > > > cd /usr/ports/devel/meson/ && make install clean
> > > > > * clone dpdk repo:
> > > > > git clone https://github.com/DPDK/dpdk.git
> > > > > * inside dpdk folder run:
> > > > > meson builddir && meson compile -C builddir
> > > > > * encounter error:
> > > > > [466/1915] Generating drivers/rte_common_cpt.pmd.c with a custom
> > > > > command
> > > > > FAILED: drivers/rte_common_cpt.pmd.c
> > > > > /usr/local/bin/python3.8 ../buildtools/gen-pmdinfo-cfile.py
> > > > > /root/dpdk/builddir/buildtools ar
> > > > > /root/dpdk/builddir/drivers/libtmp_rte_common_cpt.a
> > > > > drivers/rte_common_cpt.pmd.c /usr/local/bin/python3.8
> > > > > ../buildtools/pmdinfogen.py elf
> > > > > ar: fatal: Unrecognized archive format: Inappropriate file type or
> > > > > format
> > > > > Traceback (most recent call last):
> > > > >   File "../buildtools/gen-pmdinfo-cfile.py", line 13, in <module>
> > > > >     for name in subprocess.run([ar, "t", archive],
> > > > >     stdout=subprocess.PIPE,
> > > > >   File "/usr/local/lib/python3.8/subprocess.py", line 516, in run
> > > > >     raise CalledProcessError(retcode, process.args,
> > > > > subprocess.CalledProcessError: Command '['ar', 't',
> > > > > '/root/dpdk/builddir/drivers/libtmp_rte_common_cpt.a']' returned
> > > > > non-zero exit status 70.
> > > > >
> > > > > > A clean build of mine on FreeBSD with meson 0.61.1 didn't seem to
> > > > > > flag up any problems and I'd like to reproduce the issue to verify the fix.
> > > > > I'm guessing you're refering to the port of DPDK here.
> > > > > If not I am very interested to hear how you go about this.
> > > > >
> > > >
> > > > I tested with latest DPDK on a FreeBSD machine also, not using the BSD
> > > > ports version. Unfortunately it wasn't a clean install, but still a fairly
> > > > new one. I updated the BSD pkg config to use "latest" rather than
> > > > "quarterly" snapshot and then ran an "pkg upgrade". This gave me meson
> > > > 0.61.1, and updated other packages too. Build of DPDK then ran cleanly.
> > > >
> > > > I wonder if the version of binutils or some other package might be the
> > > > difference. The version I have is "GNU ar (GNU Binutils) 2.37". What
> > > > version of binutils is installed on your system?
> > > My version of binutils is 2.37_2,1, so that is the same.
> > > However, I think you're onto something here. When I run "ar --version" I
> > > get "BSD ar 1.1.0 - libarchive 3.5.1".
> > > The problem my patch aimed to solve was 'BSD ar' behaving differently
> > > than 'GNU ar'. So if you somehow got the 'ar' command to invoke 'GNU
> > > ar' on your system, maybe I just need to do the same.
> > 
> > Good point, I had missed that. BSD ar is in /usr/bin and GNU ar is
> > installed by binutils in /usr/local/bin/ar.
> 
> I'm confused.
> Should we apply this patch as is?
> 
A better version would select llvm-ar or binutils ar based off the
compiler on FreeBSD, but I think this patch is ok to apply as-is, as
llvm-ar should be able to work fine with the files created by binutils ar
even if gcc is the compiler.

Really, the main gap in all this is that meson does not provide a function
to return the static linker in use (though it has one for the dynamic
linker).

/Bruce

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

* Re: [PATCH] build: fix build on FreeBSD with Meson 0.61.1
  2022-02-15 15:31 ` Bruce Richardson
@ 2022-03-08 14:39   ` Thomas Monjalon
  0 siblings, 0 replies; 10+ messages in thread
From: Thomas Monjalon @ 2022-03-08 14:39 UTC (permalink / raw)
  To: Karl Bonde Torp, Karl Bonde Torp; +Cc: dev, Bruce Richardson

15/02/2022 16:31, Bruce Richardson:
> On Mon, Feb 14, 2022 at 12:43:13PM +0100, Karl Bonde Torp wrote:
> > When building with Meson 0.61.1 on FreeBSD some archives become
> > corrupted. This can be avoided by using 'llvm-ar' instead of 'ar'.
> > 
> > Signed-off-by: Karl Bonde Torp <k.torp@samsung.com>
> > ---
> >  buildtools/meson.build | 3 +++
> >  1 file changed, 3 insertions(+)
> > 
> > diff --git a/buildtools/meson.build b/buildtools/meson.build
> > index 400b88f251..e1c600e40f 100644
> > --- a/buildtools/meson.build
> > +++ b/buildtools/meson.build
> > @@ -31,6 +31,9 @@ if host_machine.system() == 'windows'
> >          pmdinfo += 'llvm-ar'
> >      endif
> >      pmdinfogen += 'coff'
> > +elif host_machine.system() == 'freebsd'
> > +    pmdinfo += 'llvm-ar'
> > +    pmdinfogen += 'elf'
> >  else
> >      pmdinfo += 'ar'
> >      pmdinfogen += 'elf'
> 
> Based off the instructions you posted later in the thread, I've reproduced
> the issue - and then done a little extra investigation. Here is my
> understanding:
> 
> * By default on FreeBSD the linking is being done by llvm-ar
> * The resulting libraries are being linked as thin archives and "ar" binary
>   does not seem to be able to process them.
> * When building with CC=gcc on FreeBSD, "ar" is used as a linker, and the
>   resulting archives are regular .a files.
> * On Linux, whether building with clang or gcc, "ar" seems to be used as
>   linker.
> 
> The ideal situation here would be if we could use meson to report itself
> what the static linker in use is, but unfortunately while we can query the
> dynamic linker using "meson.compiler().get_linker_id()", there doesn't seem
> to be an equivalent for the static linker. Therefore, the only option seems
> to be a fix as here. Only question remains as to whether we want to only
> use llvm-ar for clang builds on FreeBSD or use if for all builds on FreeBSD.
> I'm not sure it makes much difference either way, but I'd tend towards
> limiting the use of llvm-ar to only clang builds.
> 
> With or without this suggested change,
> 
> Acked-by: Bruce Richardson <bruce.richardson@intel.com>

Applied, thanks.



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

end of thread, other threads:[~2022-03-08 14:39 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-02-14 11:43 [PATCH] build: fix build on FreeBSD with Meson 0.61.1 Karl Bonde Torp
2022-02-14 13:48 ` Bruce Richardson
2022-02-15 11:07   ` Karl Bonde Torp
2022-02-15 11:27     ` Bruce Richardson
2022-02-15 13:50       ` Karl Bonde Torp
2022-02-15 15:34         ` Bruce Richardson
2022-03-07 16:43           ` Thomas Monjalon
2022-03-07 16:52             ` Bruce Richardson
2022-02-15 15:31 ` Bruce Richardson
2022-03-08 14:39   ` Thomas Monjalon

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).