Buildroot Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [Buildroot] [Bug 4634] New: Bigendian binary is output even if it is configured to output little endian
@ 2011-12-18  5:28 bugzilla at busybox.net
  2011-12-18 13:33 ` Michael S. Zick
                   ` (3 more replies)
  0 siblings, 4 replies; 6+ messages in thread
From: bugzilla at busybox.net @ 2011-12-18  5:28 UTC (permalink / raw)
  To: buildroot

https://bugs.busybox.net/show_bug.cgi?id=4634

           Summary: Bigendian binary is output even if it is configured to
                    output little endian
           Product: buildroot
           Version: 2011.11
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: major
          Priority: P5
         Component: Other
        AssignedTo: unassigned at buildroot.uclibc.org
        ReportedBy: matusita at k-micro.com
                CC: buildroot at uclibc.org
   Estimated Hours: 0.0


I set build options as below in "make menuconfig" to build root filesystem:
  Target Architecture (mipsel)
  Target Architecture Variant (mips 32r2)
  Toolcain-Toolchain type (External toolchain)
  Toolcain-Toolchain (CodeSourcery MIPS 2011.03)

I expected that little enfian binary will be output because "mipsel" is
selected. But it was big endian.
I confirmed it by objdump with "-f" option like below.

  % mips-linux-gnu-objdump -f busybox
    busybox:     file format elf32-tradbigmips      <-- Big endian !!!
    architecture: mips:isa32r2, flags 0x00000112:
    EXEC_P, HAS_SYMS, D_PAGED
    start address 0x00403f00

So, I saw following file:
  toolchain/toolchain-external/ext-tool.mk

And I understand that this script get libraries' location by calling
(prefix)-gcc with following options:
  -print-sysroot
  -print-file-name=libc.a

But as for this toolchain(CodeSourcery MIPS 2011.03), it is need to set "-EL"
option as well to get correct location of little endian libraries.

-- 
Configure bugmail: https://bugs.busybox.net/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Buildroot] [Bug 4634] New: Bigendian binary is output even if it is configured to output little endian
  2011-12-18  5:28 [Buildroot] [Bug 4634] New: Bigendian binary is output even if it is configured to output little endian bugzilla at busybox.net
@ 2011-12-18 13:33 ` Michael S. Zick
  2011-12-18 13:53   ` Michael S. Zick
  2012-01-31 19:46 ` [Buildroot] [Bug 4634] " bugzilla at busybox.net
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 6+ messages in thread
From: Michael S. Zick @ 2011-12-18 13:33 UTC (permalink / raw)
  To: buildroot

On Sat December 17 2011, bugzilla at busybox.net wrote:
> https://bugs.busybox.net/show_bug.cgi?id=4634
> 
>            Summary: Bigendian binary is output even if it is configured to
>                     output little endian
>            Product: buildroot
>            Version: 2011.11
>           Platform: PC
>         OS/Version: Linux
>             Status: NEW
>           Severity: major
>           Priority: P5
>          Component: Other
>         AssignedTo: unassigned at buildroot.uclibc.org
>         ReportedBy: matusita at k-micro.com
>                 CC: buildroot at uclibc.org
>    Estimated Hours: 0.0
> 
> 
> I set build options as below in "make menuconfig" to build root filesystem:
>   Target Architecture (mipsel)
>   Target Architecture Variant (mips 32r2)
>   Toolcain-Toolchain type (External toolchain)
>   Toolcain-Toolchain (CodeSourcery MIPS 2011.03)
> 
> I expected that little enfian binary will be output because "mipsel" is
> selected. But it was big endian.
> I confirmed it by objdump with "-f" option like below.
> 
>   % mips-linux-gnu-objdump -f busybox
>     busybox:     file format elf32-tradbigmips      <-- Big endian !!!
>     architecture: mips:isa32r2, flags 0x00000112:
>     EXEC_P, HAS_SYMS, D_PAGED
>     start address 0x00403f00
> 
> So, I saw following file:
>   toolchain/toolchain-external/ext-tool.mk
> 
> And I understand that this script get libraries' location by calling
> (prefix)-gcc with following options:
>   -print-sysroot
>   -print-file-name=libc.a
> 
> But as for this toolchain(CodeSourcery MIPS 2011.03), it is need to set "-EL"
> option as well to get correct location of little endian libraries.
> 

I think that the endian default is a gcc build-time option and some builders
do select (or it defaults to) little endian.

But the CS toolchains do default to big endian.
Too be more general purpose, perhaps there should also be a "knob" to pass
-mno-mips16 since the gcc default is to produce mixed 16/32 (or 16/64) bit
code and the mips16e decoder is not a core requirement.

http://openplayer.org/resource/tutorials/57-cs-multi-library-tour.html

Mike

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Buildroot] [Bug 4634] New: Bigendian binary is output even if it is configured to output little endian
  2011-12-18 13:33 ` Michael S. Zick
