Skip to contentSkip to conversation

Issue for the integration of Codesourcery external toolchains

Buildroot Thomas Petazzoni 4 participants 11 messages Jan 4, 2010 – Jan 12, 2010

lore
Share & tools
lore
#0 lore raw

Hello,

Now that the new package infrastructure has been integrated, I started working again on the usage of Codesourcery toolchains as external toolchains in Buildroot. Compared to the Crosstool-NG toolchains that we already support, the main difference is that the Codesoucery toolchains are multilib.

Unfortunately, I'm facing an issue for which I haven't found an issue and I'm therefore asking for your input and ideas on the matter.

External toolchains in Buildroot
================================

The external toolchain integration code is in toolchain/external-toolchain/ext-tool.mk. As the comment at the top of the file says, we basically do three things:

1. Do various checks of the toolchain and the compatibility between the options configured in Buildroot and the configuration of the toolchain.

One of the important check we do is to verify that the toolchain supports the sysroot mechanism. This mechanism allows to copy all the libraries and headers of the toolchain in another location, and using the --sysroot option, tell the compiler/linker where these files are located now. The location of the original sysroot directory is found by running CROSS-gcc -v and looking at the --with-sysroot configuration option of gcc.

2. From the toolchain, we copy the C library and other related libraries needed at runtime into $(TARGET_DIR). This will ensure that these libraries will be available on the target.

We assume that these libraries are available in the lib/ directory of the original sysroot directory. The list of library to copy is taken from a fixed list (EXTERNAL_LIBS in the code)

3. Finally, we copy the _complete_ sysroot directory into $(STAGING_DIR). This allows to keep *all* libraries and headers (C library but also other userspace libraries compiled later) into the same directory. This solution makes it very easy to support external toolchains, since we then only have to pass the --sysroot $(STAGING_DIR) option to the compiler.

For reference, when we introduced external toolchain support, we tried the solution to keep the C library/headers in their original location, and with a combination of -I/-L option, point the compiler/linker to the $(STAGING_DIR). But this solution raised a lot of problems that we easily solved by using --sysroot.

Codesoucery toolchains
======================

