Buildroot Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
To: buildroot@busybox.net
Subject: [Buildroot] [PATCH 2/2] bfin: put the libc link path of the flat shared and sep data formats before the sysroot link path
Date: Wed, 30 Dec 2015 09:53:47 +0100	[thread overview]
Message-ID: <20151230095347.6e9a9197@free-electrons.com> (raw)
In-Reply-To: <B168F8A49F4BCF4C84FD23DA5F6363EE75D82F29@NWD2MBX7.ad.analog.com>

Hello Sonic,

First of all, thanks for replying so quickly. Since we haven't seen
much patches from you improving the Blackfin support in upstream
Buildroot, I wasn't sure you would answer our e-mail.

On Wed, 30 Dec 2015 06:55:57 +0000, Zhang, Sonic wrote:

> The right sysroot of the Blackfin toolchain is copied by the external
> toolchain logic in buildroot. The problem is that the libc files for
> FLAT, Shared FLAT and Shared FLAT with separate data formats are put
> into different subfolders of the same blackfin toolchain for FLAT
> binary.

Absolutely.

> Do you suggest to copy the libc for current FLAT format type
> into $(STAGING_DIR)/usr/lib in the toolchain copy logic? If so, I can
> send a new patch.

Yes, but this should normally happen "magically". Let me take an
example from another toolchain to illustrate how it works.

If you take the CodeSourcery ARM toolchain, it has three sysroots:

 - One for ARMv5 (the default one)
 - One for ARMv4
 - One for ARMv7 Thumb2

See below:

$ ./bin/arm-none-linux-gnueabi-gcc -print-file-name=libc.a
/home/thomas/projets/buildroot/output/host/opt/ext-toolchain/bin/../arm-none-linux-gnueabi/libc/usr/lib/libc.a
$ ./bin/arm-none-linux-gnueabi-gcc -march=armv4t -print-file-name=libc.a
/home/thomas/projets/buildroot/output/host/opt/ext-toolchain/bin/../arm-none-linux-gnueabi/libc/armv4t/usr/lib/libc.a
$ ./bin/arm-none-linux-gnueabi-gcc -march=armv7-a -mthumb -print-file-name=libc.a
/home/thomas/projets/buildroot/output/host/opt/ext-toolchain/bin/../arm-none-linux-gnueabi/libc/thumb2/usr/lib/libc.a

If I build an ARMv5 system in Buildroot, then the sysroot from libc/ will
be copied to $(STAGING_DIR) :

$ md5sum output/staging/usr/lib/libc.a 
0c6a145ebbc860800152c2d8c82e5af9  output/staging/usr/lib/libc.a
$ md5sum output/host/opt/ext-toolchain/bin/../arm-none-linux-gnueabi/libc/usr/lib/libc.a
0c6a145ebbc860800152c2d8c82e5af9  output/host/opt/ext-toolchain/bin/../arm-none-linux-gnueabi/libc/usr/lib/libc.a

If I now build an ARMv4 system in Buildroot, then the sysroot from
libc/armv4t/ will be copied to $(STAGING_DIR) :

$ md5sum output/staging/usr/lib/libc.a 
21109c9b68203d10437446d998d782c7  output/staging/usr/lib/libc.a
$ md5sum output/host/opt/ext-toolchain/bin/../arm-none-linux-gnueabi/libc/armv4t/usr/lib/libc.a
21109c9b68203d10437446d998d782c7  output/host/opt/ext-toolchain/bin/../arm-none-linux-gnueabi/libc/armv4t/usr/lib/libc.a

And finally, if I build an ARMv7 Thumb2 system in Buildroot, then the
sysroot from libc/thumb2/ will be copied to $(STAGING_DIR) :

$ md5sum output/staging/usr/lib/libc.a 
d94693412ceac0839883ed0ece38c43f  output/staging/usr/lib/libc.a
$ md5sum output/host/opt/ext-toolchain/bin/../arm-none-linux-gnueabi/libc/thumb2/usr/lib/libc.a
d94693412ceac0839883ed0ece38c43f  output/host/opt/ext-toolchain/bin/../arm-none-linux-gnueabi/libc/thumb2/usr/lib/libc.a

This all gets done magically by the existing external toolchain logic,
with no special handling for this CodeSourcery toolchain. In all three
cases, we end up with $(STAGING_DIR) containing a copy of the sysroot
that corresponds to the selected architecture flags. If you want to try
this out by ourself, try the following configurations:

 - For ARMv5

