devtools: fix 32-bits build

Message ID 20201109130035.3948462-1-ferruh.yigit@intel.com (mailing list archive)
State Superseded, archived
Delegated to: Thomas Monjalon
Headers
Series devtools: fix 32-bits build |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/iol-broadcom-Functional success Functional Testing PASS
ci/iol-broadcom-Performance success Performance Testing PASS
ci/iol-testing success Testing PASS
ci/iol-intel-Functional success Functional Testing PASS
ci/iol-intel-Performance success Performance Testing PASS
ci/travis-robot success Travis build: passed
ci/iol-mellanox-Performance success Performance Testing PASS

Commit Message

Ferruh Yigit Nov. 9, 2020, 1 p.m. UTC
  32 bit still uses the pkgconfig file for 64-bits libraries, from the
build log:

"
Using DPDK_TARGET i386-pc-linux-gnu
meson  -Dexamples=l3fwd --buildtype=debugoptimized --werror
-Dc_args=-m32 -Dc_link_args=-m32
/tmp/dpdk_maintain/self/dpdk/devtools/.. ./build-32b
...
Using 'PKG_CONFIG_PATH' from environment with value:
'/usr/local/lib64/pkgconfig/
"

This causes build error when linking with the found libraries.

Reproduced with 'librte_bpf' which only has 64 bit installed but still
enables building 'af_xdp' and link fails.

To fix updating 'PKG_CONFIG_PATH' and preventing 'load_env' overwrite
it.

Fixes: 9b83106d8784 ("devtools: test 32-bit build")

Signed-off-by: Ferruh Yigit <ferruh.yigit@intel.com>
---
Cc: Bruce Richardson <bruce.richardson@intel.com>
Cc: Thomas Monjalon <thomas@monjalon.net>

'build-32b' check inside the 'load_env' looks ugly but not sure how to
be sure 'PKG_CONFIG_PATH' set correct.
---
 devtools/test-meson-builds.sh | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
  

Comments

Thomas Monjalon Nov. 9, 2020, 1:19 p.m. UTC | #1
09/11/2020 14:00, Ferruh Yigit:
> 32 bit still uses the pkgconfig file for 64-bits libraries, from the
> build log:
> 
> "
> Using DPDK_TARGET i386-pc-linux-gnu
> meson  -Dexamples=l3fwd --buildtype=debugoptimized --werror
> -Dc_args=-m32 -Dc_link_args=-m32
> /tmp/dpdk_maintain/self/dpdk/devtools/.. ./build-32b
> ...
> Using 'PKG_CONFIG_PATH' from environment with value:
> '/usr/local/lib64/pkgconfig/
> "
> 
> This causes build error when linking with the found libraries.
> 
> Reproduced with 'librte_bpf' which only has 64 bit installed but still
> enables building 'af_xdp' and link fails.

I think it is a problem in your configuration.
PKG_CONFIG_PATH is not empty before starting the script, right?

> To fix updating 'PKG_CONFIG_PATH' and preventing 'load_env' overwrite
> it.
[...]
> 'build-32b' check inside the 'load_env' looks ugly but not sure how to
> be sure 'PKG_CONFIG_PATH' set correct.
[...]
> -	export PKG_CONFIG_PATH=$default_pkgpath
> +	if [ "$targetdir" != "build-32b" ] ; then
> +		export PKG_CONFIG_PATH=$default_pkgpath
> +	fi

You can reset PKG_CONFIG_PATH in your config file.
Something like this:

if echo $DPDK_TARGET | grep -q '^i[3-6]86' ; then
	export PKG_CONFIG_PATH=my32bitlibs/pkgconfig
fi

We can also discuss why inheriting some default values on script start
instead of just resetting them.
  
