public inbox for crossgcc@sourceware.org
 help / color / mirror / Atom feed
* Relocatable toolchain
@ 2013-06-17 14:40 Filipp Andjelo
  2013-06-17 14:53 ` Thomas Petazzoni
  2013-06-17 22:36 ` Yann E. MORIN
  0 siblings, 2 replies; 7+ messages in thread
From: Filipp Andjelo @ 2013-06-17 14:40 UTC (permalink / raw)
  To: crossgcc

Hi,

I built a toolchain using crosstool-ng and it works fine, as far as I 
don't move it to another folder. I want to have a toolchain, which I can 
put everywhere, but how?
If I run "gcc --print-sysroot", I get absolute path to the directory, 
where toolchain was built. If I check the same for google's Android 
toolchain, I get relative path
to the gcc. How did they do that?

Currently, I have a workaround using CFLAGS="--sysroot=path/to/sysroot", 
but It's not acceptable solution here.

Cheers,
Filipp
--
For unsubscribe information see http://sourceware.org/lists.html#faq

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

* Re: Relocatable toolchain
  2013-06-17 14:40 Relocatable toolchain Filipp Andjelo
@ 2013-06-17 14:53 ` Thomas Petazzoni
  2013-06-17 18:15   ` Filipp Andjelo
  2013-06-17 22:36 ` Yann E. MORIN
  1 sibling, 1 reply; 7+ messages in thread
From: Thomas Petazzoni @ 2013-06-17 14:53 UTC (permalink / raw)
  To: Filipp Andjelo; +Cc: crossgcc

Dear Filipp Andjelo,

On Mon, 17 Jun 2013 14:40:32 +0000, Filipp Andjelo wrote:

> I built a toolchain using crosstool-ng and it works fine, as far as I 
> don't move it to another folder. I want to have a toolchain, which I can 
> put everywhere, but how?
> If I run "gcc --print-sysroot", I get absolute path to the directory, 
> where toolchain was built. If I check the same for google's Android 
> toolchain, I get relative path
> to the gcc. How did they do that?
> 
> Currently, I have a workaround using CFLAGS="--sysroot=path/to/sysroot", 
> but It's not acceptable solution here.

Did you do some special configuration to Crosstool-NG? Because by
default, Crosstool-NG puts the toolchain sysroot is a correct location
that allows the toolchain to be relocatable. And it works well for me.

Best regards,

Thomas
-- 
Thomas Petazzoni, Free Electrons
Kernel, drivers, real-time and embedded Linux
development, consulting, training and support.
http://free-electrons.com

--
For unsubscribe information see http://sourceware.org/lists.html#faq

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

* Re: Relocatable toolchain
  2013-06-17 14:53 ` Thomas Petazzoni
@ 2013-06-17 18:15   ` Filipp Andjelo
  2013-06-17 18:27     ` Carsten Schoenert
  0 siblings, 1 reply; 7+ messages in thread
From: Filipp Andjelo @ 2013-06-17 18:15 UTC (permalink / raw)
  To: Thomas Petazzoni; +Cc: crossgcc

Hi Thomas,

I didn't set anything special, I think. I think, there has to be some 
setting I'm missing. Which settings do you have according sysroot?
And if you call cross-gcc with --print-sysroot, do you get relative or 
absolute path? I get absolute path to the location I've used to
build the toolchain....

Thanks for your help,
Filipp

On 17.06.2013 16:53, Thomas Petazzoni wrote:
> Dear Filipp Andjelo,
>
> On Mon, 17 Jun 2013 14:40:32 +0000, Filipp Andjelo wrote:
>
>> I built a toolchain using crosstool-ng and it works fine, as far as I
>> don't move it to another folder. I want to have a toolchain, which I can
>> put everywhere, but how?
>> If I run "gcc --print-sysroot", I get absolute path to the directory,
>> where toolchain was built. If I check the same for google's Android
>> toolchain, I get relative path
>> to the gcc. How did they do that?
>>
>> Currently, I have a workaround using CFLAGS="--sysroot=path/to/sysroot",
>> but It's not acceptable solution here.
> Did you do some special configuration to Crosstool-NG? Because by
> default, Crosstool-NG puts the toolchain sysroot is a correct location
> that allows the toolchain to be relocatable. And it works well for me.
>
> Best regards,
>
> Thomas

--
For unsubscribe information see http://sourceware.org/lists.html#faq

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