@ 2011-12-18 13:53   ` Michael S. Zick
  0 siblings, 0 replies; 6+ messages in thread
From: Michael S. Zick @ 2011-12-18 13:53 UTC (permalink / raw)
  To: buildroot

On Sun December 18 2011, Michael S. Zick wrote:
> On Sat December 17 2011, bugzilla at busybox.net wrote:
> > https://bugs.busybox.net/show_bug.cgi?id=4634
> > 
> >            Summary: Bigendian binary is output even if it is configured to
> >                     output little endian
> >            Product: buildroot
> >            Version: 2011.11
> >           Platform: PC
> >         OS/Version: Linux
> >             Status: NEW
> >           Severity: major
> >           Priority: P5
> >          Component: Other
> >         AssignedTo: unassigned at buildroot.uclibc.org
> >         ReportedBy: matusita at k-micro.com
> >                 CC: buildroot at uclibc.org
> >    Estimated Hours: 0.0
> > 
> > 
> > I set build options as below in "make menuconfig" to build root filesystem:
> >   Target Architecture (mipsel)
> >   Target Architecture Variant (mips 32r2)
> >   Toolcain-Toolchain type (External toolchain)
> >   Toolcain-Toolchain (CodeSourcery MIPS 2011.03)
> > 
> > I expected that little enfian binary will be output because "mipsel" is
> > selected. But it was big endian.
> > I confirmed it by objdump with "-f" option like below.
> > 
> >   % mips-linux-gnu-objdump -f busybox
> >     busybox:     file format elf32-tradbigmips      <-- Big endian !!!
> >     architecture: mips:isa32r2, flags 0x00000112:
> >     EXEC_P, HAS_SYMS, D_PAGED
> >     start address 0x00403f00
> > 
> > So, I saw following file:
> >   toolchain/toolchain-external/ext-tool.mk
> > 
> > And I understand that this script get libraries' location by calling
> > (prefix)-gcc with following options:
> >   -print-sysroot
> >   -print-file-name=libc.a
> > 
> > But as for this toolchain(CodeSourcery MIPS 2011.03), it is need to set "-EL"
> > option as well to get correct location of little endian libraries.
> > 
> 
> I think that the endian default is a gcc build-time option and some builders
> do select (or it defaults to) little endian.
> 
> But the CS toolchains do default to big endian.
> Too be more general purpose, perhaps there should also be a "knob" to pass
> -mno-mips16 since the gcc default is to produce mixed 16/32 (or 16/64) bit
> code and the mips16e decoder is not a core requirement.
> 
> http://openplayer.org/resource/tutorials/57-cs-multi-library-tour.html
> 
PS:
Another point -

The MIPS recommendation for code generation is to use:
-Os (the BR default) when compiling 'pure' code and to use:
-O2 when compiling mixed code (gcc defaults to mixed code).

Mike
> Mike
> _______________________________________________
> buildroot mailing list
> buildroot at busybox.net
> http://lists.busybox.net/mailman/listinfo/buildroot
> 
> 

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Buildroot] [Bug 4634] Bigendian binary is output even if it is configured to output little endian
  2011-12-18  5:28 [Buildroot] [Bug 4634] New: Bigendian binary is output even if it is configured to output little endian bugzilla at busybox.net
  2011-12-18 13:33 ` Michael S. Zick
