Skip to contentSkip to conversation

test-meson-builds: add a 32-bit build

PATCH Superseded Bruce Richardson 2 participants 12 messages Nov 5, 2020 – Nov 6, 2020 Arm/Amlogic Meson SoC support

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 test-meson-builds: add a 32-bit build

It's reasonably common for patches to have issues when built on 32-bits, so to prevent this, we can add a 32-bit build (if supported) to the "test-meson-builds.sh" script. The tricky bit is using a valid PKG_CONFIG_LIBDIR, so for now we use two common possibilities for where that should point to in order to get a successful build.

---
 devtools/test-meson-builds.sh | 13 +++++++++++++
 1 file changed, 13 insertions(+)
devtools/test-meson-builds.sh +13 -0
index a87de635a..02db73e98 100755
@@ -226,6 +226,19 @@ for f in $srcdir/config/ppc/ppc* ; do
 	build build-$(basename $f | cut -d'-' -f-2) $f $use_shared
 done
 
+# test a 32-bit build
+if echo "int main(void) { return 0; }" | cc -m32 -x c - -o /dev/null 2> /dev/null ; then
+	if [ -d "/usr/lib/i386-linux-gnu" ] ; then
+		# 32-bit pkgconfig on debian/ubuntu
+		export PKG_CONFIG_LIBDIR="/usr/lib/i386-linux-gnu/pkgconfig"
+	else
+		# 32-bit pkgconfig on RHEL/fedora (lib vs lib64)
+		export PKG_CONFIG_LIBDIR="/usr/lib/pkgconfig"
+	fi
+	build build-32-bit cc -Dc_args='-m32' -Dc_link_args='-m32'
+	unset PKG_CONFIG_LIBDIR
+fi
+
 # Test installation of the x86-default target, to be used for checking
 # the sample apps build using the pkg-config file for cflags and libs
 build_path=$(readlink -f $builds_dir/build-x86-default)
Signature · 1 line
2.25.1
#1 lore raw

05/11/2020 12:07, Bruce Richardson:

Quoted 7 lines

It's reasonably common for patches to have issues when built on 32-bits, so to prevent this, we can add a 32-bit build (if supported) to the "test-meson-builds.sh" script. The tricky bit is using a valid PKG_CONFIG_LIBDIR, so for now we use two common possibilities for where that should point to in order to get a successful build.

Thanks we really need such test.

Quoted 1 line

+if echo "int main(void) { return 0; }" | cc -m32 -x c - -o /dev/null 2> /dev/null ; then

I think a function would be cleaner, with -m32 passed as parameter.

devtools/test-meson-builds.sh for f in $srcdir/config/ppc/ppc* ; do · line 236

Quoted 6 lines
devtools/test-meson-builds.sh +6 -0
+	if [ -d "/usr/lib/i386-linux-gnu" ] ; then
+		# 32-bit pkgconfig on debian/ubuntu
+		export PKG_CONFIG_LIBDIR="/usr/lib/i386-linux-gnu/pkgconfig"
+	else
+		# 32-bit pkgconfig on RHEL/fedora (lib vs lib64)
+		export PKG_CONFIG_LIBDIR="/usr/lib/pkgconfig"

It is /usr/lib32 on my Arch Linux.

I would prefer avoiding export,
by assigning a local variable and use it below:

PKG_CONFIG_LIBDIR=libdir32 build build-32-bit ...

devtools/test-meson-builds.sh for f in $srcdir/config/ppc/ppc* ; do · line 238

Quoted 2 lines
devtools/test-meson-builds.sh +2 -0
+	fi
+	build build-32-bit cc -Dc_args='-m32' -Dc_link_args='-m32'

Or just "build-32" as directory name.

devtools/test-meson-builds.sh for f in $srcdir/config/ppc/ppc* ; do · line 239

Quoted 1 line
devtools/test-meson-builds.sh +1 -0
+	unset PKG_CONFIG_LIBDIR

No need of unset if not using export above.

Quoted 1 line

+fi

#2 lore raw
Quoted 29 lines · Thomas Monjalon

05/11/2020 12:07, Bruce Richardson:

Quoted 7 lines

It's reasonably common for patches to have issues when built on 32-bits, so to prevent this, we can add a 32-bit build (if supported) to the "test-meson-builds.sh" script. The tricky bit is using a valid PKG_CONFIG_LIBDIR, so for now we use two common possibilities for where that should point to in order to get a successful build.

Thanks we really need such test.

Quoted 1 line

+if echo "int main(void) { return 0; }" | cc -m32 -x c - -o /dev/null 2> /dev/null ; then

I think a function would be cleaner, with -m32 passed as parameter.

devtools/test-meson-builds.sh for f in $srcdir/config/ppc/ppc* ; do · line 236

Quoted 6 lines
devtools/test-meson-builds.sh +6 -0
+	if [ -d "/usr/lib/i386-linux-gnu" ] ; then
+		# 32-bit pkgconfig on debian/ubuntu
+		export PKG_CONFIG_LIBDIR="/usr/lib/i386-linux-gnu/pkgconfig"
+	else
+		# 32-bit pkgconfig on RHEL/fedora (lib vs lib64)
+		export PKG_CONFIG_LIBDIR="/usr/lib/pkgconfig"

It is /usr/lib32 on my Arch Linux.

I would prefer avoiding export,
by assigning a local variable and use it below:

PKG_CONFIG_LIBDIR=libdir32 build build-32-bit ...

Quoted 10 lines

devtools/test-meson-builds.sh for f in $srcdir/config/ppc/ppc* ; do · line 238

Quoted 2 lines
devtools/test-meson-builds.sh +2 -0
+	fi
+	build build-32-bit cc -Dc_args='-m32' -Dc_link_args='-m32'

Or just "build-32" as directory name.

devtools/test-meson-builds.sh for f in $srcdir/config/ppc/ppc* ; do · line 239

Quoted 1 line
devtools/test-meson-builds.sh +1 -0
+	unset PKG_CONFIG_LIBDIR

No need of unset if not using export above.

Quoted 1 line

+fi

Thanks for the quick review, I'll put together a v2 based on this feedback.

/Bruce

#3 lore raw

05/11/2020 12:21, Bruce Richardson:

Quoted 35 lines · Thomas Monjalon
Quoted 34 lines

05/11/2020 12:07, Bruce Richardson:

Quoted 7 lines

It's reasonably common for patches to have issues when built on 32-bits, so to prevent this, we can add a 32-bit build (if supported) to the "test-meson-builds.sh" script. The tricky bit is using a valid PKG_CONFIG_LIBDIR, so for now we use two common possibilities for where that should point to in order to get a successful build.

Thanks we really need such test.

Quoted 1 line

+if echo "int main(void) { return 0; }" | cc -m32 -x c - -o /dev/null 2> /dev/null ; then

I think a function would be cleaner, with -m32 passed as parameter.

devtools/test-meson-builds.sh for f in $srcdir/config/ppc/ppc* ; do · line 236

Quoted 6 lines
devtools/test-meson-builds.sh +6 -0
+	if [ -d "/usr/lib/i386-linux-gnu" ] ; then
+		# 32-bit pkgconfig on debian/ubuntu
+		export PKG_CONFIG_LIBDIR="/usr/lib/i386-linux-gnu/pkgconfig"
+	else
+		# 32-bit pkgconfig on RHEL/fedora (lib vs lib64)
+		export PKG_CONFIG_LIBDIR="/usr/lib/pkgconfig"

It is /usr/lib32 on my Arch Linux.

I would prefer avoiding export,
by assigning a local variable and use it below:

PKG_CONFIG_LIBDIR=libdir32 build build-32-bit ...

devtools/test-meson-builds.sh for f in $srcdir/config/ppc/ppc* ; do · line 238

Quoted 2 lines
devtools/test-meson-builds.sh +2 -0
+	fi
+	build build-32-bit cc -Dc_args='-m32' -Dc_link_args='-m32'

Or just "build-32" as directory name.

Quoted 7 lines
Quoted 5 lines