The Codesourcery toolchain (at least the arm2009q1 I've been testing) are multilib toolchains. This means that within a single toolchain, several variants of the C library are available:

$ arm-none-linux-gnueabi-gcc -print-multi-lib
.;
armv4t;@march=armv4t
thumb2;@mthumb at march=armv7

We have one default variant, one variant for armv4t which is selected when -march=armv4t is passed on the gcc command line, and one variant for thumb2, which is selected when -mthumb -march=armv7 is passed on the gcc command line.

Each variant is associated with a different sysroot:

$ arm-none-linux-gnueabi-gcc -print-sysroot
/usr/local/xtools/arm-2009q1/bin/../arm-none-linux-gnueabi/libc
$ arm-none-linux-gnueabi-gcc -print-sysroot -march=armv4t
/usr/local/xtools/arm-2009q1/bin/../arm-none-linux-gnueabi/libc/armv4t
$ arm-none-linux-gnueabi-gcc -print-sysroot -march=armv7 -mthumb
/usr/local/xtools/arm-2009q1/bin/../arm-none-linux-gnueabi/libc/thumb2

(Note: /usr/local/xtools/arm-2009q1/ is where I installed the toolchain)

Issue with the Codesourcery toolchain
=====================================

The first obvious option that I tried was to copy the sysroot that correspond to the selected architecture. For example, copy only the contents of /usr/local/xtools/arm-2009q1/bin/../arm-none-linux-gnueabi/libc/armv4t to $(STAGING_DIR). Unfortunately, this doesn't work, since the header files are shared between the three sysroots (the armv4t and thumb2 directories do not contain any header files).

So there is no other choice that copying the full /usr/local/xtools/arm-2009q1/bin/../arm-none-linux-gnueabi/libc directory. This is the solution I implemented.

Unfortunately, when you do this, you have the following hierarchy in $(STAGING_DIR):

* armv4t
* lib
* usr
* lib
* lib
* thumb2
* lib
* usr
* lib
* usr
* include
* lib

When the armv5t architecture is selected, everything works as
expected: the includes are in $(STAGING_DIR)/usr/include, the libraries in $(STAGING_DIR)/lib and $(STAGING_DIR)/usr/lib.

When armv4t is selected, the include files are in $(STAGING_DIR)/usr/include, but the libraries are in $(STAGING_DIR)/armv4t/lib and $(STAGING_DIR)/armv4t/usr/lib. And the linker *only* looks in these directories for the libraries.

Unfortunately, all Buildroot packages install their libraries in $(STAGING_DIR)/lib and $(STAGING_DIR)/usr/lib, so the linker doesn't find them.

For example, compiling zlib works, but compiling libpng fails because it cannot find zlib. This is because zlib has been installed in $(STAGING_DIR)/usr/lib and not in $(STAGING_DIR)/armv4t/usr/lib.

Possible solutions
==================

* Build a more normal sysroot in $(STAGING_DIR) by combining the contents of armv4t and the header files. But this would require telling gcc that the libraries aren't in armv4t anymore. This is probably possible using a custom spec file, but is quite complicated.

* Reconsider the solution of copying the sysroot, and try harder with the more traditionnal -L/-I solutions.

* Another solution ?

Thanks for reading such a long mail, and thanks in advance for your ideas!

Thomas Petazzoni

Signature · 4 lines
Thomas Petazzoni, Free Electrons
Kernel, drivers and embedded Linux development,
consulting, training and support.
http://free-electrons.com
#1 lore raw

Le lundi 04 janvier 2010 ? 16:24 +0100, Thomas Petazzoni a ?crit :

Quoted 130 lines

Hello,

Now that the new package infrastructure has been integrated, I started working again on the usage of Codesourcery toolchains as external toolchains in Buildroot. Compared to the Crosstool-NG toolchains that we already support, the main difference is that the Codesoucery toolchains are multilib.

Unfortunately, I'm facing an issue for which I haven't found an issue and I'm therefore asking for your input and ideas on the matter.

External toolchains in Buildroot
================================

The external toolchain integration code is in toolchain/external-toolchain/ext-tool.mk. As the comment at the top of the file says, we basically do three things:

1. Do various checks of the toolchain and the compatibility between the options configured in Buildroot and the configuration of the toolchain.

One of the important check we do is to verify that the toolchain supports the sysroot mechanism. This mechanism allows to copy all the libraries and headers of the toolchain in another location, and using the --sysroot option, tell the compiler/linker where these files are located now. The location of the original sysroot directory is found by running CROSS-gcc -v and looking at the --with-sysroot configuration option of gcc.

2. From the toolchain, we copy the C library and other related libraries needed at runtime into $(TARGET_DIR). This will ensure that these libraries will be available on the target.

We assume that these libraries are available in the lib/ directory of the original sysroot directory. The list of library to copy is taken from a fixed list (EXTERNAL_LIBS in the code)

3. Finally, we copy the _complete_ sysroot directory into $(STAGING_DIR). This allows to keep *all* libraries and headers (C library but also other userspace libraries compiled later) into the same directory. This solution makes it very easy to support external toolchains, since we then only have to pass the --sysroot $(STAGING_DIR) option to the compiler.

For reference, when we introduced external toolchain support, we tried the solution to keep the C library/headers in their original location, and with a combination of -I/-L option, point the compiler/linker to the $(STAGING_DIR). But this solution raised a lot of problems that we easily solved by using --sysroot.

Codesoucery toolchains
======================

The Codesourcery toolchain (at least the arm2009q1 I've been testing) are multilib toolchains. This means that within a single toolchain, several variants of the C library are available:

$ arm-none-linux-gnueabi-gcc -print-multi-lib
.;
armv4t;@march=armv4t
thumb2;@mthumb at march=armv7

We have one default variant, one variant for armv4t which is selected when -march=armv4t is passed on the gcc command line, and one variant for thumb2, which is selected when -mthumb -march=armv7 is passed on the gcc command line.

Each variant is associated with a different sysroot:

$ arm-none-linux-gnueabi-gcc -print-sysroot
/usr/local/xtools/arm-2009q1/bin/../arm-none-linux-gnueabi/libc
$ arm-none-linux-gnueabi-gcc -print-sysroot -march=armv4t
/usr/local/xtools/arm-2009q1/bin/../arm-none-linux-gnueabi/libc/armv4t
$ arm-none-linux-gnueabi-gcc -print-sysroot -march=armv7 -mthumb
/usr/local/xtools/arm-2009q1/bin/../arm-none-linux-gnueabi/libc/thumb2

(Note: /usr/local/xtools/arm-2009q1/ is where I installed the toolchain)

Issue with the Codesourcery toolchain
=====================================

The first obvious option that I tried was to copy the sysroot that correspond to the selected architecture. For example, copy only the contents of /usr/local/xtools/arm-2009q1/bin/../arm-none-linux-gnueabi/libc/armv4t to $(STAGING_DIR). Unfortunately, this doesn't work, since the header files are shared between the three sysroots (the armv4t and thumb2 directories do not contain any header files).

So there is no other choice that copying the full /usr/local/xtools/arm-2009q1/bin/../arm-none-linux-gnueabi/libc directory. This is the solution I implemented.

Unfortunately, when you do this, you have the following hierarchy in $(STAGING_DIR):

* armv4t
* lib
* usr
* lib
* lib
* thumb2
* lib
* usr
* lib
* usr
* include
* lib

When the armv5t architecture is selected, everything works as
expected: the includes are in $(STAGING_DIR)/usr/include, the libraries in $(STAGING_DIR)/lib and $(STAGING_DIR)/usr/lib.

When armv4t is selected, the include files are in $(STAGING_DIR)/usr/include, but the libraries are in $(STAGING_DIR)/armv4t/lib and $(STAGING_DIR)/armv4t/usr/lib. And the linker *only* looks in these directories for the libraries.

Unfortunately, all Buildroot packages install their libraries in $(STAGING_DIR)/lib and $(STAGING_DIR)/usr/lib, so the linker doesn't find them.

For example, compiling zlib works, but compiling libpng fails because it cannot find zlib. This is because zlib has been installed in $(STAGING_DIR)/usr/lib and not in $(STAGING_DIR)/armv4t/usr/lib.

Quoted 8 lines

Possible solutions
==================

* Build a more normal sysroot in $(STAGING_DIR) by combining the contents of armv4t and the header files. But this would require telling gcc that the libraries aren't in armv4t anymore. This is probably possible using a custom spec file, but is quite complicated.

To me, probably the best solution...
But why would it require a custom spec file ? --sysroot doesn't change the headers and librairies' default path in that case ?

Quoted 3 lines

* Reconsider the solution of copying the sysroot, and try harder with the more traditionnal -L/-I solutions.

Ergh...
For more we would need a different treatment for codesourcery toolchains and "normal" toolchains. Sounds a bit like a nightmare... (Am I wrong ?)

Quoted 5 lines

* Another solution ?

Thanks for reading such a long mail, and thanks in advance for your ideas!

I never worked with codesourcery's toolchains (as not working with ARM chips).
Is the set of toolchain you're using available somewhere ?

Quoted 2 lines

Thomas Petazzoni

<Not_so_related>

By the way, we still have some problem with the current scripts setting up the staging/target directories. Maybe I'm the only one who noticed/has_a_strange_setup...

Just like every other linker script :

	$(STAGING_DIR)/usr/lib/libpthread.so
	$(STAGING_DIR)/usr/lib/libc.so

might be processed to replace the default path, usually /lib/libc.so, by $(STAGING_DIR)/lib/libc.so.
We also need to copy thoses linker scripts to the target directory. Otherwise you generate some kind of fucked up binaries when installing librairies in target using libtool. In particular with the pthread_* symbols, because some of them are defined in libc.so as weak symbols. So you end up having librairies calling libc's weak symbols which volontary crash because they might be replaced by the pthread's ones when pthread.so is loaded.

I didn't noticed the problem with basic monothreaded tools (busybox, bash, etc...), until I compile things like directfb which crashes incomprehensibly early at startup.

Fixing this kind of problem is on my todo list, but I don't have a lot of free time these days to make a clean fix. I wanted to let people know, so they don't spend 2/3 days finding that kind of vicious bugs (whether we can consider that as a bug) ...

</Not_so_related>

Signature · 1 line
Lionel Landwerlin
#2 lore raw

Hello,

Thanks for your input!

Quoted 3 lines · On Tue, 05 Jan 2010 00:23:35 +0100 Lionel Landwerlin <[email protected]>…

To me, probably the best solution...
But why would it require a custom spec file ? --sysroot doesn't change the headers and librairies' default path in that case ?

--sysroot changes it, but the toolchain continues to append /armv4t at the end:

$ /usr/local/xtools/arm-2009q1/bin/arm-none-linux-gnueabi-gcc --sysroot=/foo/bar -print-sysroot
/foo/bar
$ /usr/local/xtools/arm-2009q1/bin/arm-none-linux-gnueabi-gcc -march=armv4t --sysroot=/foo/bar -print-sysroot
/foo/bar/armv4t

See ?

Which is why I was talking about hacking the specs file. But I'm still not there.

With the original spec file:

$ /usr/local/xtools/arm-2009q1/bin/arm-none-linux-gnueabi-gcc -specs=spec.orig -march=armv4t -print-multi-directory
armv4t

With a modified spec file:

$ /usr/local/xtools/arm-2009q1/bin/arm-none-linux-gnueabi-gcc -specs=spec -march=armv4t -print-multi-directory
.

Which looks good. But then:

$ /usr/local/xtools/arm-2009q1/bin/arm-none-linux-gnueabi-gcc -specs=spec -march=armv4t --sysroot=/foo/bar -print-sysroot
/foo/bar/armv4t

Still not working. So even by hacking the spec file I'm not able to get the proper behaviour.

So maybe our solution of using --sysroot is ugly and we should fall back to the solution where the toolchain sysroot is kept in its original location and we just use -L/-I to indicate where our staging directory is (solution which has proved in the past to be fairly difficult to stabilize).

I really don't know how we should move forward.

Quoted 6 lines
Quoted 2 lines

Thanks for reading such a long mail, and thanks in advance for your ideas!

I never worked with codesourcery's toolchains (as not working with ARM chips).
Is the set of toolchain you're using available somewhere ?

Yes, you can go to http://www.codesourcery.com/sgpp_eval.html and register for a free evaluation.

Quoted 6 lines

<Not_so_related>

By the way, we still have some problem with the current scripts setting up the staging/target directories. Maybe I'm the only one who noticed/has_a_strange_setup...

Quoted 7 lines

Just like every other linker script :

	$(STAGING_DIR)/usr/lib/libpthread.so
	$(STAGING_DIR)/usr/lib/libc.so

might be processed to replace the default path, usually /lib/libc.so, by $(STAGING_DIR)/lib/libc.so.

Isn't this the "rpath" problem ?

Quoted 1 line

We also need to copy thoses linker scripts to the target directory.

I'm not sure which linker scripts you're talking about.

Quoted 6 lines

Otherwise you generate some kind of fucked up binaries when installing librairies in target using libtool. In particular with the pthread_* symbols, because some of them are defined in libc.so as weak symbols. So you end up having librairies calling libc's weak symbols which volontary crash because they might be replaced by the pthread's ones when pthread.so is loaded.

I'm sorry, but I didn't understand what the problem is, under which conditions it appears, and what the fix for it is (even if it's a quick and hacky fix).

Thanks,

Thomas

Signature · 4 lines
Thomas Petazzoni, Free Electrons
Kernel, drivers, real-time and embedded Linux
development, consulting, training and support.
http://free-electrons.com
#3 lore raw

Hello Thomas,
All,

Quoted 5 lines · On Tuesday 12 January 2010 11:52:28 Thomas Petazzoni wrote:

So maybe our solution of using --sysroot is ugly and we should fall back to the solution where the toolchain sysroot is kept in its original location and we just use -L/-I to indicate where our staging directory is (solution which has proved in the past to be fairly difficult to stabilize).

Well, for what it's worth, here's an (embrio of an) idea:

1) do not copy the sysroot to staging, trust gcc to find it properly
2) add a kind of wrapper to gcc (et al.) that basically does the following:

---8<---
#!/bin/sh

exec real-gcc -L "${STAGING_DIR}"{,/usr}/lib    \
                  -I "${STAGING_DIR}"/usr/include   \
                  "$@"

---8<---

That way, we always have out staging/lib and staging/usr/lib in the library search path; ditto for the include search path.

It should work with whatever toolchain we're using, internaly-built or external. And that means a single way of handling things.

Finally, when the staging is full, we can /overlay/ with a copy of the original sysroot libs we get from gcc --print-sysroot

Of course, that's far from being complete!

HTH...

Regards,
Yann E. MORIN.

Signature · 6 lines
.-----------------.--------------------.------------------.--------------------.
|  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.  |
`------------------------------^-------^------------------^--------------------'
#4 lore raw
Quoted 6 lines · On Tue, 12 Jan 2010 23:09:41 +0100 "Yann E. MORIN"…

1) do not copy the sysroot to staging, trust gcc to find it properly
2) add a kind of wrapper to gcc (et al.) that basically does the following:

---8<---
#!/bin/sh

Quoted 7 lines
exec real-gcc -L "${STAGING_DIR}"{,/usr}/lib    \
                  -I "${STAGING_DIR}"/usr/include   \
                  "$@"

---8<---

That way, we always have out staging/lib and staging/usr/lib in the library search path; ditto for the include search path.

This is the approach we tried first to support external toolchains, before switching to the current solution using --sysroot.

If you look at my original mail in this thread, the second solution I was proposing is:

* Reconsider the solution of copying the sysroot, and try harder with the more traditionnal -L/-I solutions.

As it says, we had some difficulties with the -L/-I solutions that couldn't be solved easily, and --sysroot was easier. But we can decide to go backward and try to fix the problems encountered with the -L/-I solution. Even with -L/-I, gcc was sometimes not finding libraries, and we had to start using things such as --rpath-link, which proved to be very complicated. I don't remember the exact packages and cases that were causing problems.

Regards,

Thomas

Signature · 4 lines
Thomas Petazzoni, Free Electrons
Kernel, drivers, real-time and embedded Linux
development, consulting, training and support.
http://free-electrons.com
#5 lore raw
In reply to Thomas Petazzoni

Le mardi 12 janvier 2010 ? 11:52 +0100, Thomas Petazzoni a ?crit :

Quoted 69 lines

Hello,

Thanks for your input!

Quoted 3 lines · On Tue, 05 Jan 2010 00:23:35 +0100 Lionel Landwerlin <[email protected]>…

To me, probably the best solution...
But why would it require a custom spec file ? --sysroot doesn't change the headers and librairies' default path in that case ?

--sysroot changes it, but the toolchain continues to append /armv4t at the end:

$ /usr/local/xtools/arm-2009q1/bin/arm-none-linux-gnueabi-gcc --sysroot=/foo/bar -print-sysroot
/foo/bar
$ /usr/local/xtools/arm-2009q1/bin/arm-none-linux-gnueabi-gcc -march=armv4t --sysroot=/foo/bar -print-sysroot
/foo/bar/armv4t

See ?

Which is why I was talking about hacking the specs file. But I'm still not there.

With the original spec file:

$ /usr/local/xtools/arm-2009q1/bin/arm-none-linux-gnueabi-gcc -specs=spec.orig -march=armv4t -print-multi-directory
armv4t

With a modified spec file:

$ /usr/local/xtools/arm-2009q1/bin/arm-none-linux-gnueabi-gcc -specs=spec -march=armv4t -print-multi-directory
.

Which looks good. But then:

$ /usr/local/xtools/arm-2009q1/bin/arm-none-linux-gnueabi-gcc -specs=spec -march=armv4t --sysroot=/foo/bar -print-sysroot
/foo/bar/armv4t

Still not working. So even by hacking the spec file I'm not able to get the proper behaviour.

So maybe our solution of using --sysroot is ugly and we should fall back to the solution where the toolchain sysroot is kept in its original location and we just use -L/-I to indicate where our staging directory is (solution which has proved in the past to be fairly difficult to stabilize).

I really don't know how we should move forward.

Quoted 6 lines
Quoted 2 lines

Thanks for reading such a long mail, and thanks in advance for your ideas!

I never worked with codesourcery's toolchains (as not working with ARM chips).
Is the set of toolchain you're using available somewhere ?

Yes, you can go to http://www.codesourcery.com/sgpp_eval.html and register for a free evaluation.

Quoted 8 lines

<Not_so_related>

By the way, we still have some problem with the current scripts setting up the staging/target directories. Maybe I'm the only one who noticed/has_a_strange_setup...

Just like every other linker script :

Quoted 7 lines
Quoted 5 lines
	$(STAGING_DIR)/usr/lib/libpthread.so
	$(STAGING_DIR)/usr/lib/libc.so

might be processed to replace the default path, usually /lib/libc.so, by $(STAGING_DIR)/lib/libc.so.

Isn't this the "rpath" problem ?

Hmmm I don't know...
Let me clarify the linker script problem.

When a new library (libplop for example) is installed, its libplop.la is processed to replace

libdir='/usr/lib'

by

libdir='$(STAGING_DIR)/usr/lib'

but when it comes to libc and libpthread, it's not (probably because of the copy of the sysroot directory to the staging directory).

$(STAGING_DIR)/usr/lib/libc.so should be processed to replace

/* GNU ld script
Use the shared library, but some functions are only in
the static library, so try that secondarily. */
OUTPUT_FORMAT(elf32-sh-linux)
GROUP ( /lib/libc.so.6 /lib/libc_nonshared.a AS_NEEDED ( /lib/ld-linux.so.2 ) )

by

/* GNU ld script
Use the shared library, but some functions are only in
the static library, so try that secondarily. */
OUTPUT_FORMAT(elf32-sh-linux)
GROUP ( $(STAGING_DIR)/lib/libc.so.6 $(STAGING_DIR)/lib/libc_nonshared.a AS_NEEDED ( $(STAGING_DIR)/lib/ld-linux.so.2 ) )

Same thing for $(STAGING_DIR)/usr/lib/libpthread.so.

Am I the only one who's external toolchain includes linker scripts in /usr/lib/ for libc/libpthread ? :)

Quoted 4 lines
Quoted 2 lines

We also need to copy thoses linker scripts to the target directory.

I'm not sure which linker scripts you're talking about.

Again $(STAGING_DIR)/usr/lib/libc.so and
$(STAGING_DIR)/usr/lib/libpthread.so.

Quoted 15 lines
Quoted 7 lines

Otherwise you generate some kind of fucked up binaries when installing librairies in target using libtool. In particular with the pthread_* symbols, because some of them are defined in libc.so as weak symbols. So you end up having librairies calling libc's weak symbols which volontary crash because they might be replaced by the pthread's ones when pthread.so is loaded.

I'm sorry, but I didn't understand what the problem is, under which conditions it appears, and what the fix for it is (even if it's a quick and hacky fix).

Thanks,

Thomas

#6 lore raw
In reply to Thomas Petazzoni

Hi Thomas,

Thanks for you work on this. My comment below.

On Mon, Jan 04, 2010 at 04:24:22PM +0100, Thomas Petazzoni wrote:

[snip]

Quoted 8 lines

Possible solutions
==================

* Build a more normal sysroot in $(STAGING_DIR) by combining the contents of armv4t and the header files. But this would require telling gcc that the libraries aren't in armv4t anymore. This is probably possible using a custom spec file, but is quite complicated.

How about generating symlinks in the staging directory:

armv4t/usr/include -> ../../usr/include
thumb2/usr/include -> ../../usr/include

and then using the output of -print-sysroot for each target?

Quoted 8 lines

* Reconsider the solution of copying the sysroot, and try harder with the more traditionnal -L/-I solutions.

* Another solution ?

Thanks for reading such a long mail, and thanks in advance for your ideas!

baruch

Signature · 3 lines
                                                     ~. .~   Tk Open Systems
=}------------------------------------------------ooO--U--Ooo------------{=
   - baruch at tkos.co.il - tel: +972.2.679.5364, http://www.tkos.co.il -
#7 lore raw
Quoted 6 lines · On Wed, 6 Jan 2010 08:59:53 +0200 Baruch Siach <[email protected]> wrote:
Quoted 5 lines

* Build a more normal sysroot in $(STAGING_DIR) by combining the contents of armv4t and the header files. But this would require telling gcc that the libraries aren't in armv4t anymore. This is probably possible using a custom spec file, but is quite complicated.

Quoted 6 lines

How about generating symlinks in the staging directory:

armv4t/usr/include -> ../../usr/include
thumb2/usr/include -> ../../usr/include

and then using the output of -print-sysroot for each target?

Because everything in Buildroot assumes that the libraries and headers must be installed in $(STAGING_DIR)/usr/include and $(STAGING_DIR)/usr/lib, not in $(STAGING_DIR)/armv4/usr/include and $(STAGING_DIR)/armv4/usr/lib.

See the following part of my original e-mail:

==============================================
When the armv5t architecture is selected, everything works as
expected: the includes are in $(STAGING_DIR)/usr/include, the libraries in $(STAGING_DIR)/lib and $(STAGING_DIR)/usr/lib.

When armv4t is selected, the include files are in $(STAGING_DIR)/usr/include, but the libraries are in $(STAGING_DIR)/armv4t/lib and $(STAGING_DIR)/armv4t/usr/lib. And the linker *only* looks in these directories for the libraries.

Unfortunately, all Buildroot packages install their libraries in $(STAGING_DIR)/lib and $(STAGING_DIR)/usr/lib, so the linker doesn't find them.

For example, compiling zlib works, but compiling libpng fails because it cannot find zlib. This is because zlib has been installed in $(STAGING_DIR)/usr/lib and not in $(STAGING_DIR)/armv4t/usr/lib.
==============================================

Thanks for the feedback!

Thomas

Signature · 4 lines
Thomas Petazzoni, Free Electrons
Kernel, drivers, real-time and embedded Linux
development, consulting, training and support.
http://free-electrons.com
#8 lore raw

Hi Thomas,

Quoted 14 lines · Thomas Petazzoni
Quoted 11 lines · On Wed, 6 Jan 2010 08:59:53 +0200 Baruch Siach <[email protected]> wrote:
Quoted 5 lines

* Build a more normal sysroot in $(STAGING_DIR) by combining the contents of armv4t and the header files. But this would require telling gcc that the libraries aren't in armv4t anymore. This is probably possible using a custom spec file, but is quite complicated.

How about generating symlinks in the staging directory:

armv4t/usr/include -> ../../usr/include
thumb2/usr/include -> ../../usr/include

Quoted 6 lines
Quoted 1 line

and then using the output of -print-sysroot for each target?

Because everything in Buildroot assumes that the libraries and headers must be installed in $(STAGING_DIR)/usr/include and $(STAGING_DIR)/usr/lib, not in $(STAGING_DIR)/armv4/usr/include and $(STAGING_DIR)/armv4/usr/lib.

I'll clarify. I suggest the following steps:

1. Copy the entire CodeSourcery sysroot (as reported by -print-sysroot) into $(STAGING_DIR).

2. Create the following symlinks:

    $(STAGING_DIR)/armv4t/usr/include -> ../../usr/include
    $(STAGING_DIR)/thumb2/usr/include -> ../../usr/include

3. Set as necessary:

    STAGING_DIR=$(STAGING_DIR)/armv4t

    or

    STAGING_DIR=$(STAGING_DIR)/thumb2

Buildroot then sees libraries and headers in $(STAGING_DIR)/usr/lib and $(STAGING_DIR)/usr/include respectively, as expected.

baruch

Signature · 3 lines
                                                     ~. .~   Tk Open Systems
=}------------------------------------------------ooO--U--Ooo------------{=
   - baruch at tkos.co.il - tel: +972.2.679.5364, http://www.tkos.co.il -
#9 lore raw
Quoted 26 lines · Baruch Siach

Hi Thomas,

Quoted 14 lines · Thomas Petazzoni
Quoted 11 lines · On Wed, 6 Jan 2010 08:59:53 +0200 Baruch Siach <[email protected]> wrote:
Quoted 5 lines

* Build a more normal sysroot in $(STAGING_DIR) by combining the contents of armv4t and the header files. But this would require telling gcc that the libraries aren't in armv4t anymore. This is probably possible using a custom spec file, but is quite complicated.

How about generating symlinks in the staging directory:

armv4t/usr/include -> ../../usr/include
thumb2/usr/include -> ../../usr/include

Quoted 6 lines
Quoted 1 line

and then using the output of -print-sysroot for each target?

Because everything in Buildroot assumes that the libraries and headers must be installed in $(STAGING_DIR)/usr/include and $(STAGING_DIR)/usr/lib, not in $(STAGING_DIR)/armv4/usr/include and $(STAGING_DIR)/armv4/usr/lib.

I'll clarify. I suggest the following steps:

Quoted 9 lines

1. Copy the entire CodeSourcery sysroot (as reported by -print-sysroot) into
$(STAGING_DIR).

2. Create the following symlinks:

   $(STAGING_DIR)/armv4t/usr/include -> ../../usr/include
   $(STAGING_DIR)/thumb2/usr/include -> ../../usr/include

Or just

       $(STAGING_DIR)/armv4t/ -> $(STAGING_DIR)

;)

Quoted 14 lines

3. Set as necessary:

   STAGING_DIR=$(STAGING_DIR)/armv4t
   or

   STAGING_DIR=$(STAGING_DIR)/thumb2

Buildroot then sees libraries and headers in $(STAGING_DIR)/usr/lib and $(STAGING_DIR)/usr/include respectively, as expected.

baruch

Quoted 9 lines

--
~. .~ Tk Open Systems
=}------------------------------------------------ooO--U--Ooo------------{=
- baruch at tkos.co.il - tel: +972.2.679.5364, http://www.tkos.co.il -
_______________________________________________
buildroot mailing list
buildroot at busybox.net
http://lists.busybox.net/mailman/listinfo/buildroot

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.busybox.net/pipermail/buildroot/attachments/20100112/3eb3e2ba/attachment.htm>

#10 lore raw

Hi Lionel,

Quoted 31 lines · Lionel Landwerlin
Quoted 30 lines · Baruch Siach
Quoted 14 lines · Thomas Petazzoni
Quoted 11 lines · On Wed, 6 Jan 2010 08:59:53 +0200 Baruch Siach <[email protected]> wrote:
Quoted 5 lines

* Build a more normal sysroot in $(STAGING_DIR) by combining the contents of armv4t and the header files. But this would require telling gcc that the libraries aren't in armv4t anymore. This is probably possible using a custom spec file, but is quite complicated.

How about generating symlinks in the staging directory:

armv4t/usr/include -> ../../usr/include
thumb2/usr/include -> ../../usr/include

Quoted 6 lines
Quoted 1 line

and then using the output of -print-sysroot for each target?

Because everything in Buildroot assumes that the libraries and headers must be installed in $(STAGING_DIR)/usr/include and $(STAGING_DIR)/usr/lib, not in $(STAGING_DIR)/armv4/usr/include and $(STAGING_DIR)/armv4/usr/lib.

I'll clarify. I suggest the following steps:

1. Copy the entire CodeSourcery sysroot (as reported by -print-sysroot) into
$(STAGING_DIR).

2. Create the following symlinks:

Quoted 8 lines
Quoted 3 lines
   $(STAGING_DIR)/armv4t/usr/include -> ../../usr/include
   $(STAGING_DIR)/thumb2/usr/include -> ../../usr/include

Or just

       $(STAGING_DIR)/armv4t/ -> $(STAGING_DIR)

;)

Probably not. The $(STAGING_DIR)/armv4t directory is a real one containing the ARMv4T version of the standard shared libraries in $(STAGING_DIR)/armv4t/lib and $(STAGING_DIR)/armv4t/usr/lib.

baruch

Quoted 13 lines
Quoted 13 lines

3. Set as necessary:

   STAGING_DIR=$(STAGING_DIR)/armv4t
   or

   STAGING_DIR=$(STAGING_DIR)/thumb2

Buildroot then sees libraries and headers in $(STAGING_DIR)/usr/lib and $(STAGING_DIR)/usr/include respectively, as expected.

baruch

Signature · 3 lines
                                                     ~. .~   Tk Open Systems
=}------------------------------------------------ooO--U--Ooo------------{=
   - baruch at tkos.co.il - tel: +972.2.679.5364, http://www.tkos.co.il -