Buildroot Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [Buildroot] [PATCH 1/1] libcap: fix static linking issue
@ 2013-10-06 20:10 Romain Naour
  2013-10-06 21:29 ` Thomas Petazzoni
  2013-11-01 17:48 ` Thomas Petazzoni
  0 siblings, 2 replies; 8+ messages in thread
From: Romain Naour @ 2013-10-06 20:10 UTC (permalink / raw)
  To: buildroot

Add -fPIC flag

Fixes:
http://autobuild.buildroot.net/results/619bceb3491ecd2ed4e1ae552fdb237a0ed2fa47/

Signed-off-by: Romain Naour <romain.naour@openwide.fr>
---
 package/libcap/libcap.mk | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/package/libcap/libcap.mk b/package/libcap/libcap.mk
index 16afaef..6248fed 100644
--- a/package/libcap/libcap.mk
+++ b/package/libcap/libcap.mk
@@ -25,10 +25,15 @@ endif
 # we don't have host-attr
 HOST_LIBCAP_DEPENDENCIES =

+ifeq ($(BR2_PREFER_STATIC_LIB),y)
+LIBCAP_LDFLAGS=-fPIC
+endif
+
 define LIBCAP_BUILD_CMDS
 	$(TARGET_MAKE_ENV) $(TARGET_CONFIGURE_OPTS) $(MAKE) -C $(@D) \
 		LIBATTR=$(LIBCAP_HAVE_LIBATTR) BUILD_CC="$(HOSTCC)" \
-		BUILD_CFLAGS="$(HOST_CFLAGS)"
+		BUILD_CFLAGS="$(HOST_CFLAGS)" \
+		LDFLAGS="$(LIBCAP_LDFLAGS)"
 endef

 define LIBCAP_INSTALL_STAGING_CMDS
-- 
1.8.4

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

* [Buildroot] [PATCH 1/1] libcap: fix static linking issue
  2013-10-06 20:10 [Buildroot] [PATCH 1/1] libcap: fix static linking issue Romain Naour
@ 2013-10-06 21:29 ` Thomas Petazzoni
  2013-10-08  8:11   ` Romain Naour
  2013-11-01 17:48 ` Thomas Petazzoni
  1 sibling, 1 reply; 8+ messages in thread
From: Thomas Petazzoni @ 2013-10-06 21:29 UTC (permalink / raw)
  To: buildroot

Dear Romain Naour,

On Sun, 06 Oct 2013 22:10:24 +0200, Romain Naour wrote:
> Add -fPIC flag
> 
> Fixes:
> http://autobuild.buildroot.net/results/619bceb3491ecd2ed4e1ae552fdb237a0ed2fa47/
> 
> Signed-off-by: Romain Naour <romain.naour@openwide.fr>
> ---
>  package/libcap/libcap.mk | 7 ++++++-
>  1 file changed, 6 insertions(+), 1 deletion(-)
> 
> diff --git a/package/libcap/libcap.mk b/package/libcap/libcap.mk
> index 16afaef..6248fed 100644
> --- a/package/libcap/libcap.mk
> +++ b/package/libcap/libcap.mk
> @@ -25,10 +25,15 @@ endif
>  # we don't have host-attr
>  HOST_LIBCAP_DEPENDENCIES =
> 
> +ifeq ($(BR2_PREFER_STATIC_LIB),y)
> +LIBCAP_LDFLAGS=-fPIC
> +endif

This seems really weird, because normally, we would expect exactly the
opposite: position independent code is needed for shared libraries, not
for static libraries.

Thomas
-- 
Thomas Petazzoni, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com

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

* [Buildroot] [PATCH 1/1] libcap: fix static linking issue
  2013-10-06 21:29 ` Thomas Petazzoni
@ 2013-10-08  8:11   ` Romain Naour
  2013-10-08  8:13     ` Thomas Petazzoni
  0 siblings, 1 reply; 8+ messages in thread
From: Romain Naour @ 2013-10-08  8:11 UTC (permalink / raw)
  To: buildroot

Hi Thomas,