devtools/test-meson-builds.sh for f in $srcdir/config/ppc/ppc* ; do · line 239

Quoted 1 line
devtools/test-meson-builds.sh +1 -0
+	unset PKG_CONFIG_LIBDIR

No need of unset if not using export above.

Quoted 1 line

+fi

Thanks for the quick review, I'll put together a v2 based on this feedback.

One more thing, the variable DPDK_TARGET should be set accordingly so the right configuration can be loaded. By default, I believe it will be x86_64-pc-linux-gnu. We need something with "32" or i686 on x86 so we can adjust the paths to the dependencies built for 32-bit.

#4 lore raw
In reply to Thomas Monjalon
Quoted 24 lines · Thomas Monjalon

05/11/2020 12:07, Bruce Richardson:

Quoted 7 lines

It's reasonably common for patches to have issues when built on 32-bits, so to prevent this, we can add a 32-bit build (if supported) to the "test-meson-builds.sh" script. The tricky bit is using a valid PKG_CONFIG_LIBDIR, so for now we use two common possibilities for where that should point to in order to get a successful build.

Thanks we really need such test.

Quoted 1 line

+if echo "int main(void) { return 0; }" | cc -m32 -x c - -o /dev/null 2> /dev/null ; then

I think a function would be cleaner, with -m32 passed as parameter.

devtools/test-meson-builds.sh for f in $srcdir/config/ppc/ppc* ; do · line 236

Quoted 6 lines
devtools/test-meson-builds.sh +6 -0
+	if [ -d "/usr/lib/i386-linux-gnu" ] ; then
+		# 32-bit pkgconfig on debian/ubuntu
+		export PKG_CONFIG_LIBDIR="/usr/lib/i386-linux-gnu/pkgconfig"
+	else
+		# 32-bit pkgconfig on RHEL/fedora (lib vs lib64)
+		export PKG_CONFIG_LIBDIR="/usr/lib/pkgconfig"

It is /usr/lib32 on my Arch Linux.

Quoted 5 lines

I would prefer avoiding export,
by assigning a local variable and use it below:

PKG_CONFIG_LIBDIR=libdir32 build build-32-bit ...

Not having the variable exported means that it does not seem to be passed through to the meson (and other) subprocesses. Therefore keeping the export as is in V2.

/Bruce

#5 lore raw

PATCH v2 1/1 test-meson-builds: add a 32-bit build

In reply to Bruce Richardson

It's reasonably common for patches to have issues when built on 32-bits, so to prevent this, we can add a 32-bit build (if supported) to the "test-meson-builds.sh" script. The tricky bit is using a valid PKG_CONFIG_LIBDIR, so for now we use two common possibilities for where that should point to in order to get a successful build.

---
V2: added separate flag checking function
added override of the DPDK_TARGET value
added /usr/lib32 as possible 32-bit libdir

---
 devtools/test-meson-builds.sh | 26 ++++++++++++++++++++++++++
 1 file changed, 26 insertions(+)
devtools/test-meson-builds.sh +26 -0
index a87de635a2..47786dcd69 100755
@@ -43,6 +43,11 @@ default_cppflags=$CPPFLAGS
 default_cflags=$CFLAGS
 default_ldflags=$LDFLAGS
 