BR2_arm=y
BR2_TOOLCHAIN_EXTERNAL=y

 - For ARMv4

BR2_arm=y
BR2_arm920t=y
BR2_TOOLCHAIN_EXTERNAL=y

 - For ARMv7/Thumb2

BR2_arm=y
BR2_cortex_a8=y
BR2_ARM_EABI=y
BR2_ARM_SOFT_FLOAT=y
BR2_ARM_INSTRUCTIONS_THUMB2=y
BR2_TOOLCHAIN_EXTERNAL=y

Now, back to the Blackfin toolchain, if we ask gcc for the location of
libc.a (like I did before with the ARM toolchain), we get :

 - With no special flags

$ ./bin/bfin-uclinux-gcc -print-file-name=libc.a
/home/thomas/projets/buildroot/output/host/opt/ext-toolchain/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/lib/libc.a

 - With -mid-shared-library

$ ./bin/bfin-uclinux-gcc -mid-shared-library -print-file-name=libc.a
/home/thomas/projets/buildroot/output/host/opt/ext-toolchain/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/lib/mid-shared-library/libc.a

 - With -msep-data

$ ./bin/bfin-uclinux-gcc -msep-data -print-file-name=libc.a
/home/thomas/projets/buildroot/output/host/opt/ext-toolchain/bfin-uclinux/bin/../bfin-uclinux/runtime/usr/lib/msep-data/libc.a

As you can see, it behaves like the CodeSourcery ARM toolchain:
depending on the gcc flags passed, it points to a different sysroot. So
my expectation is that the external toolchain logic that works for the
CodeSourcery ARM toolchain should also work for the ADI Blackfin
toolchain. Note that Buildroot specifically uses the location of libc.a
to determine where the sysroot is. See:

# Returns the location of the libc.a file for the given compiler + flags
define toolchain_find_libc_a
$$(readlink -f $$(LANG=C $(1) -print-file-name=libc.a))
endef

Can you investigate why the external toolchain logic doesn't work for
the Blackfin use case, and whether it can be fixed/extended to cover
this case ?

I saw your patch, which could be a work-around specific to the Blackfin
toolchain. It takes into account the mid-shared-library and msep-data
cases, but it doesn't take into account the other sysroot available in
the Blackfin toolchain:

$ ./output/host/opt/ext-toolchain/bfin-uclinux/bin/bfin-uclinux-gcc -print-multi-lib
.;
bf532-none;@mcpu=bf532-none
mid-shared-library;@mid-shared-library
msep-data;@msep-data
bf532-none/mid-shared-library;@mcpu=bf532-none at mid-shared-library
bf532-none/msep-data;@mcpu=bf532-none at msep-data

So we would have to add other cases for the bf532-none flag (but what
is this flag ? the gcc documentation documents -mcpu=bf532, but
certainly not -mcpu=bf532-none).

Could you look into this ?

Thanks!

Thomas
-- 
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com

  parent reply	other threads:[~2015-12-30  8:53 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-03-18  8:59 [Buildroot] [PATCH 1/2] bfin: remove the dependency of flat shared mode to shared library Sonic Zhang
2015-03-18  8:59 ` [Buildroot] [PATCH 2/2] bfin: put the libc link path of the flat shared and sep data formats before the sysroot link path Sonic Zhang
2015-03-20 21:42   ` Thomas Petazzoni
2015-03-23  2:57     ` Sonic Zhang
2015-12-29 21:01   ` Thomas Petazzoni
     [not found]     ` <B168F8A49F4BCF4C84FD23DA5F6363EE75D82F29@NWD2MBX7.ad.analog.com>
2015-12-30  8:53       ` Thomas Petazzoni [this message]
2015-03-20 21:45 ` [Buildroot] [PATCH 1/2] bfin: remove the dependency of flat shared mode to shared library Thomas Petazzoni
2015-03-23  2:43   ` Sonic Zhang
2015-03-24 19:09     ` Arnout Vandecappelle
2015-03-26  8:55       ` Sonic Zhang
2015-03-27 20:31         ` Arnout Vandecappelle

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20151230095347.6e9a9197@free-electrons.com \
    --to=thomas.petazzoni@free-electrons.com \
    --cc=buildroot@busybox.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox