Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 376643 - dev-libs/libtommath-0.42.0 cross compilation fix
Summary: dev-libs/libtommath-0.42.0 cross compilation fix
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal normal with 2 votes (vote)
Assignee: Thomas Sachau
URL: http://groups.google.com/group/libtom...
Whiteboard:
Keywords: InVCS, PATCH
: 328289 460030 (view as bug list)
Depends on:
Blocks:
 
Reported: 2011-07-27 18:46 UTC by Bertrand Jacquin
Modified: 2013-04-24 01:08 UTC (History)
13 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
dev-libs/libtommath-BJA-LT.diff (libtommath-0.42.0.ebuild-BJA-LT.diff,686 bytes, patch)
2011-07-27 18:47 UTC, Bertrand Jacquin
Details | Diff
handle LT in makefile.shared (libtommath-0.42.0-makefile.patch,1.87 KB, patch)
2011-07-27 18:47 UTC, Bertrand Jacquin
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Bertrand Jacquin 2011-07-27 18:46:08 UTC
dev-libs/libtommath-0.42.0 for CC to tc-getCC, but this is not used for linking :

libtool: compile:  i586-alix-linux-gnu-gcc -Os -pipe -march=geode -mmmx -m3dnow -fomit-frame-pointer -I/usr/i586-alix-linux-gnu/usr/include/ -I/usr/i586-alix-linux-gnu/include/ -I./ -Wall -W -Wshadow -Wsign-compare -L/usr/i586-alix-linux-gnu/lib -L/usr/i586-alix-linux-gnu/usr/lib -c bn_mp_to_unsigned_bin_n.c  -fPIC -DPIC -o .libs/bn_mp_to_unsigned_bin_n.o
libtool: compile:  i586-alix-linux-gnu-gcc -Os -pipe -march=geode -mmmx -m3dnow -fomit-frame-pointer -I/usr/i586-alix-linux-gnu/usr/include/ -I/usr/i586-alix-linux-gnu/include/ -I./ -Wall -W -Wshadow -Wsign-compare -L/usr/i586-alix-linux-gnu/lib -L/usr/i586-alix-linux-gnu/usr/lib -c bn_mp_prime_rabin_miller_trials.c -o bn_mp_prime_rabin_miller_trials.o >/dev/null 2>&1
libtool: compile:  i586-alix-linux-gnu-gcc -Os -pipe -march=geode -mmmx -m3dnow -fomit-frame-pointer -I/usr/i586-alix-linux-gnu/usr/include/ -I/usr/i586-alix-linux-gnu/include/ -I./ -Wall -W -Wshadow -Wsign-compare -L/usr/i586-alix-linux-gnu/lib -L/usr/i586-alix-linux-gnu/usr/lib -c bn_mp_to_signed_bin_n.c -o bn_mp_to_signed_bin_n.o >/dev/null 2>&1
libtool: compile:  i586-alix-linux-gnu-gcc -Os -pipe -march=geode -mmmx -m3dnow -fomit-frame-pointer -I/usr/i586-alix-linux-gnu/usr/include/ -I/usr/i586-alix-linux-gnu/include/ -I./ -Wall -W -Wshadow -Wsign-compare -L/usr/i586-alix-linux-gnu/lib -L/usr/i586-alix-linux-gnu/usr/lib -c bn_mp_invmod_slow.c -o bn_mp_invmod_slow.o >/dev/null 2>&1
libtool: compile:  i586-alix-linux-gnu-gcc -Os -pipe -march=geode -mmmx -m3dnow -fomit-frame-pointer -I/usr/i586-alix-linux-gnu/usr/include/ -I/usr/i586-alix-linux-gnu/include/ -I./ -Wall -W -Wshadow -Wsign-compare -L/usr/i586-alix-linux-gnu/lib -L/usr/i586-alix-linux-gnu/usr/lib -c bn_mp_to_unsigned_bin_n.c -o bn_mp_to_unsigned_bin_n.o >/dev/null 2>&1
libtool --mode=link --tag=CC i586-alix-linux-gnu-gcc -L/usr/i586-alix-linux-gnu/lib -L/usr/i586-alix-linux-gnu/usr/lib *.lo -o libtommath.la -rpath /usr/lib -version-info 0:41
libtool: link: x86_64-pc-linux-gnu-gcc -shared  -fPIC -DPIC  .libs/bn_error.o .libs/bn_fast_mp_invmod.o .libs/bn_fast_mp_montgomery_reduce.o .libs/bn_fast_s_mp_mul_digs.o .libs/bn_fast_s_mp_mul_high_digs.o .libs/bn_fast_s_mp_sqr.o .libs/bn_mp_2expt.o .libs/bn_mp_abs.o .libs/bn_mp_add.o .libs/bn_mp_add_d.o .libs/bn_mp_addmod.o .libs/bn_mp_and.o .libs/bn_mp_clamp.o .libs/bn_mp_clear.o .libs/bn_mp_clear_multi.o .libs/bn_mp_cmp.o .libs/bn_mp_cmp_d.o .libs/bn_mp_cmp_mag.o .libs/bn_mp_cnt_lsb.o .libs/bn_mp_copy.o .libs/bn_mp_count_bits.o .libs/bn_mp_div.o .libs/bn_mp_div_2.o .libs/bn_mp_div_2d.o .libs/bn_mp_div_3.o .libs/bn_mp_div_d.o .libs/bn_mp_dr_is_modulus.o .libs/bn_mp_dr_reduce.o .libs/bn_mp_dr_setup.o .libs/bn_mp_exch.o .libs/bn_mp_expt_d.o .libs/bn_mp_exptmod.o .libs/bn_mp_exptmod_fast.o .libs/bn_mp_exteuclid.o .libs/bn_mp_fread.o .libs/bn_mp_fwrite.o .libs/bn_mp_gcd.o .libs/bn_mp_get_int.o .libs/bn_mp_grow.o .libs/bn_mp_init.o .libs/bn_mp_init_copy.o .libs/bn_mp_init_multi.o .libs/bn_mp_init_set.o .libs/bn_mp_init_set_int.o .libs/bn_mp_init_size.o .libs/bn_mp_invmod.o .libs/bn_mp_invmod_slow.o .libs/bn_mp_is_square.o .libs/bn_mp_jacobi.o .libs/bn_mp_karatsuba_mul.o .libs/bn_mp_karatsuba_sqr.o .libs/bn_mp_lcm.o .libs/bn_mp_lshd.o .libs/bn_mp_mod.o .libs/bn_mp_mod_2d.o .libs/bn_mp_mod_d.o .libs/bn_mp_montgomery_calc_normalization.o .libs/bn_mp_montgomery_reduce.o .libs/bn_mp_montgomery_setup.o .libs/bn_mp_mul.o .libs/bn_mp_mul_2.o .libs/bn_mp_mul_2d.o .libs/bn_mp_mul_d.o .libs/bn_mp_mulmod.o .libs/bn_mp_n_root.o .libs/bn_mp_neg.o .libs/bn_mp_or.o .libs/bn_mp_prime_fermat.o .libs/bn_mp_prime_is_divisible.o .libs/bn_mp_prime_is_prime.o .libs/bn_mp_prime_miller_rabin.o .libs/bn_mp_prime_next_prime.o .libs/bn_mp_prime_rabin_miller_trials.o .libs/bn_mp_prime_random_ex.o .libs/bn_mp_radix_size.o .libs/bn_mp_radix_smap.o .libs/bn_mp_rand.o .libs/bn_mp_read_radix.o .libs/bn_mp_read_signed_bin.o .libs/bn_mp_read_unsigned_bin.o .libs/bn_mp_reduce.o .libs/bn_mp_reduce_2k.o .libs/bn_mp_reduce_2k_l.o .libs/bn_mp_reduce_2k_setup.o .libs/bn_mp_reduce_2k_setup_l.o .libs/bn_mp_reduce_is_2k.o .libs/bn_mp_reduce_is_2k_l.o .libs/bn_mp_reduce_setup.o .libs/bn_mp_rshd.o .libs/bn_mp_set.o .libs/bn_mp_set_int.o .libs/bn_mp_shrink.o .libs/bn_mp_signed_bin_size.o .libs/bn_mp_sqr.o .libs/bn_mp_sqrmod.o .libs/bn_mp_sqrt.o .libs/bn_mp_sub.o .libs/bn_mp_sub_d.o .libs/bn_mp_submod.o .libs/bn_mp_to_signed_bin.o .libs/bn_mp_to_signed_bin_n.o .libs/bn_mp_to_unsigned_bin.o .libs/bn_mp_to_unsigned_bin_n.o .libs/bn_mp_toom_mul.o .libs/bn_mp_toom_sqr.o .libs/bn_mp_toradix.o .libs/bn_mp_toradix_n.o .libs/bn_mp_unsigned_bin_size.o .libs/bn_mp_xor.o .libs/bn_mp_zero.o .libs/bn_prime_tab.o .libs/bn_reverse.o .libs/bn_s_mp_add.o .libs/bn_s_mp_exptmod.o .libs/bn_s_mp_mul_digs.o .libs/bn_s_mp_mul_high_digs.o .libs/bn_s_mp_sqr.o .libs/bn_s_mp_sub.o .libs/bncore.o   -L/usr/i586-alix-linux-gnu/lib -L/usr/i586-alix-linux-gnu/usr/lib    -Wl,-soname -Wl,libtommath.so.0 -o .libs/libtommath.so.0.0.41
/usr/lib/gcc/x86_64-pc-linux-gnu/4.5.2/../../../../x86_64-pc-linux-gnu/bin/ld: skipping incompatible /usr/i586-alix-linux-gnu/usr/lib/libc.so when searching for -lc
/usr/lib/gcc/x86_64-pc-linux-gnu/4.5.2/../../../../x86_64-pc-linux-gnu/bin/ld: skipping incompatible /usr/i586-alix-linux-gnu/usr/lib/libc.a when searching for -lc
/usr/lib/gcc/x86_64-pc-linux-gnu/4.5.2/../../../../x86_64-pc-linux-gnu/bin/ld: i386 architecture of input file `.libs/bn_error.o' is incompatible with i386:x86-64 output
/usr/lib/gcc/x86_64-pc-linux-gnu/4.5.2/../../../../x86_64-pc-linux-gnu/bin/ld: i386 architecture of input file `.libs/bn_fast_mp_invmod.o' is incompatible with i386:x86-64 output
/usr/lib/gcc/x86_64-pc-linux-gnu/4.5.2/../../../../x86_64-pc-linux-gnu/bin/ld: i386 architecture of input file `.libs/bn_fast_mp_montgomery_reduce.o' is incompatible with i386:x86-64 output
/usr/lib/gcc/x86_64-pc-linux-gnu/4.5.2/../../../../x86_64-pc-linux-gnu/bin/ld: i386 architecture of input file `.libs/bn_fast_s_mp_mul_digs.o' is incompatible with i386:x86-64 output

libtool completely ignore LINK-COMMAND while mode=link, so here is a crappy fix to use HOST libtool instead of BUILD one

Reproducible: Always

Steps to Reproduce:
1. i586-alix-linux-gnu-emerge -vat dev-libs/libtommath
2.
3.
Comment 1 Bertrand Jacquin 2011-07-27 18:47:17 UTC
Created attachment 281187 [details, diff]
dev-libs/libtommath-BJA-LT.diff
Comment 2 Bertrand Jacquin 2011-07-27 18:47:56 UTC
Created attachment 281189 [details, diff]
handle LT in makefile.shared
Comment 3 Pacho Ramos gentoo-dev 2011-07-28 10:03:26 UTC
*** Bug 328289 has been marked as a duplicate of this bug. ***
Comment 4 Jeroen Roovers (RETIRED) gentoo-dev 2011-08-02 05:18:26 UTC
Looks interesting. You could report this upstream at [1].



[1] http://groups.google.com/group/libtom
Comment 5 Thomas Sachau gentoo-dev 2012-02-17 19:27:38 UTC
Is this still valid for libtommath-0.42-r1?
Comment 6 Bertrand Jacquin 2012-02-19 15:00:09 UTC
(In reply to comment #5)
> Is this still valid for libtommath-0.42-r1?

It is !

And reported upstream as http://groups.google.com/group/libtom/browse_thread/thread/86a140fff35568b6/01315200ebf2f72e?lnk=gst&q=libtool#01315200ebf2f72e
Comment 7 Kiichiro 2012-07-07 04:50:53 UTC
I've got the same error with arm cross compiler


libtool --mode=link --tag=CC armv6z-rpi-linux-uclibceabi-gcc -L/usr/armv6z-rpi-linux-uclibceabi/lib -L/usr/armv6z-rpi-linux-uclibceabi/usr/lib *.lo -o libtommath.la -rpath /usr/lib -version-info 0:41
libtool: link: x86_64-pc-linux-gnu-gcc -shared  -fPIC -DPIC  .libs/bncore.o .libs/bn_error.o .libs/bn_fast_mp_invmod.o .libs/bn_fast_mp_montgomery_reduce.o .libs/bn_fast_s_mp_mul_digs.o .libs/bn_fast_s_mp_mul_high_digs.o .libs/bn_fast_s_mp_sqr.o .libs/bn_mp_2expt.o .libs/bn_mp_abs.o .libs/bn_mp_add_d.o .libs/bn_mp_add.o .libs/bn_mp_addmod.o .libs/bn_mp_and.o .libs/bn_mp_clamp.o .libs/bn_mp_clear.o .libs/bn_mp_clear_multi.o .libs/bn_mp_cmp_d.o .libs/bn_mp_cmp.o .libs/bn_mp_cmp_mag.o .libs/bn_mp_cnt_lsb.o .libs/bn_mp_copy.o .libs/bn_mp_count_bits.o .libs/bn_mp_div_2d.o .libs/bn_mp_div_2.o .libs/bn_mp_div_3.o .libs/bn_mp_div_d.o .libs/bn_mp_div.o .libs/bn_mp_dr_is_modulus.o .libs/bn_mp_dr_reduce.o .libs/bn_mp_dr_setup.o .libs/bn_mp_exch.o .libs/bn_mp_expt_d.o .libs/bn_mp_exptmod_fast.o .libs/bn_mp_exptmod.o .libs/bn_mp_exteuclid.o .libs/bn_mp_fread.o .libs/bn_mp_fwrite.o .libs/bn_mp_gcd.o .libs/bn_mp_get_int.o .libs/bn_mp_grow.o .libs/bn_mp_init_copy.o .libs/bn_mp_init.o .libs/bn_mp_init_multi.o .libs/bn_mp_init_set_int.o .libs/bn_mp_init_set.o .libs/bn_mp_init_size.o .libs/bn_mp_invmod.o .libs/bn_mp_invmod_slow.o .libs/bn_mp_is_square.o .libs/bn_mp_jacobi.o .libs/bn_mp_karatsuba_mul.o .libs/bn_mp_karatsuba_sqr.o .libs/bn_mp_lcm.o .libs/bn_mp_lshd.o .libs/bn_mp_mod_2d.o .libs/bn_mp_mod_d.o .libs/bn_mp_mod.o .libs/bn_mp_montgomery_calc_normalization.o .libs/bn_mp_montgomery_reduce.o .libs/bn_mp_montgomery_setup.o .libs/bn_mp_mul_2d.o .libs/bn_mp_mul_2.o .libs/bn_mp_mul_d.o .libs/bn_mp_mul.o .libs/bn_mp_mulmod.o .libs/bn_mp_neg.o .libs/bn_mp_n_root.o .libs/bn_mp_or.o .libs/bn_mp_prime_fermat.o .libs/bn_mp_prime_is_divisible.o .libs/bn_mp_prime_is_prime.o .libs/bn_mp_prime_miller_rabin.o .libs/bn_mp_prime_next_prime.o .libs/bn_mp_prime_rabin_miller_trials.o .libs/bn_mp_prime_random_ex.o .libs/bn_mp_radix_size.o .libs/bn_mp_radix_smap.o .libs/bn_mp_rand.o .libs/bn_mp_read_radix.o .libs/bn_mp_read_signed_bin.o .libs/bn_mp_read_unsigned_bin.o .libs/bn_mp_reduce_2k_l.o .libs/bn_mp_reduce_2k.o .libs/bn_mp_reduce_2k_setup_l.o .libs/bn_mp_reduce_2k_setup.o .libs/bn_mp_reduce_is_2k_l.o .libs/bn_mp_reduce_is_2k.o .libs/bn_mp_reduce.o .libs/bn_mp_reduce_setup.o .libs/bn_mp_rshd.o .libs/bn_mp_set_int.o .libs/bn_mp_set.o .libs/bn_mp_shrink.o .libs/bn_mp_signed_bin_size.o .libs/bn_mp_sqr.o .libs/bn_mp_sqrmod.o .libs/bn_mp_sqrt.o .libs/bn_mp_sub_d.o .libs/bn_mp_sub.o .libs/bn_mp_submod.o .libs/bn_mp_toom_mul.o .libs/bn_mp_toom_sqr.o .libs/bn_mp_toradix.o .libs/bn_mp_toradix_n.o .libs/bn_mp_to_signed_bin.o .libs/bn_mp_to_signed_bin_n.o .libs/bn_mp_to_unsigned_bin.o .libs/bn_mp_to_unsigned_bin_n.o .libs/bn_mp_unsigned_bin_size.o .libs/bn_mp_xor.o .libs/bn_mp_zero.o .libs/bn_prime_tab.o .libs/bn_reverse.o .libs/bn_s_mp_add.o .libs/bn_s_mp_exptmod.o .libs/bn_s_mp_mul_digs.o .libs/bn_s_mp_mul_high_digs.o .libs/bn_s_mp_sqr.o .libs/bn_s_mp_sub.o   -L/usr/armv6z-rpi-linux-uclibceabi/lib -L/usr/armv6z-rpi-linux-uclibceabi/usr/lib    -Wl,-soname -Wl,libtommath.so.0 -o .libs/libtommath.so.0.0.41
/usr/lib/gcc/x86_64-pc-linux-gnu/4.5.3/../../../../x86_64-pc-linux-gnu/bin/ld: .libs/bn_error.o: Relocations in generic ELF (EM: 40)
/usr/lib/gcc/x86_64-pc-linux-gnu/4.5.3/../../../../x86_64-pc-linux-gnu/bin/ld: .libs/bn_error.o: Relocations in generic ELF (EM: 40)
.libs/bn_error.o: could not read symbols: File in wrong format
collect2: ld returned 1 exit status
Comment 8 Roman 2012-07-30 10:48:37 UTC
Same problem when cross-compiling for ARM.
Comment 9 Jeroen Roovers (RETIRED) gentoo-dev 2012-07-30 20:42:55 UTC
Please do not CC arch teams.
Comment 10 SpanKY gentoo-dev 2012-08-07 22:55:03 UTC
Comment on attachment 281187 [details, diff]
dev-libs/libtommath-BJA-LT.diff

ROOT should never be used in src_* steps

this also doesn't make much sense upstream.  really upstream should be bundling+generating libtool as part of the normal autotool process, but i can't see that happening anytime soon.
Comment 11 Shawn A. Wilson 2012-09-08 00:24:35 UTC
The patch alone did not work for me. I too am cross-compiling for ARM (on x86). Here's what I had to do to get a successful compile:

1. Build libtool for ARM: $ armv6j-hardfloat-linux-gnueabi-emerge libtool -va
2. Download the patch supplied here
3. Edit LT definition in patch to use the ARM libtool: +LT = /usr/armv6j-hardfloat-linux-gnueabi/usr/bin/libtool

Obviously #3 is a hack specific to my system and use. Somebody more in the know can fix it to auto-detect the right libtool to use. With these steps done (in a local portage overlay) I was able to successfully compile libtommath for ARM.

-shawn
Comment 12 Bertrand Jacquin 2012-09-11 19:49:22 UTC
(In reply to comment #11)
> The patch alone did not work for me. I too am cross-compiling for ARM (on
> x86). Here's what I had to do to get a successful compile:
> 
> 1. Build libtool for ARM: $ armv6j-hardfloat-linux-gnueabi-emerge libtool -va
> 2. Download the patch supplied here
> 3. Edit LT definition in patch to use the ARM libtool: +LT =
> /usr/armv6j-hardfloat-linux-gnueabi/usr/bin/libtool
> 
> Obviously #3 is a hack specific to my system and use. Somebody more in the
> know can fix it to auto-detect the right libtool to use. With these steps
> done (in a local portage overlay) I was able to successfully compile
> libtommath for ARM.

You don't need #3 if you also use patch that have invalidated in

https://bugs.gentoo.org/show_bug.cgi?id=376643#c10

Patch is here 
https://bugs.gentoo.org/attachment.cgi?id=281187
Comment 13 nikarul 2013-01-26 23:25:03 UTC
Ran into this bug when cross compiling for armv7a-hardfloat-linux-gnueabi, the attached patch and one mentioned below solved the problem for me.  The overlay ebuilds I used are available here:  http://digitalbytes.net/gentoo/lostwoods/dev-libs/libtommath/

Note:  I modified both ebuilds but only tested version 0.42.0
Comment 14 Markos Chandras (RETIRED) gentoo-dev 2013-03-05 13:20:03 UTC
*** Bug 460030 has been marked as a duplicate of this bug. ***
Comment 15 Markos Chandras (RETIRED) gentoo-dev 2013-04-20 19:25:42 UTC
(In reply to comment #10)
> Comment on attachment 281187 [details, diff] [details, diff]
> dev-libs/libtommath-BJA-LT.diff
> 
> ROOT should never be used in src_* steps
> 
> this also doesn't make much sense upstream.  really upstream should be
> bundling+generating libtool as part of the normal autotool process, but i
> can't see that happening anytime soon.

upstream does not seem to care about this so we need to carry this patch ourselves. I think the ebuild diff you invalidated would be fine if you replace ROOT with EPREFIX wouldn't it?

I will do some more tests and if they work for me I will commit it as this breaks every cross-compilation out there
Comment 16 Bertrand Jacquin 2013-04-20 20:54:09 UTC
(In reply to comment #15)
> (In reply to comment #10)
> > Comment on attachment 281187 [details, diff] [details, diff] [details, diff]
> > dev-libs/libtommath-BJA-LT.diff
> > 
> > ROOT should never be used in src_* steps
> > 
> > this also doesn't make much sense upstream.  really upstream should be
> > bundling+generating libtool as part of the normal autotool process, but i
> > can't see that happening anytime soon.
> 
> upstream does not seem to care about this so we need to carry this patch
> ourselves. I think the ebuild diff you invalidated would be fine if you
> replace ROOT with EPREFIX wouldn't it?
> 
> I will do some more tests and if they work for me I will commit it as this
> breaks every cross-compilation out there

Thanks to take care of it markos :)
Comment 17 Markos Chandras (RETIRED) gentoo-dev 2013-04-21 15:19:40 UTC
How about this one?

Index: libtommath-0.42.0-r1.ebuild
===================================================================
RCS file: /var/cvsroot/gentoo-x86/dev-libs/libtommath/libtommath-0.42.0-r1.ebuild,v
retrieving revision 1.5
diff -u -B -u -r1.5 libtommath-0.42.0-r1.ebuild
--- libtommath-0.42.0-r1.ebuild	28 Mar 2013 15:43:01 -0000	1.5
+++ libtommath-0.42.0-r1.ebuild	21 Apr 2013 15:06:06 -0000
@@ -25,7 +25,10 @@
 }
 
 src_compile() {
-	emake CC=$(tc-getCC) -f makefile.shared IGNORE_SPEED=1 LIBPATH="${EPREFIX}/usr/$(get_libdir)"
+	local sysroot="$(tc-getCC) -print-sysroot"
+	emake CC=$(tc-getCC) -f makefile.shared \
+		IGNORE_SPEED=1 LIBPATH="${EPREFIX}/usr/$(get_libdir)" \
+		LT="$(eval $sysroot)/usr/bin/libtool"
 }
 
 src_install() {
Comment 18 Bertrand Jacquin 2013-04-21 17:46:03 UTC
(In reply to comment #17)
> How about this one?
>  
>  src_compile() {
> -	emake CC=$(tc-getCC) -f makefile.shared IGNORE_SPEED=1
> LIBPATH="${EPREFIX}/usr/$(get_libdir)"
> +	local sysroot="$(tc-getCC) -print-sysroot"
> +	emake CC=$(tc-getCC) -f makefile.shared \
> +		IGNORE_SPEED=1 LIBPATH="${EPREFIX}/usr/$(get_libdir)" \
> +		LT="$(eval $sysroot)/usr/bin/libtool"

Why eval() should be needed ? Also, GCC sysroot may not be the same as gentoo SYSROOT. EPREFIX can't do the trick for LT here ?

I'm not a gentoo dev so I don't really known if using gcc -print-sysroot is better than using SYSROOT. Not sure
Comment 19 Markos Chandras (RETIRED) gentoo-dev 2013-04-21 17:53:45 UTC
(In reply to comment #18)
> (In reply to comment #17)
> > How about this one?
> >  
> >  src_compile() {
> > -	emake CC=$(tc-getCC) -f makefile.shared IGNORE_SPEED=1
> > LIBPATH="${EPREFIX}/usr/$(get_libdir)"
> > +	local sysroot="$(tc-getCC) -print-sysroot"
> > +	emake CC=$(tc-getCC) -f makefile.shared \
> > +		IGNORE_SPEED=1 LIBPATH="${EPREFIX}/usr/$(get_libdir)" \
> > +		LT="$(eval $sysroot)/usr/bin/libtool"
> 
> Why eval() should be needed ?

because you want to run the $sysroot as command

> Also, GCC sysroot may not be the same as
> gentoo SYSROOT.

what does that mean?

> 
> I'm not a gentoo dev so I don't really known if using gcc -print-sysroot is
> better than using SYSROOT. Not sure
SYSROOT is not a Gentoo/Portage exported variable. -print-sysroot should print the --with-sysroot command executed when you built your cross-compile.

EPREFIX is empty on my system
Comment 20 Bertrand Jacquin 2013-04-21 19:14:38 UTC
(In reply to comment #19)
> (In reply to comment #18)
> > (In reply to comment #17)
> > > How about this one?
> > >  
> > >  src_compile() {
> > > -	emake CC=$(tc-getCC) -f makefile.shared IGNORE_SPEED=1
> > > LIBPATH="${EPREFIX}/usr/$(get_libdir)"
> > > +	local sysroot="$(tc-getCC) -print-sysroot"
> > > +	emake CC=$(tc-getCC) -f makefile.shared \
> > > +		IGNORE_SPEED=1 LIBPATH="${EPREFIX}/usr/$(get_libdir)" \
> > > +		LT="$(eval $sysroot)/usr/bin/libtool"
> > 
> > Why eval() should be needed ?
> 
> because you want to run the $sysroot as command

True, misread, sorry.

> > Also, GCC sysroot may not be the same as
> > gentoo SYSROOT.
> 
> what does that mean?

$ROOT not always = $SYSROOT when cross compiling, and generally is not.

> > I'm not a gentoo dev so I don't really known if using gcc -print-sysroot is
> > better than using SYSROOT. Not sure
> SYSROOT is not a Gentoo/Portage exported variable. -print-sysroot should
> print the --with-sysroot command executed when you built your cross-compile.
> 
> EPREFIX is empty on my system

Maybe we need to approach someone closer to x-compile issue like this (vapier) ? I really don't known what is better here.
Comment 21 Markos Chandras (RETIRED) gentoo-dev 2013-04-21 20:42:42 UTC
(In reply to comment #20)
> 
> $ROOT not always = $SYSROOT when cross compiling, and generally is not.

True.

> 
> Maybe we need to approach someone closer to x-compile issue like this
> (vapier) ? I really don't known what is better here.

Would it be preferred for libtommath ebuild to download and build libtool if a cross-compiler is detected?
Comment 22 Markos Chandras (RETIRED) gentoo-dev 2013-04-23 17:20:36 UTC
(In reply to comment #21)
> > 
> > Maybe we need to approach someone closer to x-compile issue like this
> > (vapier) ? I really don't known what is better here.
> 
> Would it be preferred for libtommath ebuild to download and build libtool if
> a cross-compiler is detected?

Mike would you be happy with this ^^^ ?
Comment 23 SpanKY gentoo-dev 2013-04-23 18:21:31 UTC
(In reply to comment #22)

no, don't do that.  you could create a small configure.ac that sets up libtool for you and then gen autotools as part of the build.

 cat <<-EOF > configure.ac
 AC_INIT(libtommath, 0)
 AM_INIT_AUTOMAKE
 LT_INIT
 AC_CONFIG_FILES(Makefile)
 AC_OUTPUT
 EOF
 touch NEWS README AUTHORS ChangeLog Makefile.am
 eautoreconf

then you can use $S/libtool at build time
Comment 24 Markos Chandras (RETIRED) gentoo-dev 2013-04-23 19:40:17 UTC
(In reply to comment #23)
> (In reply to comment #22)
Thanks. I committed the following patch. I am also cc'ing the prefix people so they can tell me if everything is still ok for them

+  23 Apr 2013; Markos Chandras <hwoarang@gentoo.org>
+  libtommath-0.42.0-r1.ebuild, files/libtommath-0.42.0-makefile.patch:
+  Create a minimal configure.ac file to build libtool. Fixes cross compilation
+  problems reported in bug #376643. Thanks to Bertrand Jacquin
+  <beber@meleeweb.net> for the upstream patch and Mike Frysinger
+  <vapier@gentoo.org> for the suggestions.
+

http://sources.gentoo.org/cgi-bin/viewvc.cgi/gentoo-x86/dev-libs/libtommath/libtommath-0.42.0-r1.ebuild?r1=1.5&r2=1.6

http://sources.gentoo.org/cgi-bin/viewvc.cgi/gentoo-x86/dev-libs/libtommath/files/libtommath-0.42.0-makefile.patch?r1=1.2&r2=1.3
Comment 25 SpanKY gentoo-dev 2013-04-24 01:08:36 UTC
(In reply to comment #24)

i don't think we need the darwin code path.  it can do the same thing as the non-darwin code.  this is how most packages in the tree build.

i've made that change and some other random cleanups.

if other packages want this behavior, we might consider moving the code to autotools eclass.  i know apache packages have a history of problems here.

http://sources.gentoo.org/dev-libs/libtommath/libtommath-0.42.0-r1.ebuild?r1=1.6&r2=1.7
http://sources.gentoo.org/dev-libs/libtommath/files/libtommath-0.42.0-makefile.patch?r1=1.3&r2=1.4