@ 2012-01-31 19:46 ` bugzilla at busybox.net
  2012-02-17  9:37 ` bugzilla at busybox.net
  2012-02-17  9:42 ` bugzilla at busybox.net
  3 siblings, 0 replies; 6+ messages in thread
From: bugzilla at busybox.net @ 2012-01-31 19:46 UTC (permalink / raw)
  To: buildroot

https://bugs.busybox.net/show_bug.cgi?id=4634

Thomas Petazzoni <thomas.petazzoni@free-electrons.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |WONTFIX

--- Comment #1 from Thomas Petazzoni <thomas.petazzoni@free-electrons.com> 2012-01-31 19:46:56 UTC ---
Buildroot does not automatically add the needed CFLAGS and LDFLAGS to use the
adequate multilib variant, because those CFLAGS and LDFLAGS are very
toolchain-specific and architecture-specific. So it is the user's job to add
explictly those flags.

I have posted a patch,
http://lists.busybox.net/pipermail/buildroot/2012-January/049556.html, which
adds some help text on the different external toolchains about their respective
multilib variants and how to select between them. Hopefully, this patch should
be merged for 2012.02.

-- 
Configure bugmail: https://bugs.busybox.net/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Buildroot] [Bug 4634] Bigendian binary is output even if it is configured to output little endian
  2011-12-18  5:28 [Buildroot] [Bug 4634] New: Bigendian binary is output even if it is configured to output little endian bugzilla at busybox.net
  2011-12-18 13:33 ` Michael S. Zick
  2012-01-31 19:46 ` [Buildroot] [Bug 4634] " bugzilla at busybox.net
@ 2012-02-17  9:37 ` bugzilla at busybox.net
  2012-02-17  9:42 ` bugzilla at busybox.net
  3 siblings, 0 replies; 6+ messages in thread
From: bugzilla at busybox.net @ 2012-02-17  9:37 UTC (permalink / raw)
  To: buildroot

https://bugs.busybox.net/show_bug.cgi?id=4634

--- Comment #2 from Aristotelis Iordanidis <aristotelis.iordanidis@diasemi.com> 2012-02-17 09:37:52 UTC ---
Created attachment 4040
  --> https://bugs.busybox.net/attachment.cgi?id=4040
Patch to properly create symlinks when ARCH_SUBDIR is not a single directory.

-- 
Configure bugmail: https://bugs.busybox.net/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Buildroot] [Bug 4634] Bigendian binary is output even if it is configured to output little endian
  2011-12-18  5:28 [Buildroot] [Bug 4634] New: Bigendian binary is output even if it is configured to output little endian bugzilla at busybox.net
                   ` (2 preceding siblings ...)
  2012-02-17  9:37 ` bugzilla at busybox.net
@ 2012-02-17  9:42 ` bugzilla at busybox.net
  3 siblings, 0 replies; 6+ messages in thread
From: bugzilla at busybox.net @ 2012-02-17  9:42 UTC (permalink / raw)
  To: buildroot

https://bugs.busybox.net/show_bug.cgi?id=4634

