Patchwork configure: change endian cross compilation test

login
register
mail settings
Submitter Stuart Yoder
Date March 14, 2012, 4:36 p.m.
Message ID <1331742990-14385-1-git-send-email-stuart.yoder@freescale.com>
Download mbox | patch
Permalink /patch/146689/
State New
Headers show

Comments

Stuart Yoder - March 14, 2012, 4:36 p.m.
From: Stuart Yoder <stuart.yoder@freescale.com>

Previous check in configure's endian test was to determine if
this is a cross-compile build by testing whether --cross-prefix
was used.  This does not work for cross build environments
like Yocto that may set CC instead of --cross-prefix.

Instead, test whether host compiler is same as target compiler,
which also works when --cross-prefix is used.

Signed-off-by: Stuart Yoder <stuart.yoder@freescale.com>
---
 configure |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
Peter Maydell - March 14, 2012, 5:17 p.m.
2012/3/14 Paul Brook <paul@codesourcery.com>:
>> From: Stuart Yoder <stuart.yoder@freescale.com>
>>
>> Previous check in configure's endian test was to determine if
>> this is a cross-compile build by testing whether --cross-prefix
>> was used.  This does not work for cross build environments
>> like Yocto that may set CC instead of --cross-prefix.

Do we even support not using --cross-prefix ? I'd have expected just
setting CC to run into random problems like using the host arch's
version of strip rather than the cross toolchain, the host's
pkg-config rather than the one that knows where the cross libraries
are, etc etc.

>> Instead, test whether host compiler is same as target compiler,
>> which also works when --cross-prefix is used.
>
> I'd much rather remove this test altogether.  If the cross case doesn't give
> the right answer for all the host systems we care about then we should fix
> that.

Agreed. I think looking at the host CPUs we support the only ones
that aren't guaranteed either big or little endian are (a) mips
and (b) ARM. ARM already identifies big-endian by a compile-time
check, and it seems likely that MIPS could too.

-- PMM
Peter Maydell - March 14, 2012, 6:09 p.m.
[added qemu-devel back again]

On 14 March 2012 17:51, Stuart Yoder <b08248@gmail.com> wrote:
> On Wed, Mar 14, 2012 at 12:17 PM, Peter Maydell
> <peter.maydell@linaro.org> wrote:
>> Agreed. I think looking at the host CPUs we support the only ones
>> that aren't guaranteed either big or little endian are (a) mips
>> and (b) ARM. ARM already identifies big-endian by a compile-time
>> check, and it seems likely that MIPS could too.
>
> So, you're proposing just leaving the test as:
>
> # if cross compiling, cannot launch a program, so make a static guess
> case "$cpu" in
>  arm)
>    # ARM can be either way; ask the compiler which one we are
>    if check_define __ARMEB__; then
>      bigendian=yes
>    fi
>  ;;
>  hppa|m68k|mips|mips64|ppc|ppc64|s390|s390x|sparc|sparc64)
>    bigendian=yes
>  ;;
> esac

No, I'm proposing that you find out what the right check_define
for mips is and make mips|mips64 have a similar case to the arm
one. Google suggests the answer is __MIPSEB__; you can do a quick
check by firing up the mipsel/mips images from
http://people.debian.org/~aurel32/qemu/ under qemu :-)

-- PMM
Stefan Weil - March 14, 2012, 7 p.m.
Am 14.03.2012 19:09, schrieb Peter Maydell:
> [added qemu-devel back again]
>
> On 14 March 2012 17:51, Stuart Yoder<b08248@gmail.com>  wrote:
>> On Wed, Mar 14, 2012 at 12:17 PM, Peter Maydell
>> <peter.maydell@linaro.org>  wrote:
>>> Agreed. I think looking at the host CPUs we support the only ones
>>> that aren't guaranteed either big or little endian are (a) mips
>>> and (b) ARM. ARM already identifies big-endian by a compile-time
>>> check, and it seems likely that MIPS could too.
>> So, you're proposing just leaving the test as:
>>
>> # if cross compiling, cannot launch a program, so make a static guess
>> case "$cpu" in
>>   arm)
>>     # ARM can be either way; ask the compiler which one we are
>>     if check_define __ARMEB__; then
>>       bigendian=yes
>>     fi
>>   ;;
>>   hppa|m68k|mips|mips64|ppc|ppc64|s390|s390x|sparc|sparc64)
>>     bigendian=yes
>>   ;;
>> esac
> No, I'm proposing that you find out what the right check_define
> for mips is and make mips|mips64 have a similar case to the arm
> one. Google suggests the answer is __MIPSEB__; you can do a quick
> check by firing up the mipsel/mips images from
> http://people.debian.org/~aurel32/qemu/ under qemu :-)
>
> -- PMM

Running

     git grep "__MIPSEB__"

or

     git grep "__MIPSEL__"

would be a quicker check :-))

Stefan W.

Patch

diff --git a/configure b/configure
index fe4fc4f..c5333bf 100755
--- a/configure
+++ b/configure
@@ -1269,7 +1269,7 @@  feature_not_found() {
   exit 1;
 }
 
-if test -z "$cross_prefix" ; then
+if test $cc = $host_cc; then
 
 # ---
 # big/little endian test