config: add 32-bit cross-compilation x86 target

Message ID 20240904135939.329324-1-bruce.richardson@intel.com (mailing list archive)
State Superseded
Delegated to: Thomas Monjalon
Headers
Series config: add 32-bit cross-compilation x86 target |

Checks

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

Commit Message

Bruce Richardson Sept. 4, 2024, 1:57 p.m. UTC
To simplify building 32-bit binaries on 64-bit system, we can supply a
cross-compilation file which provides the relevant compiler flags and
settings needed - '-m32' compile/link flag, and appropriate
PKG_CONFIG_LIBDIR value. This latter setting will depend upon the layout
format of the particular OS/distro in use, so initially add a cross file
with paths set for Debian or Ubuntu systems.

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

The generation of 32-bit cross-files for other distros is left as an
exercise for the reader! I suspect that for Fedora/RHEL and Arch
variants that only the "pkg_config_libdir" and "libdir" setting should
be adjusted. However, I don't currently have a machine set up to test
that assumption, so getting the ball rolling for now with just this
patch to get feedback.

---

 config/x86/cross-debian-32bit | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)
 create mode 100644 config/x86/cross-debian-32bit
  

Comments

Vladimir Medvedkin Sept. 6, 2024, 3:34 p.m. UTC | #1
Acked-by: Vladimir Medvedkin <vladimir.medvedkin@intel.com>

On 04/09/2024 14:57, Bruce Richardson wrote:
> To simplify building 32-bit binaries on 64-bit system, we can supply a
> cross-compilation file which provides the relevant compiler flags and
> settings needed - '-m32' compile/link flag, and appropriate
> PKG_CONFIG_LIBDIR value. This latter setting will depend upon the layout
> format of the particular OS/distro in use, so initially add a cross file
> with paths set for Debian or Ubuntu systems.
>
> Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
> ---
>
> The generation of 32-bit cross-files for other distros is left as an
> exercise for the reader! I suspect that for Fedora/RHEL and Arch
> variants that only the "pkg_config_libdir" and "libdir" setting should
> be adjusted. However, I don't currently have a machine set up to test
> that assumption, so getting the ball rolling for now with just this
> patch to get feedback.
>
> ---
>
>   config/x86/cross-debian-32bit | 22 ++++++++++++++++++++++
>   1 file changed, 22 insertions(+)
>   create mode 100644 config/x86/cross-debian-32bit
>
> diff --git a/config/x86/cross-debian-32bit b/config/x86/cross-debian-32bit
> new file mode 100644
> index 0000000000..2f6e4714cb
> --- /dev/null
> +++ b/config/x86/cross-debian-32bit
> @@ -0,0 +1,22 @@
> +[binaries]
> +c = 'cc'
> +cpp = 'c++'
> +ar = 'ar'
> +strip = 'strip'
> +pkg-config = 'pkg-config'
> +
> +[host_machine]
> +system = 'linux'
> +cpu_family = 'x86'
> +cpu = 'native'
> +endian = 'little'
> +
> +[properties]
> +pkg_config_libdir = '/usr/lib/i386-linux-gnu/pkgconfig'
> +
> +[built-in options]
> +c_args = '-m32'
> +c_link_args = '-m32'
> +cpp_args = '-m32'
> +cpp_link_args = '-m32'
> +libdir = 'lib/i386-linux-gnu'
  