Ferruh Yigit Nov. 9, 2020, 1:24 p.m. UTC | #2
On 11/9/2020 1:19 PM, Thomas Monjalon wrote:
> 09/11/2020 14:00, Ferruh Yigit:
>> 32 bit still uses the pkgconfig file for 64-bits libraries, from the
>> build log:
>>
>> "
>> Using DPDK_TARGET i386-pc-linux-gnu
>> meson  -Dexamples=l3fwd --buildtype=debugoptimized --werror
>> -Dc_args=-m32 -Dc_link_args=-m32
>> /tmp/dpdk_maintain/self/dpdk/devtools/.. ./build-32b
>> ...
>> Using 'PKG_CONFIG_PATH' from environment with value:
>> '/usr/local/lib64/pkgconfig/
>> "
>>
>> This causes build error when linking with the found libraries.
>>
>> Reproduced with 'librte_bpf' which only has 64 bit installed but still
>> enables building 'af_xdp' and link fails.
> 
> I think it is a problem in your configuration.
> PKG_CONFIG_PATH is not empty before starting the script, right?
> 
>> To fix updating 'PKG_CONFIG_PATH' and preventing 'load_env' overwrite
>> it.
> [...]
>> 'build-32b' check inside the 'load_env' looks ugly but not sure how to
>> be sure 'PKG_CONFIG_PATH' set correct.
> [...]
>> -	export PKG_CONFIG_PATH=$default_pkgpath
>> +	if [ "$targetdir" != "build-32b" ] ; then
>> +		export PKG_CONFIG_PATH=$default_pkgpath
>> +	fi
> 
> You can reset PKG_CONFIG_PATH in your config file.
> Something like this:
> 
> if echo $DPDK_TARGET | grep -q '^i[3-6]86' ; then
> 	export PKG_CONFIG_PATH=my32bitlibs/pkgconfig
> fi
> 
> We can also discuss why inheriting some default values on script start
> instead of just resetting them.
> 

Yes I have 'PKG_CONFIG_PATH' set in my environment before running script, if it 
expects it to be not set, +1 to reset it at the beginning of the script.
  
Bruce Richardson Nov. 9, 2020, 1:35 p.m. UTC | #3
On Mon, Nov 09, 2020 at 01:24:28PM +0000, Ferruh Yigit wrote:
> On 11/9/2020 1:19 PM, Thomas Monjalon wrote:
> > 09/11/2020 14:00, Ferruh Yigit:
> > > 32 bit still uses the pkgconfig file for 64-bits libraries, from the
> > > build log:
> > > 
> > > "
> > > Using DPDK_TARGET i386-pc-linux-gnu
> > > meson  -Dexamples=l3fwd --buildtype=debugoptimized --werror
> > > -Dc_args=-m32 -Dc_link_args=-m32
> > > /tmp/dpdk_maintain/self/dpdk/devtools/.. ./build-32b
> > > ...
> > > Using 'PKG_CONFIG_PATH' from environment with value:
> > > '/usr/local/lib64/pkgconfig/
> > > "
> > > 
> > > This causes build error when linking with the found libraries.
> > > 
> > > Reproduced with 'librte_bpf' which only has 64 bit installed but still
> > > enables building 'af_xdp' and link fails.
> > 
> > I think it is a problem in your configuration.
> > PKG_CONFIG_PATH is not empty before starting the script, right?
> > 
> > > To fix updating 'PKG_CONFIG_PATH' and preventing 'load_env' overwrite
> > > it.
> > [...]
> > > 'build-32b' check inside the 'load_env' looks ugly but not sure how to
> > > be sure 'PKG_CONFIG_PATH' set correct.
> > [...]
> > > -	export PKG_CONFIG_PATH=$default_pkgpath
> > > +	if [ "$targetdir" != "build-32b" ] ; then
> > > +		export PKG_CONFIG_PATH=$default_pkgpath
> > > +	fi
> > 
> > You can reset PKG_CONFIG_PATH in your config file.
> > Something like this:
> > 
> > if echo $DPDK_TARGET | grep -q '^i[3-6]86' ; then
> > 	export PKG_CONFIG_PATH=my32bitlibs/pkgconfig
> > fi
> > 
> > We can also discuss why inheriting some default values on script start
> > instead of just resetting them.
> > 
> 
> Yes I have 'PKG_CONFIG_PATH' set in my environment before running script, if
> it expects it to be not set, +1 to reset it at the beginning of the script.

+1 to this, because we can't have a global PKG_CONFIG_PATH for both 32-bit
and 64-bit builds.

/Bruce
  