* Re: Relocatable toolchain
  2013-06-17 18:15   ` Filipp Andjelo
@ 2013-06-17 18:27     ` Carsten Schoenert
  2013-06-17 21:02       ` Filipp Andjelo
  0 siblings, 1 reply; 7+ messages in thread
From: Carsten Schoenert @ 2013-06-17 18:27 UTC (permalink / raw)
  To: Filipp Andjelo; +Cc: crossgcc

Hello Filipp,

Am 17.06.2013 20:15, schrieb Filipp Andjelo:
> Hi Thomas,
> 
> I didn't set anything special, I think. I think, there has to be some 
> setting I'm missing. Which settings do you have according sysroot?
> And if you call cross-gcc with --print-sysroot, do you get relative or 
> absolute path? I get absolute path to the location I've used to
> build the toolchain....

It would be easier if you can show us your crosstool-ng config. :)

And please, don't do top-posting.

Regards
Carsten

--
For unsubscribe information see http://sourceware.org/lists.html#faq

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

* Re: Relocatable toolchain
  2013-06-17 18:27     ` Carsten Schoenert
@ 2013-06-17 21:02       ` Filipp Andjelo
  0 siblings, 0 replies; 7+ messages in thread
From: Filipp Andjelo @ 2013-06-17 21:02 UTC (permalink / raw)
  To: Carsten Schoenert; +Cc: crossgcc

Hello Carsten,

On 17.06.2013 20:27, Carsten Schoenert wrote:
> Hello Filipp,
>
> Am 17.06.2013 20:15, schrieb Filipp Andjelo:
>> Hi Thomas,
>>
>> I didn't set anything special, I think. I think, there has to be some
>> setting I'm missing. Which settings do you have according sysroot?
>> And if you call cross-gcc with --print-sysroot, do you get relative or
>> absolute path? I get absolute path to the location I've used to
>> build the toolchain....
> It would be easier if you can show us your crosstool-ng config. :)
>
> And please, don't do top-posting.
>
> Regards
> Carsten

first, sorry for the top-posting, didn't realize this rule here. I've 
just taken one of the sample configurations and rebuild my toolchain 
from it. Now it seems to work properly, I mean it is relocatable now. I 
have to diff the two configs now to understand the problem. First 
important difference is gcc 4.5.2 vs 4.4.7 and binutils 2.21a vs 2.22. 
Everything else shouldn't make difference... but I'll look more closely 
tomorrow...

Cheers,
Filipp

--
For unsubscribe information see http://sourceware.org/lists.html#faq

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

* Re: Relocatable toolchain
  2013-06-17 14:40 Relocatable toolchain Filipp Andjelo
  2013-06-17 14:53 ` Thomas Petazzoni
@ 2013-06-17 22:36 ` Yann E. MORIN
  2013-06-19  8:14   ` Filipp Andjelo
  1 sibling, 1 reply; 7+ messages in thread
From: Yann E. MORIN @ 2013-06-17 22:36 UTC (permalink / raw)
  To: Filipp Andjelo; +Cc: crossgcc

Filipp, All,

On 2013-06-17 14:40 +0000, Filipp Andjelo spake thusly:
> Hi,
> 
> I built a toolchain using crosstool-ng and it works fine, as far as I 
> don't move it to another folder. I want to have a toolchain, which I can 
> put everywhere, but how?

As Thomas already pointed out, the toolchains built by crosstool-NG
*are* relocatable (well, should be, otherwise this is a bug, but so far
I never encountered such a condition).

> If I run "gcc --print-sysroot", I get absolute path to the directory, 
> where toolchain was built.

This is expected.

The sysroot handling in gcc is a bit tricky (I don't really know the
exact gory details, but here are an excerpt based on experience):
  - gcc first tries to see if it's configured sysroot exists
    - if so, uses it
  - if not, then gcc tries to see if it is running from the location
    it's been configured for
  - if not, gcc apllies to its configured sysroot the same change, and
    uses the new path for the surrent sysroot

For example, let's say gcc was configured with:
    --prefix=/opt/toolchain
    --sysroot=/opt/toolchain/tuple/sysroot

But you then moved the toolchain:
    /opt/toolchain    -->   /some/place/new/base

gcc will see the relocation; then it constructs a relative path to the
sysroot from its configuration:
    /opt/toolchain/tuple/sysroot
    ^^^^^^^^^^^^^^  <- this is gcc's --prefix, so it gets removed.

    /tuple/sysroot    <- this is the relative path to the sysroot.

And gcc now adds its new location in front:
    /some/place/new/base/tuple/sysroot

Note-1: if the sysroot is not a sub-path of the prefix, this will not
work, and the toolchain will not be relocatable. That's why crosstool-NG
insists on not letting the user specify the path to the sysroot in the
menuconfig, and computes it itself.

Note-2: there can be a case where the toolchain has been relocated, but
the original sysroot already exists (eg. another toolchain was built
with the same prefix). In this case, you'd get in much trouble!
Especially if the sysroot of the new toolchain is read-only, you'd get
weird build errors later on, or if it is read-write, you'd get either
weirder build errors, or worse, run-time errors.. Well, I said sysroot
path computation by gcc was tricky, didn't I? ;-)

> If I check the same for google's Android 
> toolchain, I get relative path
> to the gcc. How did they do that?

I don't know why/how Android's toolchains are built thus, but we can't
do it for crosstool-NG (long story made short: canadian builds).

