[oe] libxml2-native build against host zlib.h

Jader H. Silva jader at 2mi.com.br
Tue Apr 14 20:48:03 UTC 2009


Tom Rini escreveu:
> On Tue, Apr 07, 2009 at 06:07:51PM -0300, Jader H. Silva wrote:
> [snip]
>   
>> I'm using ubuntu 8.04, zlib1g-dev package is installed.
>> I can compile it without problems in a machine where zlib1g-dev is not  
>> installed.
>>
>> Attached there's the log.do_compile and config.log.nok originated from a  
>> failed compilation and config.log from a successful compilation after my  
>> patch was applied.
>>     
>
> On the failing machine can you either do CCACHE="" or ccache -C to dump
> the cache and try again?
>
>   
Alright, nothing worked (setting --with-zlib=${STAGING_INCDIR} included) 
so I decided to look deeper and found out that problem is caused by 
BUILD_CPPFLAGS in GCC's preprocessing stage of xmlIO.c.

BUILD_CPPFLAGS use "-isystem" to include ${STAGING_INCDIR}.

openembedded/conf/bitbake.conf:429:export BUILD_CPPFLAGS = 
"-isystem${STAGING_INCDIR_NATIVE}"

Both CFLAGS and CPPFLAGS use BUILD_CPPFLAGS:

CFLAGS=-isystem/home/jader/thinstation/build/tmp/staging/i686-linux/usr/include 
-O2
CPPFLAGS=-isystem/home/jader/thinstation/build/tmp/staging/i686-linux/usr/include 
-O2 -fpermissive

When building xmlIO.o, the preprocessor is called as follow:

 /usr/lib/gcc/i486-linux-gnu/4.2.4/cc1 -E -quiet -v -I. -I./include 
-I./include -MD xmlIO.d -MF .deps/xmlIO.Tpo -MP -MT xmlIO.lo -H -isystem 
/usr/include -DHAVE_CONFIG_H -D_REENTRANT -DPIC 
-isystem/home/jader/thinstation/build/tmp/staging/i686-linux/usr/include 
-isystem/home/jader/thinstation/build/tmp/staging/i686-linux/usr/include 
xmlIO.c -mtune=generic -pedantic -W -Wunused -Wimplicit -Wreturn-type 
-Wswitch -Wcomment -Wtrigraphs -Wformat -Wchar-subscripts 
-Wuninitialized -Wparentheses -Wshadow -Wpointer-arith -Wcast-align 
-Wwrite-strings -Waggregate-return -Wstrict-prototypes 
-Wmissing-prototypes -Wnested-externs -Winline -Wredundant-decls -fPIC -O2

As you can see, gcc includes the standard host include directory 
"-isystem /usr/include" in the command line.

All "-isystem" directories are searched after "-I" directories but, as 
stated in GCC's manual, if a directory is referenced both with "-I" and 
"-isystem", gcc will use only "-isystem".

If I compile with --with-zlib=${STAGING_INCDIR}, there will be an 
additional flag: "-I ${STAGING_INCDIR}"  and the preprocessor will mark 
this include dir as a duplicated of "-isystem ${STAGING_INCDIR}" and 
ignore it. If I do not include it, it simply won't be ignored

ignoring duplicate directory 
"/home/jader/thinstation/build/tmp/staging/i686-linux/usr/include" <-- 
this ${is STAGING_INCDIR}
ignoring nonexistent directory "/usr/local/include/i486-linux-gnu"
ignoring nonexistent directory 
"/usr/lib/gcc/i486-linux-gnu/4.2.4/../../../../i486-linux-gnu/include"
ignoring nonexistent directory "/usr/include/i486-linux-gnu"
ignoring duplicate directory "/usr/include"
ignoring duplicate directory "./include"
#include "..." search starts here:
#include <...> search starts here:
 .
 ./include
 /usr/include
 /home/jader/thinstation/build/tmp/staging/i686-linux/usr/include
 /usr/local/include
 /usr/lib/gcc/i486-linux-gnu/4.2.4/include

As "-isystem /usr/include" is the first "-isystem" flag, it will be 
looked up first and if you have zlib.h there, then your libxml2-native 
will be compile against it. I don't know if this is a GCC's version 
issue tough. Here I use: gcc (GCC) 4.2.4 (Ubuntu 4.2.4-1ubuntu3)

Maybe 3.x won't insert "-isystem /usr/include" as first "-isystem" when 
preprocessing.

It's possible this problem happens with many recipes that use 
preprocessed files against headers in ${STAGING_INCDIR} and don't 
override BUILD_CPPFLAGS properly.

Setting BUILD_CPPFLAGS inside 
openembedded/recipes/libxml/libxml2-native.inc fixed it. There's a patch 
attached.

Att.

Jader H. Silva
jader at 2mi.com.br
Depto. de desenvolvimento
2MI Tecnologia
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-Fix-libxml2-native-compilation-against-host-zlib.h.patch
Type: text/x-patch
Size: 753 bytes
Desc: not available
URL: <http://lists.openembedded.org/pipermail/openembedded-devel/attachments/20090414/fd872887/attachment-0002.bin>


More information about the Openembedded-devel mailing list