Re: Linux kernel cross-compilers

From: Guenter Roeck
Date: Fri Aug 16 2013 - 20:34:43 EST


On Fri, Aug 16, 2013 at 09:26:51PM +0200, Sam Ravnborg wrote:
> On Fri, Aug 16, 2013 at 08:43:35AM -0700, Guenter Roeck wrote:
> > On 08/16/2013 02:45 AM, Max Filippov wrote:
> >>>> Guenter,
> >>>> can you share a complete build log with V=1?
> >>>>
> >>>
> >>> http://roeck-us.net/linux/logs/make.xtensa.log.bad
> >>> http://roeck-us.net/linux/logs/make.xtensa.log.ok
> >>>
> >>> Key difference: the failing command in the bad case is
> >>> xtensa-linux-objcopy -O elf32-xtensa-le
> >>> and in the good case
> >>> xtensa-linux-objcopy -O elf32-xtensa-be
> >>>
> >>> Same compiler (4.6.3 from kernel.org), same configuration file, same command
> >>> line.
> >>> Configuration file is generated from defconfig, and the resulting .config
> >>> file
> >>> is the same in both cases.
> >>>
> >>> If I execute make and expicitly set BIG_ENDIAN=1 on the failing system as
> >>> parameter to it,
> >>> it works fine. If I set BIG_ENDIAN=0 on the passing system, it fails.
> >>>
> >>> I am puzzled. Guess there must be something different, but I have no idea
> >>> what it might be.
> >>
> >> What is the output of
> >>
> >> echo -e __XTENSA_EB__ | xtensa-linux-gcc -E -
> >>
> >> on the failing system?
> >>
> > It is "1", but that let me pinpoint the problem.
> >
> > On the failing system, the version of echo executed by make does
> > not understand the "-e" option. Thus, when running arch/xtensa/boot/Makefile,
> > "echo -e __XTENSA_EB__" returns "-e __XTENSA_EB__", which doesn't compile,
> > and BIG_ENDIAN ends up being 0. So the compiler is completely innocent.
> >
> > I found out the root source: SHELL is set the /bin/sh, which on the failing
> > system points to /bin/dash (default in Ubuntu, or at least it used to be).
> > dash apparently has a built-in version of echo which does not understand '-e'.
>
> Could you try to replace "echo -e bla" with "printf "bla".
> Kbuild.include uses some similar tricks but here printf is used.
> Maybe this can be dash compatible then
>
"echo" would do perfectly fine in this case. Besides, there are more
"echo -e" in arch/xtensa/Makefile. Those only cause unpredictable build
results (because neither big endian not little endian is set because of it),
but no errors.

Problem is that "echo -e" is used elsewhere in various kernel makefiles,
not just for xtensa. Those don't cause odd errors like the one I observed,
but may result in unpredictable behavior. I am not sure if I should try
to fix that.

Maybe we should just put "don't try to compile the linux kernel with dash
as default shell" as a note somewhere.

Guenter
--
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/