--- Comment #3 from Aristotelis Iordanidis <aristotelis.iordanidis@diasemi.com> 2012-02-17 09:42:09 UTC ---
(In reply to comment #1)
> Buildroot does not automatically add the needed CFLAGS and LDFLAGS to use the
> adequate multilib variant, because those CFLAGS and LDFLAGS are very
> toolchain-specific and architecture-specific. So it is the user's job to add
> explictly those flags.
> 
> I have posted a patch,
> http://lists.busybox.net/pipermail/buildroot/2012-January/049556.html, which
> adds some help text on the different external toolchains about their respective
> multilib variants and how to select between them. Hopefully, this patch should
> be merged for 2012.02.

(I'm sorry I posted a patch before the explanation)

I don't think this is enough (it didn't work for me).
The TOOLCHAIN_EXTERNAL_CFLAGS in toolchain/toolchain-external/ext-tool.mk does
not take into account BR2_TARGET_OPTIMIZATION.
So, in the end it always copies the big-endian libc/ from multilib.

From toolchain/toolchain-external/ext-tool.mk:

# march/mtune/floating point mode needs to be passed to the external toolchain
# to select the right multilib variant
ifneq ($(CC_TARGET_TUNE_),)
TOOLCHAIN_EXTERNAL_CFLAGS += -mtune=$(CC_TARGET_TUNE_)
TOOLCHAIN_EXTERNAL_WRAPPER_ARGS += -DBR_TUNE='"$(CC_TARGET_TUNE_)"'
endif
ifneq ($(CC_TARGET_ARCH_),)
TOOLCHAIN_EXTERNAL_CFLAGS += -march=$(CC_TARGET_ARCH_)
TOOLCHAIN_EXTERNAL_WRAPPER_ARGS += -DBR_ARCH='"$(CC_TARGET_ARCH_)"'
endif
ifneq ($(CC_TARGET_CPU_),)
TOOLCHAIN_EXTERNAL_CFLAGS += -mcpu=$(CC_TARGET_CPU_)
TOOLCHAIN_EXTERNAL_WRAPPER_ARGS += -DBR_CPU='"$(CC_TARGET_CPU_)"'
endif
ifneq ($(CC_TARGET_ABI_),)
TOOLCHAIN_EXTERNAL_CFLAGS += -mabi=$(CC_TARGET_ABI_)
TOOLCHAIN_EXTERNAL_WRAPPER_ARGS += -DBR_ABI='"$(CC_TARGET_ABI_)"'
endif

ifeq ($(BR2_SOFT_FLOAT),y)
TOOLCHAIN_EXTERNAL_CFLAGS += -msoft-float
TOOLCHAIN_EXTERNAL_WRAPPER_ARGS += -DBR_SOFTFLOAT=1
endif

ifeq ($(BR2_VFP_FLOAT),y)
TOOLCHAIN_EXTERNAL_CFLAGS += -mfpu=vfp
TOOLCHAIN_EXTERNAL_WRAPPER_ARGS += -DBR_VFPFLOAT=1
endif

...

        $(Q)SYSROOT_DIR=`$(TOOLCHAIN_EXTERNAL_CC) -print-sysroot 2>/dev/null` ;
\

...

        ARCH_SUBDIR=`$(TOOLCHAIN_EXTERNAL_CC) $(TOOLCHAIN_EXTERNAL_CFLAGS)
-print-multi-directory` ; \
        ARCH_SYSROOT_DIR=$${SYSROOT_DIR}/$${ARCH_SUBDIR} ; \

...

        echo "Copy external toolchain sysroot to staging..." ; \
        $(call
copy_toolchain_sysroot,$${SYSROOT_DIR},$${ARCH_SYSROOT_DIR},$${ARCH_SUBDIR}) ;
\


I have selected the following in menuconfig (I've also selected soft-float):

BR2_TARGET_OPTIMIZATION="-pipe -EL -march=m14kc -mmcu"
BR2_TARGET_LDFLAGS="-EL"


I attempted to fix the problem by passing $(TARGET_LDFLAGS) in ARCH_SUBDIR:

        ARCH_SUBDIR=`$(TOOLCHAIN_EXTERNAL_CC) $(TOOLCHAIN_EXTERNAL_CFLAGS)
$(TARGET_LDFLAGS) -print-multi-directory` ; \

After this change it seems that the little-endian version of libc is copied in
buildroot's sysroot, but I still get errors about crt1.o and crti.o (ld can't
find them).

This happens because in my case ARCH_SUBDIR=soft-float/el .
copy_toolchain_sysroot doesn't handle the case where ARCH_SUBDIR is not a
single directory:

ln: failed to create symbolic link
`/home/iordanidis/src/buildroot/buildroot/output/host/usr/mipsel-unknown-linux-gnu/sysroot/soft-float/el':
No such file or directory

I corrected this by slightly modifying copy_toolchain_sysroot. After that,
busybox was built correctly with -EL -soft-float.

-- 
Configure bugmail: https://bugs.busybox.net/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2012-02-17  9:42 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-12-18  5:28 [Buildroot] [Bug 4634] New: Bigendian binary is output even if it is configured to output little endian bugzilla at busybox.net
2011-12-18 13:33 ` Michael S. Zick
2011-12-18 13:53   ` Michael S. Zick
2012-01-31 19:46 ` [Buildroot] [Bug 4634] " bugzilla at busybox.net
2012-02-17  9:37 ` bugzilla at busybox.net
2012-02-17  9:42 ` bugzilla at busybox.net

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox