Buildroot Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [Buildroot] Bug with gmp and mpfr
@ 2009-02-05  2:17 Vania Joloboff
  2009-02-05  3:59 ` Maxim Grigoriev
  0 siblings, 1 reply; 5+ messages in thread
From: Vania Joloboff @ 2009-02-05  2:17 UTC (permalink / raw)
  To: buildroot

Hi,

We have some experience in cross compiling but we are new users of 
buildroot.
Please pardon our ignorance.

We have built the GCC toolchain with the latest version of buildroot 
2009-02-rc3
for three targets arm, ppc and mips, all three on two different hosts 
Ubuntu 7.10 and 8.10
We have installed the three toolchains in respectively 
/usr/local/cross/{arm|ppc|mips}

The gcc cross-compilers works (almost) fine except that the gmp and mpfr
library are dynamically loaded by gcc (by cc1 more exactly) from the 
wrong place...
They are loaded from the system directory (/usr/lib) instead of the 
directory
that should correspond to the gcc build.

Because Ubuntu version 8 is using libgmp and libmpfr in a more
recent version it creates a mismatch that you can notice if you compile 
with gcc -v,
but it seems to work fine however. We did not have time to thoroughly 
test generated code

Ubuntu version 7 is older and does not use libmpfr.
If you don't have libmpfr installed in the dynamic loading system 
directories
you get an error like :

/usr/local/cross/ppc/usr/bin/../libexec/gcc/powerpc-linux-uclibc/4.3.2/cc1plus: 
error while loading shared libraries: libmpfr.so.1: cannot open shared 
object file: No such file or directory

It seems there is a bug in buildroot: the generated gcc does not take 
the libgmp
and libmpfr from the right place.
libgmp and libmpfr are not target dependent, they are host dependent.
However the cross compiler gcc should not take these libraries
from the same place as the host gcc.
It should be from the staging directory.
Moreover in our case we built the three targets (arm, ppc, mips)
with the same release of buildroot.
But it could be possible we would have the three targets built with 
different
releases of buildroot, hence different releases of mpfr. These libraries
should be loaded from the staging directory.

Perhaps it is because we missed an option somewhere in the configuration...

Anyone has an opinion on this ?

VJ

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

* [Buildroot] Bug with gmp and mpfr
  2009-02-05  2:17 Vania Joloboff
@ 2009-02-05  3:59 ` Maxim Grigoriev
  2009-02-09 10:10   ` Peter Korsgaard
  2009-02-09 13:03   ` Peter Korsgaard
  0 siblings, 2 replies; 5+ messages in thread
From: Maxim Grigoriev @ 2009-02-05  3:59 UTC (permalink / raw)
  To: buildroot

Hello Vania,

The best solution for this problem I was able to find is
switching to static linkage of GMP/MPFR for GCC 4.3.x compilers.

If you don't like the idea of static linkage, please, simply ignore this 
email.

Here is the patch :

diff -u package/gmp/gmp.mk.orig package/gmp/gmp.mk
--- package/gmp/gmp.mk.orig 2009-01-21 15:43:41.788558000 -0800
+++ package/gmp/gmp.mk 2009-02-03 18:07:44.643402000 -0800
@@ -83,7 +83,7 @@
--prefix="$(GMP_HOST_DIR)" \
--build=$(GNU_HOST_NAME) \
--host=$(GNU_HOST_NAME) \
- --enable-shared \
+ --disable-shared \
--enable-static \
$(DISABLE_NLS) \
)
diff -u package/mpfr/mpfr.mk.orig package/mpfr/mpfr.mk
--- package/mpfr/mpfr.mk.orig 2009-01-21 15:43:42.259089000 -0800
+++ package/mpfr/mpfr.mk 2009-02-03 17:58:09.369092000 -0800
@@ -97,7 +97,7 @@
--prefix="$(MPFR_HOST_DIR)" \
--build=$(GNU_HOST_NAME) \
--host=$(GNU_HOST_NAME) \
- --enable-shared \
+ --disable-shared \
--enable-static \
--with-gmp=$(GMP_HOST_DIR) \
$(DISABLE_NLS) \

-- Maxim


Vania Joloboff wrote:
> Hi,
>
> We have some experience in cross compiling but we are new users of 
> buildroot.
> Please pardon our ignorance.
>
> We have built the GCC toolchain with the latest version of buildroot 
> 2009-02-rc3
> for three targets arm, ppc and mips, all three on two different hosts 
> Ubuntu 7.10 and 8.10
> We have installed the three toolchains in respectively 
> /usr/local/cross/{arm|ppc|mips}
>
> The gcc cross-compilers works (almost) fine except that the gmp and mpfr
> library are dynamically loaded by gcc (by cc1 more exactly) from the 
> wrong place...
> They are loaded from the system directory (/usr/lib) instead of the 
> directory
> that should correspond to the gcc build.
>
> Because Ubuntu version 8 is using libgmp and libmpfr in a more
> recent version it creates a mismatch that you can notice if you 
> compile with gcc -v,
> but it seems to work fine however. We did not have time to thoroughly 
> test generated code
>
> Ubuntu version 7 is older and does not use libmpfr.
> If you don't have libmpfr installed in the dynamic loading system 
> directories
> you get an error like :
>
> /usr/local/cross/ppc/usr/bin/../libexec/gcc/powerpc-linux-uclibc/4.3.2/cc1plus: 
> error while loading shared libraries: libmpfr.so.1: cannot open shared 
> object file: No such file or directory
>
> It seems there is a bug in buildroot: the generated gcc does not take 
> the libgmp
> and libmpfr from the right place.
> libgmp and libmpfr are not target dependent, they are host dependent.
> However the cross compiler gcc should not take these libraries
> from the same place as the host gcc.
> It should be from the staging directory.
> Moreover in our case we built the three targets (arm, ppc, mips)
> with the same release of buildroot.
> But it could be possible we would have the three targets built with 
> different
> releases of buildroot, hence different releases of mpfr. These libraries
> should be loaded from the staging directory.
>
> Perhaps it is because we missed an option somewhere in the 
> configuration...
>
> Anyone has an opinion on this ?
>
> VJ
>
>
> _______________________________________________
> buildroot mailing list
> buildroot at busybox.net
> http://lists.busybox.net/mailman/listinfo/buildroot
>

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

* [Buildroot] Bug with gmp and mpfr
  2009-02-05  3:59 ` Maxim Grigoriev
@ 2009-02-09 10:10   ` Peter Korsgaard
  2009-02-09 13:03   ` Peter Korsgaard
  1 sibling, 0 replies; 5+ messages in thread
From: Peter Korsgaard @ 2009-02-09 10:10 UTC (permalink / raw)
  To: buildroot

>>>>> "Maxim" == Maxim Grigoriev <maxim@tensilica.com> writes:

Hi,

 Maxim> Hello Vania,
 Maxim> The best solution for this problem I was able to find is
 Maxim> switching to static linkage of GMP/MPFR for GCC 4.3.x compilers.

 Maxim> If you don't like the idea of static linkage, please, simply ignore
 Maxim> this email.

It indeed seems to be best solution this close to the release. I'll do
a test build with one of the older gcc's, and commit if that still
works.

Thanks.

-- 
Bye, Peter Korsgaard

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

* [Buildroot] Bug with gmp and mpfr
  2009-02-05  3:59 ` Maxim Grigoriev
  2009-02-09 10:10   ` Peter Korsgaard
@ 2009-02-09 13:03   ` Peter Korsgaard
  1 sibling, 0 replies; 5+ messages in thread
From: Peter Korsgaard @ 2009-02-09 13:03 UTC (permalink / raw)
  To: buildroot

>>>>> "Maxim" == Maxim Grigoriev <maxim@tensilica.com> writes:

 Maxim> Hello Vania,
 Maxim> The best solution for this problem I was able to find is
 Maxim> switching to static linkage of GMP/MPFR for GCC 4.3.x compilers.

 Maxim> If you don't like the idea of static linkage, please, simply ignore
 Maxim> this email.

Thanks, committed as r25269.

-- 
Bye, Peter Korsgaard

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

* [Buildroot] Bug with gmp and mpfr
       [not found] <4989680E.4010807@liama.ia.ac.cn>
@ 2009-04-20  8:29 ` Vania Joloboff
  0 siblings, 0 replies; 5+ messages in thread
From: Vania Joloboff @ 2009-04-20  8:29 UTC (permalink / raw)
  To: buildroot

Hi,


We have a problem. We have build gcc with buildroot and in most cases it 
works fine.
But in one case we do not want to use the _start entry point because we 
redefine it.
So we use option -nostdlib and then we explicitly want to link with 
libstdc++ and libgcc

so we use a command like

g++ -nostdlib path/to/ourfiles $options -lstdc++ -lc -lgcc

We get

/usr/local/cross/arm/usr/bin/../lib/gcc/arm-linux-uclibc/4.3.2/../../../../arm-linux-uclibc/bin/ld: 
warning: libgcc_s.so.1, needed by 
/usr/local/cross/arm/usr/arm-linux-uclibc/lib/libstdc++.so, not found 
(try using -rpath or -rpath-link)
and then many  undefined references to _Unwind_*

We have tried using

1. -L options on the command line with the directories where are 
libgcc_s.so.1 and libstdc++
2.  the  -static-libgcc option
3. using export LD_LIBRARY_PATH=/path/to/libs
4. using LD_RUN_PATH=/path/to/libs

None of the 4 above work.

Does anybody have any clue ?

Can we build buildroot so that it uses only static linking ?

PS: Using the -L option just works fine if we build gcc with binutils 
and newlib.
It does not work with uclibc.

-- 
Sincerely,
-- Vania Joloboff
======================================================================
Tsinghua University, FIT Building, 3-605, Beijing 100040, China
Tel: +80 10 6279 6979 x605
email: vania.joloboff at tsinghua.edu.cn

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

end of thread, other threads:[~2009-04-20  8:29 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <4989680E.4010807@liama.ia.ac.cn>
2009-04-20  8:29 ` [Buildroot] Bug with gmp and mpfr Vania Joloboff
2009-02-05  2:17 Vania Joloboff
2009-02-05  3:59 ` Maxim Grigoriev
2009-02-09 10:10   ` Peter Korsgaard
2009-02-09 13:03   ` Peter Korsgaard

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