----- Mail original -----
| De: "Thomas Petazzoni" <thomas.petazzoni@free-electrons.com>
| ?: "Romain Naour" <romain.naour@openwide.fr>
| Cc: "buildroot" <buildroot@busybox.net>
| Envoy?: Dimanche 6 Octobre 2013 23:29:54
| Objet: Re: [Buildroot] [PATCH 1/1] libcap: fix static linking issue
| 
| Dear Romain Naour,
| 
| On Sun, 06 Oct 2013 22:10:24 +0200, Romain Naour wrote:
| > Add -fPIC flag
| > 
| > Fixes:
| > http://autobuild.buildroot.net/results/619bceb3491ecd2ed4e1ae552fdb237a0ed2fa47/
| > 
| > Signed-off-by: Romain Naour <romain.naour@openwide.fr>
| > ---
| >  package/libcap/libcap.mk | 7 ++++++-
| >  1 file changed, 6 insertions(+), 1 deletion(-)
| > 
| > diff --git a/package/libcap/libcap.mk b/package/libcap/libcap.mk
| > index 16afaef..6248fed 100644
| > --- a/package/libcap/libcap.mk
| > +++ b/package/libcap/libcap.mk
| > @@ -25,10 +25,15 @@ endif
| >  # we don't have host-attr
| >  HOST_LIBCAP_DEPENDENCIES =
| > 
| > +ifeq ($(BR2_PREFER_STATIC_LIB),y)
| > +LIBCAP_LDFLAGS=-fPIC
| > +endif
| 
| This seems really weird, because normally, we would expect exactly
| the
| opposite: position independent code is needed for shared libraries,
| not
| for static libraries.

Ok, I'll take the problem from the beginning.
Sorry for that mistake.

Best regards,
Romain
| 
| Thomas
| --
| Thomas Petazzoni, Free Electrons
| Embedded Linux, Kernel and Android engineering
| http://free-electrons.com
| 

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

* [Buildroot] [PATCH 1/1] libcap: fix static linking issue
  2013-10-08  8:11   ` Romain Naour
@ 2013-10-08  8:13     ` Thomas Petazzoni
  2013-10-13 19:44       ` Romain Naour
  0 siblings, 1 reply; 8+ messages in thread
From: Thomas Petazzoni @ 2013-10-08  8:13 UTC (permalink / raw)
  To: buildroot

Dear Romain Naour,

On Tue, 8 Oct 2013 10:11:53 +0200 (CEST), Romain Naour wrote:

> | > +ifeq ($(BR2_PREFER_STATIC_LIB),y)
> | > +LIBCAP_LDFLAGS=-fPIC
> | > +endif
> | 
> | This seems really weird, because normally, we would expect exactly
> | the
> | opposite: position independent code is needed for shared libraries,
> | not
> | for static libraries.
> 
> Ok, I'll take the problem from the beginning.
> Sorry for that mistake.

Note that I'm not sure about what I said, but having to build with
-fPIC in the static lib case seems really strange.

Thanks!

Thomas
-- 
Thomas Petazzoni, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com

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

* [Buildroot] [PATCH 1/1] libcap: fix static linking issue
  2013-10-08  8:13     ` Thomas Petazzoni
@ 2013-10-13 19:44       ` Romain Naour
  2013-10-16 16:09         ` Thomas Petazzoni
  0 siblings, 1 reply; 8+ messages in thread
From: Romain Naour @ 2013-10-13 19:44 UTC (permalink / raw)
  To: buildroot

Hi,

Le 08/10/2013 10:13, Thomas Petazzoni a ?crit :
> Dear Romain Naour,
> 
> On Tue, 8 Oct 2013 10:11:53 +0200 (CEST), Romain Naour wrote:
> 
>> | > +ifeq ($(BR2_PREFER_STATIC_LIB),y)
>> | > +LIBCAP_LDFLAGS=-fPIC
>> | > +endif
>> | 
>> | This seems really weird, because normally, we would expect exactly
>> | the
>> | opposite: position independent code is needed for shared libraries,
>> | not
>> | for static libraries.
>>
>> Ok, I'll take the problem from the beginning.
>> Sorry for that mistake.
> 
> Note that I'm not sure about what I said, but having to build with
> -fPIC in the static lib case seems really strange.
> 
> Thanks!
> 
> Thomas
> 

You're right, the static lib isn?t built with -fPIC.
But the libcap build system build the static and shared libraries,
even if you don't want one of them.

The build failure [1] is caused by the missing -fPIC during the build of libcap.so.2.22