+check_cc_flags () # <flag to check> <flag2> ...
+{
+	echo "int main(void) { return 0; }" | cc $@ -x c - -o /dev/null 2> /dev/null
+}
+
 load_env () # <target compiler>
 {
 	targetcc=$1
@@ -57,6 +62,10 @@ load_env () # <target compiler>
 	else # toolchain not yet in PATH: its name should be enough
 		DPDK_TARGET=$targetcc
 	fi
+	if [ -n "$DPDK_TARGET_OVERRIDE" ] ; then
+		DPDK_TARGET=$DPDK_TARGET_OVERRIDE
+	fi
+	echo "Using DPDK_TARGET $DPDK_TARGET"
 	# config input: $DPDK_TARGET
 	. $srcdir/devtools/load-devel-config
 	# config output: $DPDK_MESON_OPTIONS, $PATH, $PKG_CONFIG_PATH, etc
@@ -226,6 +235,23 @@ for f in $srcdir/config/ppc/ppc* ; do
 	build build-$(basename $f | cut -d'-' -f-2) $f $use_shared
 done
 
+# test a 32-bit build
+if check_cc_flags '-m32' ; then
+	if [ -d "/usr/lib/i386-linux-gnu" ] ; then
+		# 32-bit pkgconfig on debian/ubuntu
+		export PKG_CONFIG_LIBDIR="/usr/lib/i386-linux-gnu/pkgconfig"
+	elif [ -d "/usr/lib32" ] ; then
+		# 32-bit pkgconfig on arch
+		export PKG_CONFIG_LIBDIR="/usr/lib32/pkgconfig"
+	else
+		# 32-bit pkgconfig on RHEL/fedora (lib vs lib64)
+		export PKG_CONFIG_LIBDIR="/usr/lib/pkgconfig"
+	fi
+	DPDK_TARGET_OVERRIDE="i386-pc-linux-gnu" \
+		build build-32b cc -Dc_args='-m32' -Dc_link_args='-m32'
+	unset PKG_CONFIG_LIBDIR
+fi
+
 # Test installation of the x86-default target, to be used for checking
 # the sample apps build using the pkg-config file for cflags and libs
 build_path=$(readlink -f $builds_dir/build-x86-default)
Signature · 1 line
2.25.1
#6 lore raw

05/11/2020 18:21, Bruce Richardson:

devtools/test-meson-builds.sh for f in $srcdir/config/ppc/ppc* ; do · line 251

Quoted 2 lines
devtools/test-meson-builds.sh +2 -0
+	DPDK_TARGET_OVERRIDE="i386-pc-linux-gnu" \
+		build build-32b cc -Dc_args='-m32' -Dc_link_args='-m32'

Surprinsingly, DPDK_TARGET_OVERRIDE is set in the global context, so it seems unset is required.

I will send a v3 with other details changed.

#7 lore raw
Quoted 9 lines · Thomas Monjalon

05/11/2020 18:21, Bruce Richardson:

devtools/test-meson-builds.sh for f in $srcdir/config/ppc/ppc* ; do · line 251

Quoted 2 lines
devtools/test-meson-builds.sh +2 -0
+	DPDK_TARGET_OVERRIDE="i386-pc-linux-gnu" \
+		build build-32b cc -Dc_args='-m32' -Dc_link_args='-m32'

Surprinsingly, DPDK_TARGET_OVERRIDE is set in the global context, so it seems unset is required.

I will send a v3 with other details changed.

Ok, thanks.

#8 lore raw

PATCH v3 1/1 devtools: test 32-bit build

In reply to Bruce Richardson

From: Bruce Richardson <[email protected]>

It's reasonably common for patches to have issues when built on 32-bits, so to prevent this, we can add a 32-bit build (if supported) to the "test-meson-builds.sh" script. The tricky bit is using a valid PKG_CONFIG_LIBDIR, so for now we use two common possibilities for where that should point to in order to get a successful build.

---
v3: unset override
move and rename override
split command in check_cc_flags
use check_cc_flags for x86 default build
v2: added separate flag checking function
added override of the DPDK_TARGET value
added /usr/lib32 as possible 32-bit libdir

---
 devtools/test-meson-builds.sh | 32 +++++++++++++++++++++++++++++---
 1 file changed, 29 insertions(+), 3 deletions(-)
devtools/test-meson-builds.sh +29 -3
index a87de635a2..ac76c2184b 100755
@@ -43,6 +43,12 @@ default_cppflags=$CPPFLAGS
 default_cflags=$CFLAGS
 default_ldflags=$LDFLAGS
 
+check_cc_flags () # <flag to check> <flag2> ...
+{
+	echo 'int main(void) { return 0; }' |
+	cc $@ -x c - -o /dev/null 2> /dev/null
+}
+
 load_env () # <target compiler>
 {
 	targetcc=$1
@@ -52,11 +58,14 @@ load_env () # <target compiler>
 	export CFLAGS=$default_cflags
 	export LDFLAGS=$default_ldflags
 	unset DPDK_MESON_OPTIONS
-	if command -v $targetcc >/dev/null 2>&1 ; then
+	if [ -n "$target_override" ] ; then
+		DPDK_TARGET=$target_override
+	elif command -v $targetcc >/dev/null 2>&1 ; then
 		DPDK_TARGET=$($targetcc -v 2>&1 | sed -n 's,^Target: ,,p')
 	else # toolchain not yet in PATH: its name should be enough
 		DPDK_TARGET=$targetcc
 	fi
+	echo "Using DPDK_TARGET $DPDK_TARGET"
 	# config input: $DPDK_TARGET
 	. $srcdir/devtools/load-devel-config
 	# config output: $DPDK_MESON_OPTIONS, $PATH, $PKG_CONFIG_PATH, etc
@@ -200,12 +209,29 @@ done
 # Set the install path for libraries to "lib" explicitly to prevent problems
 # with pkg-config prefixes if installed in "lib/x86_64-linux-gnu" later.
 default_machine='nehalem'
-ok=$(cc -march=$default_machine -E - < /dev/null > /dev/null 2>&1 || echo false)
-if [ "$ok" = "false" ] ; then
+if ! check_cc_flags "-march=$default_machine" ; then
 	default_machine='corei7'
 fi
 build build-x86-default cc -Dlibdir=lib -Dmachine=$default_machine $use_shared
 
+# 32-bit with default compiler
+if check_cc_flags '-m32' ; then
+	if [ -d '/usr/lib/i386-linux-gnu' ] ; then
+		# 32-bit pkgconfig on Debian/Ubuntu
+		export PKG_CONFIG_LIBDIR='/usr/lib/i386-linux-gnu/pkgconfig'
+	elif [ -d '/usr/lib32' ] ; then
+		# 32-bit pkgconfig on Arch
+		export PKG_CONFIG_LIBDIR='/usr/lib32/pkgconfig'
+	else
+		# 32-bit pkgconfig on RHEL/Fedora (lib vs lib64)
+		export PKG_CONFIG_LIBDIR='/usr/lib/pkgconfig'
+	fi
+	target_override='i386-pc-linux-gnu'
+	build build-32b cc -Dc_args='-m32' -Dc_link_args='-m32'
+	target_override=
+	unset PKG_CONFIG_LIBDIR
+fi
+
 # x86 MinGW
 build build-x86-mingw $srcdir/config/x86/cross-mingw -Dexamples=helloworld
 
Signature · 1 line
2.28.0
#9 lore raw

Re: [dpdk-dev] [PATCH v3 1/1] devtools: test 32-bit build

Quoted 27 lines · Thomas Monjalon

From: Bruce Richardson <[email protected]>

It's reasonably common for patches to have issues when built on 32-bits, so to prevent this, we can add a 32-bit build (if supported) to the "test-meson-builds.sh" script. The tricky bit is using a valid PKG_CONFIG_LIBDIR, so for now we use two common possibilities for where that should point to in order to get a successful build.

---
v3: unset override
move and rename override
split command in check_cc_flags
use check_cc_flags for x86 default build
v2: added separate flag checking function
added override of the DPDK_TARGET value
added /usr/lib32 as possible 32-bit libdir

---
 devtools/test-meson-builds.sh | 32 +++++++++++++++++++++++++++++---
 1 file changed, 29 insertions(+), 3 deletions(-)
devtools/test-meson-builds.sh +0 -0
index a87de635a2..ac76c2184b 100755

devtools/test-meson-builds.sh default_cppflags=$CPPFLAGS · line 49

Quoted 7 lines
devtools/test-meson-builds.sh +4 -0
@@ -43,6 +43,12 @@ default_cppflags=$CPPFLAGS
 default_cflags=$CFLAGS
 default_ldflags=$LDFLAGS
 
+check_cc_flags () # <flag to check> <flag2> ...
+{
+	echo 'int main(void) { return 0; }' |
+	cc $@ -x c - -o /dev/null 2> /dev/null

Minor nit, as a continuation of the previous line, I think this should be further indented.

Otherwise all looks good to me. Thanks for the updated changes.

/Bruce

#10 lore raw

Re: [dpdk-dev] [PATCH v3 1/1] devtools: test 32-bit build

06/11/2020 18:01, Bruce Richardson:

Quoted 31 lines · Thomas Monjalon
Quoted 30 lines

From: Bruce Richardson <[email protected]>

It's reasonably common for patches to have issues when built on 32-bits, so to prevent this, we can add a 32-bit build (if supported) to the "test-meson-builds.sh" script. The tricky bit is using a valid PKG_CONFIG_LIBDIR, so for now we use two common possibilities for where that should point to in order to get a successful build.

---
v3: unset override
move and rename override
split command in check_cc_flags
use check_cc_flags for x86 default build
v2: added separate flag checking function
added override of the DPDK_TARGET value
added /usr/lib32 as possible 32-bit libdir

---
 devtools/test-meson-builds.sh | 32 +++++++++++++++++++++++++++++---
 1 file changed, 29 insertions(+), 3 deletions(-)
devtools/test-meson-builds.sh +0 -0
index a87de635a2..ac76c2184b 100755
@@ -43,6 +43,12 @@ default_cppflags=$CPPFLAGS
 default_cflags=$CFLAGS
 default_ldflags=$LDFLAGS
 
Quoted 7 lines

devtools/test-meson-builds.sh default_cppflags=$CPPFLAGS · line 49

Quoted 4 lines
devtools/test-meson-builds.sh +4 -0
+check_cc_flags () # <flag to check> <flag2> ...
+{
+	echo 'int main(void) { return 0; }' |
+	cc $@ -x c - -o /dev/null 2> /dev/null

Minor nit, as a continuation of the previous line, I think this should be further indented.

In general I keep piped commands at the same level. This is a matter of taste,
but I can see other piped commands indented in this file, so I will indent this one as well.

Quoted 1 line

Otherwise all looks good to me. Thanks for the updated changes.

Then I will merge it with above change. I guess we won't get more reviews.

#11 lore raw

Re: [dpdk-dev] [PATCH v3 1/1] devtools: test 32-bit build

06/11/2020 18:11, Thomas Monjalon:

Quoted 40 lines

06/11/2020 18:01, Bruce Richardson:

Quoted 31 lines · Thomas Monjalon
Quoted 30 lines

From: Bruce Richardson <[email protected]>

It's reasonably common for patches to have issues when built on 32-bits, so to prevent this, we can add a 32-bit build (if supported) to the "test-meson-builds.sh" script. The tricky bit is using a valid PKG_CONFIG_LIBDIR, so for now we use two common possibilities for where that should point to in order to get a successful build.

---
v3: unset override
move and rename override
split command in check_cc_flags
use check_cc_flags for x86 default build
v2: added separate flag checking function
added override of the DPDK_TARGET value
added /usr/lib32 as possible 32-bit libdir

---
 devtools/test-meson-builds.sh | 32 +++++++++++++++++++++++++++++---
 1 file changed, 29 insertions(+), 3 deletions(-)
devtools/test-meson-builds.sh +0 -0
index a87de635a2..ac76c2184b 100755
@@ -43,6 +43,12 @@ default_cppflags=$CPPFLAGS
 default_cflags=$CFLAGS
 default_ldflags=$LDFLAGS
 
Quoted 7 lines

devtools/test-meson-builds.sh default_cppflags=$CPPFLAGS · line 49

Quoted 4 lines
devtools/test-meson-builds.sh +4 -0
+check_cc_flags () # <flag to check> <flag2> ...
+{
+	echo 'int main(void) { return 0; }' |
+	cc $@ -x c - -o /dev/null 2> /dev/null

Minor nit, as a continuation of the previous line, I think this should be further indented.

Quoted 8 lines

In general I keep piped commands at the same level. This is a matter of taste,
but I can see other piped commands indented in this file, so I will indent this one as well.

Quoted 1 line

Otherwise all looks good to me. Thanks for the updated changes.

Then I will merge it with above change. I guess we won't get more reviews.

Applied