> Currently, I have a workaround using CFLAGS="--sysroot=path/to/sysroot", 
> but It's not acceptable solution here.

No, and this is wrong. The toolchain should be relocatable. Can you
share the .config that produces this non-relocatable toolchain, please?

Regards,
Yann E. MORIN.

-- 
.-----------------.--------------------.------------------.--------------------.
|  Yann E. MORIN  | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software  Designer | \ / CAMPAIGN     |  ___               |
| +33 223 225 172 `------------.-------:  X  AGAINST      |  \e/  There is no  |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL    |   v   conspiracy.  |
'------------------------------^-------^------------------^--------------------'

--
For unsubscribe information see http://sourceware.org/lists.html#faq

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

* Re: Relocatable toolchain
  2013-06-17 22:36 ` Yann E. MORIN
@ 2013-06-19  8:14   ` Filipp Andjelo
  0 siblings, 0 replies; 7+ messages in thread
From: Filipp Andjelo @ 2013-06-19  8:14 UTC (permalink / raw)
  Cc: crossgcc

Hello Yann, hello *,

On 18.06.2013 00:36, Yann E. MORIN wrote:
> Filipp, All,
>
> On 2013-06-17 14:40 +0000, Filipp Andjelo spake thusly:
>> Hi,
>>
>> I built a toolchain using crosstool-ng and it works fine, as far as I
>> don't move it to another folder. I want to have a toolchain, which I can
>> put everywhere, but how?
> As Thomas already pointed out, the toolchains built by crosstool-NG
> *are* relocatable (well, should be, otherwise this is a bug, but so far
> I never encountered such a condition).
>
>> If I run "gcc --print-sysroot", I get absolute path to the directory,
>> where toolchain was built.
> This is expected.
>
> The sysroot handling in gcc is a bit tricky (I don't really know the
> exact gory details, but here are an excerpt based on experience):
>    - gcc first tries to see if it's configured sysroot exists
>      - if so, uses it
>    - if not, then gcc tries to see if it is running from the location
>      it's been configured for
>    - if not, gcc apllies to its configured sysroot the same change, and
>      uses the new path for the surrent sysroot
>
> For example, let's say gcc was configured with:
>      --prefix=/opt/toolchain
>      --sysroot=/opt/toolchain/tuple/sysroot
>
> But you then moved the toolchain:
>      /opt/toolchain    -->   /some/place/new/base
>
> gcc will see the relocation; then it constructs a relative path to the
> sysroot from its configuration:
>      /opt/toolchain/tuple/sysroot
>      ^^^^^^^^^^^^^^  <- this is gcc's --prefix, so it gets removed.
>
>      /tuple/sysroot    <- this is the relative path to the sysroot.
>
> And gcc now adds its new location in front:
>      /some/place/new/base/tuple/sysroot
>
> Note-1: if the sysroot is not a sub-path of the prefix, this will not
> work, and the toolchain will not be relocatable. That's why crosstool-NG
> insists on not letting the user specify the path to the sysroot in the
> menuconfig, and computes it itself.
>
> Note-2: there can be a case where the toolchain has been relocated, but
> the original sysroot already exists (eg. another toolchain was built
> with the same prefix). In this case, you'd get in much trouble!
> Especially if the sysroot of the new toolchain is read-only, you'd get
> weird build errors later on, or if it is read-write, you'd get either
> weirder build errors, or worse, run-time errors.. Well, I said sysroot
> path computation by gcc was tricky, didn't I? ;-)
>
>> If I check the same for google's Android
>> toolchain, I get relative path
>> to the gcc. How did they do that?
> I don't know why/how Android's toolchains are built thus, but we can't
> do it for crosstool-NG (long story made short: canadian builds).
>
>> Currently, I have a workaround using CFLAGS="--sysroot=path/to/sysroot",
>> but It's not acceptable solution here.
> No, and this is wrong. The toolchain should be relocatable. Can you
> share the .config that produces this non-relocatable toolchain, please?
>
> Regards,
> Yann E. MORIN.
>

thank you very much for the detailed explanation, it's very informative! 
As I said, I rebuilt the toolchain using similar sample configuration 
and that worked as expected. Then I tried to find the important 
difference, but didn't find anything. So I took my config again and made 
completely clean trial. And now it works as expected..... I can't 
explain that, nor I can reproduce the state.... I hate magic :)

If I get it reproduced one day and/or get more info about it, I'll write 
again. Nevertheless, thanks a lot for your help!

Cheers,
Filipp

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

end of thread, other threads:[~2013-06-19  8:14 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-06-17 14:40 Relocatable toolchain Filipp Andjelo
2013-06-17 14:53 ` Thomas Petazzoni
2013-06-17 18:15   ` Filipp Andjelo
2013-06-17 18:27     ` Carsten Schoenert
2013-06-17 21:02       ` Filipp Andjelo
2013-06-17 22:36 ` Yann E. MORIN
2013-06-19  8:14   ` Filipp Andjelo

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).