diff mbox

libtommath: add -fPIC

Message ID 1462005187-32394-1-git-send-email-francois.perrad@gadz.org
State Accepted
Headers show

Commit Message

Francois Perrad April 30, 2016, 8:33 a.m. UTC
fix build with x86_64, see http://autobuild.buildroot.net/results/212/212469db5dc8399070390603c0fdf7f12b130cda/

Signed-off-by: Francois Perrad <francois.perrad@gadz.org>
---
 package/libtommath/libtommath.mk | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Thomas Petazzoni April 30, 2016, 12:55 p.m. UTC | #1
Hello,

On Sat, 30 Apr 2016 10:33:07 +0200, Francois Perrad wrote:
> fix build with x86_64, see http://autobuild.buildroot.net/results/212/212469db5dc8399070390603c0fdf7f12b130cda/
> 
> Signed-off-by: Francois Perrad <francois.perrad@gadz.org>
> ---
>  package/libtommath/libtommath.mk | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

Applied to master, thanks.

Thomas
Peter Korsgaard April 30, 2016, 6:43 p.m. UTC | #2
>>>>> "Thomas" == Thomas Petazzoni <thomas.petazzoni@free-electrons.com> writes:

 > Hello,
 > On Sat, 30 Apr 2016 10:33:07 +0200, Francois Perrad wrote:
 >> fix build with x86_64, see
 >> http://autobuild.buildroot.net/results/212/212469db5dc8399070390603c0fdf7f12b130cda/
 >> 
 >> Signed-off-by: Francois Perrad <francois.perrad@gadz.org>
 >> ---
 >> package/libtommath/libtommath.mk | 2 +-
 >> 1 file changed, 1 insertion(+), 1 deletion(-)

 > Applied to master, thanks.

Hmm, isn't it a bit odd to build a static library with -fPIC?

But OK, the error message seems to be from trying to link a shared
library with it.
Thomas Petazzoni April 30, 2016, 7:13 p.m. UTC | #3
Hello,

On Sat, 30 Apr 2016 20:43:26 +0200, Peter Korsgaard wrote:

>  > Applied to master, thanks.  
> 
> Hmm, isn't it a bit odd to build a static library with -fPIC?
> 
> But OK, the error message seems to be from trying to link a shared
> library with it.

Well, as you've seen yourself, this static library is then used inside
a shared library, so it has to be built -fPIC.

If you want to build the static library without -fPIC, then the
libtommath package should also provide a shared version of its library,
so that it gets used instead of the static one when linked into a
shared library.

Thomas
Peter Korsgaard April 30, 2016, 7:43 p.m. UTC | #4
>>>>> "Thomas" == Thomas Petazzoni <thomas.petazzoni@free-electrons.com> writes:

 >> Hmm, isn't it a bit odd to build a static library with -fPIC?
 >> 
 >> But OK, the error message seems to be from trying to link a shared
 >> library with it.

 > Well, as you've seen yourself, this static library is then used inside
 > a shared library, so it has to be built -fPIC.

 > If you want to build the static library without -fPIC, then the
 > libtommath package should also provide a shared version of its library,
 > so that it gets used instead of the static one when linked into a
 > shared library.

Hmm, should we do this for all static only libraries in case they would
ever get used by a shared library? E.G. ezxml is a similar package.
Francois Perrad May 1, 2016, 6:49 a.m. UTC | #5
2016-04-30 20:43 GMT+02:00 Peter Korsgaard <peter@korsgaard.com>:
>>>>>> "Thomas" == Thomas Petazzoni <thomas.petazzoni@free-electrons.com> writes:
>
>  > Hello,
>  > On Sat, 30 Apr 2016 10:33:07 +0200, Francois Perrad wrote:
>  >> fix build with x86_64, see
>  >> http://autobuild.buildroot.net/results/212/212469db5dc8399070390603c0fdf7f12b130cda/
>  >>
>  >> Signed-off-by: Francois Perrad <francois.perrad@gadz.org>
>  >> ---
>  >> package/libtommath/libtommath.mk | 2 +-
>  >> 1 file changed, 1 insertion(+), 1 deletion(-)
>
>  > Applied to master, thanks.
>
> Hmm, isn't it a bit odd to build a static library with -fPIC?
>
> But OK, the error message seems to be from trying to link a shared
> library with it.
>

libtommath have a support for shared library via a makefile.shared.
But it is currently broken for cross compilation (bad linking with libtool).

François

> --
> Bye, Peter Korsgaard
> _______________________________________________
> buildroot mailing list
> buildroot@busybox.net
> http://lists.busybox.net/mailman/listinfo/buildroot
Thomas Petazzoni May 1, 2016, 7:35 a.m. UTC | #6
Hello,

On Sat, 30 Apr 2016 21:43:46 +0200, Peter Korsgaard wrote:

>  > Well, as you've seen yourself, this static library is then used inside
>  > a shared library, so it has to be built -fPIC.  
> 
>  > If you want to build the static library without -fPIC, then the
>  > libtommath package should also provide a shared version of its library,
>  > so that it gets used instead of the static one when linked into a
>  > shared library.  
> 
> Hmm, should we do this for all static only libraries in case they would
> ever get used by a shared library? E.G. ezxml is a similar package.

Well, as soon as some object code ends up being used in a shared
library (directly or via linking to a static library), then it must be
compiled with -fPIC, at least on some architectures (x86_64 and mips
are the one who clearly abort the build if that's not the case).

Thomas
diff mbox

Patch

diff --git a/package/libtommath/libtommath.mk b/package/libtommath/libtommath.mk
index 463ea7b..eb3b00e 100644
--- a/package/libtommath/libtommath.mk
+++ b/package/libtommath/libtommath.mk
@@ -13,7 +13,7 @@  LIBTOMMATH_INSTALL_STAGING = YES
 LIBTOMMATH_INSTALL_TARGET = NO  # only static library
 
 define LIBTOMMATH_BUILD_CMDS
-	$(MAKE) -C $(@D) $(TARGET_CONFIGURE_OPTS) CFLAGS="-I./ $(TARGET_CFLAGS)"
+	$(MAKE) -C $(@D) $(TARGET_CONFIGURE_OPTS) CFLAGS="-I./ -fPIC $(TARGET_CFLAGS)"
 endef
 
 define LIBTOMMATH_INSTALL_STAGING_CMDS