This is the mail archive of the crossgcc@sourceware.org mailing list for the crossgcc project.

See the CrossGCC FAQ for lots more information.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: "building binutils for target" question


Michael, All,

On Friday 25 March 2011 18:19:34 Michael Zintakis wrote:
> In my case, fortunately (or unfortunately, depending if a newbie like me 
> has to do it) the answer is 'yes' as the target machine would need to 
> compile and run programs using gcc, so I have to prepare everything on 
> the (powerful) x86_64 arch machine, build the image, deploy it to the 
> target powerpc and then let that machine do its business.

OK. So you can build your cross-toolchain with crosstool-NG, that's
supported. But for building the cross-native compiler to run on your
PPC, you'll mostly be on your own; crostool-NG won't help you much...

> >   make DESTDIR=/some/place/staging
> >   (note: you may need to pass additional CFLAGS and LDFLAGS, such as:
> >     CFLAGS="-I/some/place/staging/usr/include -I/some/place/staging/include"
> >     LDFLAGS="-L/some/place/staging/lib -L/some/place/staging/usr/lib"
> >   )
> >   
> In your last "make" statement presumably you meant "make 
> DESTDIR=/some/place/staging install" right?

Yes, of course! :-)

> As for the CFLAGS/LDFLAGS includes that is a given, although I am 
> thinking if I run with chroot to /some/place/staging and then execute 
> make install then I won't be needing this, right? I might be wrong though!

You can't use a chroot: the chroot you'd like to chroot into is a PPC
system, while the machine you're running on is an x86_64...

> I know, I've read all of the doc files and I am also aware of the 
> populate tool, but to me it seemed a bit of a chicken-and-egg scenario - 
> you need to build the tools in the staging area in order to use this 
> script, but in effect I can't build the tools if I do not have the core 
> libraries...

Hmmm... Sorry, I'm missing something here...
Of course you do have the system libraries: they are in the sysroot of
the cross-toolchain.

> But as you pointed out below, if I just copy all of the toolchain's 
> sysroot to my staging area I won't need any of this, right? Would that 
> mean that I do not have to install the kernel headers for the target 
> machine as well?

Eactly. Copy the sysroot to your staging, you'll get all the system stuff:
- headers from the kernel
- headers from the libc
- libs from the libc

> > You would need to build the native gcc using the already built sysroot. Just
> > copy the sysroot of the cross-toolchain, and use that copy to configure gcc.
> > You could start by creating your staging by entirely copying the sysroot
> > as-is, and then configure gcc with --disable-sysroot and --with-build-sysroot
> > that points to the staging.
> >   
> And also presumably using --with-headers as well, right?

--with-headers is deprecated in favor of --with-sysroot.
Anyway, --with-headers is only needed when building a cross-compiler, and
you want to build a _native_ compiler. Sure, you are cross-compiling your
compiler, but in the end, this compiler is a native one.

> True, but are there any drawback with using this approach (it is a given 
> that I may copy something, which I won't be needing on the target machine)?

If you want to run the compiler on the target, then you will need the full
content of the sysroot to be present on the target: system headers & system
libraries.

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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]