So, we may add -fPIC if BR2_PREFER_STATIC_LIB=y and the shared lib is build correctly
(ok it's weird)
Or add a patch for enable/disable separately the static/shared build.

Best regards,
Romain Naour

[1] http://autobuild.buildroot.net/results/619bceb3491ecd2ed4e1ae552fdb237a0ed2fa47/

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

* [Buildroot] [PATCH 1/1] libcap: fix static linking issue
  2013-10-13 19:44       ` Romain Naour
@ 2013-10-16 16:09         ` Thomas Petazzoni
  0 siblings, 0 replies; 8+ messages in thread
From: Thomas Petazzoni @ 2013-10-16 16:09 UTC (permalink / raw)
  To: buildroot

Dear Romain Naour,

On Sun, 13 Oct 2013 21:44:08 +0200, Romain Naour wrote:

> You're right, the static lib isn?t built with -fPIC.
> But the libcap build system build the static and shared libraries,
> even if you don't want one of them.
> 
> The build failure [1] is caused by the missing -fPIC during the build of libcap.so.2.22
> 
> So, we may add -fPIC if BR2_PREFER_STATIC_LIB=y and the shared lib is build correctly
> (ok it's weird)
> Or add a patch for enable/disable separately the static/shared build.

If BR2_PREFER_STATIC_LIB=y, then not shared library should be built at
all. Even though the naming of the option doesn't make it clear for the
moment.

And therefore, when BR2_PREFER_STATIC_LIB=y, passing -fPIC should not
be needed, as we're building only static libraries.

I had a quick look at libcap, and we can easily build only the static
or shared library by doing the $(MAKE) only in $(@D)/libcap, and using
the libcap.a and libcap.so targets. But the install target is not really
adapted to that, so we would have to install things manually.

Maybe a little patch to the libcap/Makefile which understands
BUILD_STATIC and BUILD_SHARED variables would be good.

Best regards,

Thomas
-- 
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com

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

* [Buildroot] [PATCH 1/1] libcap: fix static linking issue
  2013-10-06 20:10 [Buildroot] [PATCH 1/1] libcap: fix static linking issue Romain Naour
  2013-10-06 21:29 ` Thomas Petazzoni
@ 2013-11-01 17:48 ` Thomas Petazzoni
  2013-11-02 15:52   ` Romain Naour
  1 sibling, 1 reply; 8+ messages in thread
From: Thomas Petazzoni @ 2013-11-01 17:48 UTC (permalink / raw)
  To: buildroot

Dear Romain Naour,

On Sun, 06 Oct 2013 22:10:24 +0200, Romain Naour wrote:
> Add -fPIC flag
> 
> Fixes:
> http://autobuild.buildroot.net/results/619bceb3491ecd2ed4e1ae552fdb237a0ed2fa47/
> 
> Signed-off-by: Romain Naour <romain.naour@openwide.fr>

I've just sent a patch which I believe is a better fix than this one.
The problem was that libcap was building the shared library
unconditionally. By adjusting the libcap build system, we can make it
build only the static library, and therefore make things work properly.

Best regards,

Thomas
-- 
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com

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

* [Buildroot] [PATCH 1/1] libcap: fix static linking issue
  2013-11-01 17:48 ` Thomas Petazzoni
@ 2013-11-02 15:52   ` Romain Naour
  0 siblings, 0 replies; 8+ messages in thread
From: Romain Naour @ 2013-11-02 15:52 UTC (permalink / raw)
  To: buildroot

Le 01/11/2013 18:48, Thomas Petazzoni a ?crit :
> Dear Romain Naour,
>
> On Sun, 06 Oct 2013 22:10:24 +0200, Romain Naour wrote:
>> Add -fPIC flag
>>
>> Fixes:
>> http://autobuild.buildroot.net/results/619bceb3491ecd2ed4e1ae552fdb237a0ed2fa47/
>>
>> Signed-off-by: Romain Naour <romain.naour@openwide.fr>
> I've just sent a patch which I believe is a better fix than this one.
> The problem was that libcap was building the shared library
> unconditionally. By adjusting the libcap build system, we can make it
> build only the static library, and therefore make things work properly.
>
> Best regards,
>
> Thomas
Hi Thomas,

I haven't take time to rework on this path :-/
Thanks.

Best regards,
Romain

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

end of thread, other threads:[~2013-11-02 15:52 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-10-06 20:10 [Buildroot] [PATCH 1/1] libcap: fix static linking issue Romain Naour
2013-10-06 21:29 ` Thomas Petazzoni
2013-10-08  8:11   ` Romain Naour
2013-10-08  8:13     ` Thomas Petazzoni
2013-10-13 19:44       ` Romain Naour
2013-10-16 16:09         ` Thomas Petazzoni
2013-11-01 17:48 ` Thomas Petazzoni
2013-11-02 15:52   ` Romain Naour

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