David Marchand Sept. 19, 2024, 7:44 a.m. UTC | #2
On Fri, Sep 6, 2024 at 6:13 PM Bruce Richardson
<bruce.richardson@intel.com> wrote:
>
> To make it easier to build and test DPDK on 32-bit x86 add a set of
> cross-compile ini files for a number of common linux distributions.
> This avoids the user having to remember strange meson incantations
> with '-m32' in various args values and with the PKG_CONFIG_LIBDIR
> overridden in the environment.
>
> Bruce Richardson (4):
>   config: add 32-bit x86 debian cross-compilation file
>   config: add fedora 32-bit x86 cross-compile file
>   config: add arch 32-bit cross-compilation file
>   devtools/test-meson-builds: use cross files for 32bit build
>
>  config/x86/cross-32bit-arch.ini   | 22 ++++++++++++++++++++++
>  config/x86/cross-32bit-debian.ini | 22 ++++++++++++++++++++++
>  config/x86/cross-32bit-fedora.ini | 22 ++++++++++++++++++++++
>  devtools/test-meson-builds.sh     | 13 +++++--------
>  4 files changed, 71 insertions(+), 8 deletions(-)
>  create mode 100644 config/x86/cross-32bit-arch.ini
>  create mode 100644 config/x86/cross-32bit-debian.ini
>  create mode 100644 config/x86/cross-32bit-fedora.ini

I tried to convert the GHA script to use the debian cross file
introduced in the series:

diff --git a/.ci/linux-build.sh b/.ci/linux-build.sh
index 15ed51e4c1..cec8742ed1 100755
--- a/.ci/linux-build.sh
+++ b/.ci/linux-build.sh
@@ -54,6 +54,10 @@ if [ "$AARCH64" = "true" ]; then
     fi
 fi

+if [ "$BUILD_32BIT" = "true" ]; then
+    cross_file=config/x86/cross-32bit-debian.ini
+fi
+
 if [ "$MINGW" = "true" ]; then
     cross_file=config/x86/cross-mingw
 fi
@@ -76,12 +80,6 @@ if [ "$BUILD_DOCS" = "true" ]; then
     OPTS="$OPTS -Denable_docs=true"
 fi

-if [ "$BUILD_32BIT" = "true" ]; then
-    OPTS="$OPTS -Dc_args=-m32 -Dc_link_args=-m32"
-    OPTS="$OPTS -Dcpp_args=-m32 -Dcpp_link_args=-m32"
-    export PKG_CONFIG_LIBDIR="/usr/lib32/pkgconfig"
-fi
-
 if [ "$MINGW" = "true" ]; then
     OPTS="$OPTS -Dexamples=helloworld"
 elif [ "$DEF_LIB" = "static" ]; then

I was then surprised to read the result:
...
2024-09-19T07:22:12.6485260Z Checking for size of "void *" : 8
2024-09-19T07:22:12.6485592Z Checking for size of "void *" : 8
...


*scratch* *scratch*
So I retested the series locally on my f39 (the series seemed ok so
far) but I downgraded meson to 0.53.2 (which is the version forced in
GHA) and now I observe the same issue.

I suspect something changed in the cross file handling in more recent
meson versions.
Likely, the c_args= or [build-in options] part is not read.

Am I doing something wrong?
  
