DPDK patches and discussions
 help / color / mirror / Atom feed
From: Thomas Monjalon <thomas@monjalon.net>
To: dev@dpdk.org
Cc: david.marchand@redhat.com, Bruce Richardson <bruce.richardson@intel.com>
Subject: [dpdk-dev] [PATCH v3 1/1] devtools: test 32-bit build
Date: Fri,  6 Nov 2020 17:56:10 +0100
Message-ID: <20201106165611.232288-1-thomas@monjalon.net> (raw)
In-Reply-To: <20201105110728.220957-1-bruce.richardson@intel.com>

From: Bruce Richardson <bruce.richardson@intel.com>

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.

Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
Signed-off-by: Thomas Monjalon <thomas@monjalon.net>
---
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(-)

diff --git a/devtools/test-meson-builds.sh b/devtools/test-meson-builds.sh
index a87de635a2..ac76c2184b 100755
--- a/devtools/test-meson-builds.sh
+++ b/devtools/test-meson-builds.sh
@@ -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
 
-- 
2.28.0


  parent reply	other threads:[~2020-11-06 16:56 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-05 11:07 [dpdk-dev] [PATCH] test-meson-builds: add a " Bruce Richardson
2020-11-05 11:13 ` Thomas Monjalon
2020-11-05 11:21   ` Bruce Richardson
2020-11-05 12:56     ` Thomas Monjalon
2020-11-05 17:19   ` Bruce Richardson
2020-11-05 17:21 ` [dpdk-dev] [PATCH v2] " Bruce Richardson
2020-11-06 12:40   ` Thomas Monjalon
2020-11-06 14:08     ` Bruce Richardson
2020-11-06 16:56 ` Thomas Monjalon [this message]
2020-11-06 17:01   ` [dpdk-dev] [PATCH v3 1/1] devtools: test " Bruce Richardson
2020-11-06 17:11     ` Thomas Monjalon
2020-11-06 17:30       ` Thomas Monjalon

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20201106165611.232288-1-thomas@monjalon.net \
    --to=thomas@monjalon.net \
    --cc=bruce.richardson@intel.com \
    --cc=david.marchand@redhat.com \
    --cc=dev@dpdk.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

DPDK patches and discussions

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://inbox.dpdk.org/dev/0 dev/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 dev dev/ https://inbox.dpdk.org/dev \
		dev@dpdk.org
	public-inbox-index dev

Example config snippet for mirrors.
Newsgroup available over NNTP:
	nntp://inbox.dpdk.org/inbox.dpdk.dev


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git