Thomas Monjalon Nov. 9, 2020, 1:51 p.m. UTC | #4
09/11/2020 14:35, Bruce Richardson:
> On Mon, Nov 09, 2020 at 01:24:28PM +0000, Ferruh Yigit wrote:
> > On 11/9/2020 1:19 PM, Thomas Monjalon wrote:
> > > 09/11/2020 14:00, Ferruh Yigit:
> > > > 32 bit still uses the pkgconfig file for 64-bits libraries, from the
> > > > build log:
> > > > 
> > > > "
> > > > Using DPDK_TARGET i386-pc-linux-gnu
> > > > meson  -Dexamples=l3fwd --buildtype=debugoptimized --werror
> > > > -Dc_args=-m32 -Dc_link_args=-m32
> > > > /tmp/dpdk_maintain/self/dpdk/devtools/.. ./build-32b
> > > > ...
> > > > Using 'PKG_CONFIG_PATH' from environment with value:
> > > > '/usr/local/lib64/pkgconfig/
> > > > "
> > > > 
> > > > This causes build error when linking with the found libraries.
> > > > 
> > > > Reproduced with 'librte_bpf' which only has 64 bit installed but still
> > > > enables building 'af_xdp' and link fails.
> > > 
> > > I think it is a problem in your configuration.
> > > PKG_CONFIG_PATH is not empty before starting the script, right?
> > > 
> > > > To fix updating 'PKG_CONFIG_PATH' and preventing 'load_env' overwrite
> > > > it.
> > > [...]
> > > > 'build-32b' check inside the 'load_env' looks ugly but not sure how to
> > > > be sure 'PKG_CONFIG_PATH' set correct.
> > > [...]
> > > > -	export PKG_CONFIG_PATH=$default_pkgpath
> > > > +	if [ "$targetdir" != "build-32b" ] ; then
> > > > +		export PKG_CONFIG_PATH=$default_pkgpath
> > > > +	fi
> > > 
> > > You can reset PKG_CONFIG_PATH in your config file.
> > > Something like this:
> > > 
> > > if echo $DPDK_TARGET | grep -q '^i[3-6]86' ; then
> > > 	export PKG_CONFIG_PATH=my32bitlibs/pkgconfig
> > > fi
> > > 
> > > We can also discuss why inheriting some default values on script start
> > > instead of just resetting them.
> > > 
> > 
> > Yes I have 'PKG_CONFIG_PATH' set in my environment before running script, if
> > it expects it to be not set, +1 to reset it at the beginning of the script.
> 
> +1 to this, because we can't have a global PKG_CONFIG_PATH for both 32-bit
> and 64-bit builds.

Not sure what is best.
The idea of saving the env vars is to consider what the user set
for one run, not in the config file:

default_path=$PATH
default_pkgpath=$PKG_CONFIG_PATH
default_cppflags=$CPPFLAGS
default_cflags=$CFLAGS
default_ldflags=$LDFLAGS

Do you want to change this assumption to ignore all environment vars?
Should we save PATH at least?
Do we set every variables inside the configuration file?

I tend to think that it may be safer to avoid influence of the env
and have a self-contained config file.
So I would add PATH=/usr/bin at the beginning of my config file.
  

Patch

diff --git a/devtools/test-meson-builds.sh b/devtools/test-meson-builds.sh
index 0c95d1cc98..9e44359398 100755
--- a/devtools/test-meson-builds.sh
+++ b/devtools/test-meson-builds.sh
@@ -53,7 +53,9 @@  load_env () # <target compiler>
 {
 	targetcc=$1
 	export PATH=$default_path
-	export PKG_CONFIG_PATH=$default_pkgpath
+	if [ "$targetdir" != "build-32b" ] ; then
+		export PKG_CONFIG_PATH=$default_pkgpath
+	fi
 	export CPPFLAGS=$default_cppflags
 	export CFLAGS=$default_cflags
 	export LDFLAGS=$default_ldflags
@@ -226,10 +228,12 @@  if check_cc_flags '-m32' ; then
 		# 32-bit pkgconfig on RHEL/Fedora (lib vs lib64)
 		export PKG_CONFIG_LIBDIR='/usr/lib/pkgconfig'
 	fi
+	export PKG_CONFIG_PATH=$PKG_CONFIG_LIBDIR
 	target_override='i386-pc-linux-gnu'
 	build build-32b cc -Dc_args='-m32' -Dc_link_args='-m32'
 	target_override=
 	unset PKG_CONFIG_LIBDIR
+	unset PKG_CONFIG_PATH
 fi
 
 # x86 MinGW