Bruce Richardson Sept. 19, 2024, 7:52 a.m. UTC | #3
On Thu, Sep 19, 2024 at 09:44:18AM +0200, David Marchand wrote:
> On Fri, Sep 6, 2024 at 6:13 PM Bruce Richardson
> <bruce.richardson@intel.com> wrote:
> >
> > To make it easier to build and test DPDK on 32-bit x86 add a set of
> > cross-compile ini files for a number of common linux distributions.
> > This avoids the user having to remember strange meson incantations
> > with '-m32' in various args values and with the PKG_CONFIG_LIBDIR
> > overridden in the environment.
> >
> > Bruce Richardson (4):
> >   config: add 32-bit x86 debian cross-compilation file
> >   config: add fedora 32-bit x86 cross-compile file
> >   config: add arch 32-bit cross-compilation file
> >   devtools/test-meson-builds: use cross files for 32bit build
> >
> >  config/x86/cross-32bit-arch.ini   | 22 ++++++++++++++++++++++
> >  config/x86/cross-32bit-debian.ini | 22 ++++++++++++++++++++++
> >  config/x86/cross-32bit-fedora.ini | 22 ++++++++++++++++++++++
> >  devtools/test-meson-builds.sh     | 13 +++++--------
> >  4 files changed, 71 insertions(+), 8 deletions(-)
> >  create mode 100644 config/x86/cross-32bit-arch.ini
> >  create mode 100644 config/x86/cross-32bit-debian.ini
> >  create mode 100644 config/x86/cross-32bit-fedora.ini
> 
> I tried to convert the GHA script to use the debian cross file
> introduced in the series:
> 
> diff --git a/.ci/linux-build.sh b/.ci/linux-build.sh
> index 15ed51e4c1..cec8742ed1 100755
> --- a/.ci/linux-build.sh
> +++ b/.ci/linux-build.sh
> @@ -54,6 +54,10 @@ if [ "$AARCH64" = "true" ]; then
>      fi
>  fi
> 
> +if [ "$BUILD_32BIT" = "true" ]; then
> +    cross_file=config/x86/cross-32bit-debian.ini
> +fi
> +
>  if [ "$MINGW" = "true" ]; then
>      cross_file=config/x86/cross-mingw
>  fi
> @@ -76,12 +80,6 @@ if [ "$BUILD_DOCS" = "true" ]; then
>      OPTS="$OPTS -Denable_docs=true"
>  fi
> 
> -if [ "$BUILD_32BIT" = "true" ]; then
> -    OPTS="$OPTS -Dc_args=-m32 -Dc_link_args=-m32"
> -    OPTS="$OPTS -Dcpp_args=-m32 -Dcpp_link_args=-m32"
> -    export PKG_CONFIG_LIBDIR="/usr/lib32/pkgconfig"
> -fi
> -
>  if [ "$MINGW" = "true" ]; then
>      OPTS="$OPTS -Dexamples=helloworld"
>  elif [ "$DEF_LIB" = "static" ]; then
> 
> I was then surprised to read the result:
> ...
> 2024-09-19T07:22:12.6485260Z Checking for size of "void *" : 8
> 2024-09-19T07:22:12.6485592Z Checking for size of "void *" : 8
> ...
> 
> 
> *scratch* *scratch*
> So I retested the series locally on my f39 (the series seemed ok so
> far) but I downgraded meson to 0.53.2 (which is the version forced in
> GHA) and now I observe the same issue.
> 
> I suspect something changed in the cross file handling in more recent
> meson versions.
> Likely, the c_args= or [build-in options] part is not read.
> 
> Am I doing something wrong?
> 

I don't think you are doing anything wrong. Let me check for cross-file
handling in the meson docs. On my side, I've been using this cross-file for
my test builds for the last couple of weeks without issues. I'm using
latest meson, but it's been much more reliable for me than the previous
method, which required me to occasionally delete the build-32b directory.

/Bruce
  
Bruce Richardson Sept. 19, 2024, 8:02 a.m. UTC | #4
On Thu, Sep 19, 2024 at 09:44:18AM +0200, David Marchand wrote:
> On Fri, Sep 6, 2024 at 6:13 PM Bruce Richardson
> <bruce.richardson@intel.com> wrote:
> >
> > To make it easier to build and test DPDK on 32-bit x86 add a set of
> > cross-compile ini files for a number of common linux distributions.
> > This avoids the user having to remember strange meson incantations
> > with '-m32' in various args values and with the PKG_CONFIG_LIBDIR
> > overridden in the environment.
> >
> > Bruce Richardson (4):
> >   config: add 32-bit x86 debian cross-compilation file
> >   config: add fedora 32-bit x86 cross-compile file
> >   config: add arch 32-bit cross-compilation file
> >   devtools/test-meson-builds: use cross files for 32bit build
> >
> >  config/x86/cross-32bit-arch.ini   | 22 ++++++++++++++++++++++
> >  config/x86/cross-32bit-debian.ini | 22 ++++++++++++++++++++++
> >  config/x86/cross-32bit-fedora.ini | 22 ++++++++++++++++++++++
> >  devtools/test-meson-builds.sh     | 13 +++++--------
> >  4 files changed, 71 insertions(+), 8 deletions(-)
> >  create mode 100644 config/x86/cross-32bit-arch.ini
> >  create mode 100644 config/x86/cross-32bit-debian.ini
> >  create mode 100644 config/x86/cross-32bit-fedora.ini
> 
> I tried to convert the GHA script to use the debian cross file
> introduced in the series:
> 
> diff --git a/.ci/linux-build.sh b/.ci/linux-build.sh
> index 15ed51e4c1..cec8742ed1 100755
> --- a/.ci/linux-build.sh
> +++ b/.ci/linux-build.sh
> @@ -54,6 +54,10 @@ if [ "$AARCH64" = "true" ]; then
>      fi
>  fi
> 
> +if [ "$BUILD_32BIT" = "true" ]; then
> +    cross_file=config/x86/cross-32bit-debian.ini
> +fi
> +
>  if [ "$MINGW" = "true" ]; then
>      cross_file=config/x86/cross-mingw
>  fi
> @@ -76,12 +80,6 @@ if [ "$BUILD_DOCS" = "true" ]; then
>      OPTS="$OPTS -Denable_docs=true"
>  fi
> 
> -if [ "$BUILD_32BIT" = "true" ]; then
> -    OPTS="$OPTS -Dc_args=-m32 -Dc_link_args=-m32"
> -    OPTS="$OPTS -Dcpp_args=-m32 -Dcpp_link_args=-m32"
> -    export PKG_CONFIG_LIBDIR="/usr/lib32/pkgconfig"
> -fi
> -
>  if [ "$MINGW" = "true" ]; then
>      OPTS="$OPTS -Dexamples=helloworld"
>  elif [ "$DEF_LIB" = "static" ]; then
> 
> I was then surprised to read the result:
> ...
> 2024-09-19T07:22:12.6485260Z Checking for size of "void *" : 8
> 2024-09-19T07:22:12.6485592Z Checking for size of "void *" : 8
> ...
> 
> 
> *scratch* *scratch*
> So I retested the series locally on my f39 (the series seemed ok so
> far) but I downgraded meson to 0.53.2 (which is the version forced in
> GHA) and now I observe the same issue.
> 
> I suspect something changed in the cross file handling in more recent
> meson versions.
> Likely, the c_args= or [build-in options] part is not read.
> 
> Am I doing something wrong?
> 
From the docs on cross-files [1], it appears that significant changes to
the cross-file handling was done in 0.56 release. That may be the cause.
I'll have to try some testing myself.

Overall, I think we haven't increased our minimum meson version in some
time. Maybe it's time to consider doing so in this release or the next one?
Need to look through release notes to see how far forward to jump to see
what extra features might be useful for us to leverage.

/Bruce

[1] https://mesonbuild.com/Machine-files.html
  
David Marchand Sept. 19, 2024, 8:08 a.m. UTC | #5
On Thu, Sep 19, 2024 at 10:02 AM Bruce Richardson
<bruce.richardson@intel.com> wrote:
> Overall, I think we haven't increased our minimum meson version in some
> time. Maybe it's time to consider doing so in this release or the next one?
> Need to look through release notes to see how far forward to jump to see
> what extra features might be useful for us to leverage.

That's an option, just be careful that there is some tie with python
versions iirc.
  

Patch

diff --git a/config/x86/cross-debian-32bit b/config/x86/cross-debian-32bit
new file mode 100644
index 0000000000..2f6e4714cb
--- /dev/null
+++ b/config/x86/cross-debian-32bit
@@ -0,0 +1,22 @@ 
+[binaries]
+c = 'cc'
+cpp = 'c++'
+ar = 'ar'
+strip = 'strip'
+pkg-config = 'pkg-config'
+
+[host_machine]
+system = 'linux'
+cpu_family = 'x86'
+cpu = 'native'
+endian = 'little'
+
+[properties]
+pkg_config_libdir = '/usr/lib/i386-linux-gnu/pkgconfig'
+
+[built-in options]
+c_args = '-m32'
+c_link_args = '-m32'
+cpp_args = '-m32'
+cpp_link_args = '-m32'
+libdir = 'lib/i386-linux-gnu'