Re: [PATCH] ASoC: core: Fix Sparse incompatible types warning

From: Krzysztof Kozlowski
Date: Thu Apr 10 2014 - 03:13:49 EST


On czw, 2014-04-10 at 04:01 +0100, Al Viro wrote:
> On Wed, Apr 09, 2014 at 10:28:59PM +0200, Lars-Peter Clausen wrote:
>
> > I had a look at the sparse code and the problem is that it sets the
> > default return type of sizeof according to the type of the host it
> > was compiled on (either unsigned int or unsigned long). It can be
> > overwritten by switches like -m32, but of course wont work when
> > cross compiling. So if your host system is 64bit, but your target
> > system is 32bit you'll get that warning.
>
> Not that simple. First of all, you *need* to tell sparse what target
> to expect; size_t is the least of your troubles - sizeof(long) has
> far more widespread impact. If you don't get -m64 or -m32 in CFLAGS
> (and on quite a few cross-builds you get it, simply because the target
> is biarch and gcc itself needs to know what to generate), you need
> to set it in CHECKFLAGS, along with other target-specific things.
> Example:
> arch/ia64/Makefile:21:CHECKFLAGS += -m64 -D__ia64=1 -D__ia64__=1 -D_LP64 -D__LP64__
>
> With the defaults being what they are (since commit 7aa79f "Adding default for
> m64/m32 handle"), we probably need explicit -m32 in CHECKFLAGS for a bunch
> of 32bit targets. Defaults are iffy, BTW - it's not even "do as host does",
> it's "64bit if the host is amd64, 32bit otherwise" ;-/
>
> Again, CHECKFLAGS need to be set; that's normally done in arch/*/Makefile.

In my case it was cross compile on x86_64 for ARM so adding -m32 to
CHECKFLAGS in arch/arm/Makefile helped.

Best regards,
Krzysztof

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/