Buildroot Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [Buildroot] [PATCH 0/5] Fix libnl static linking
@ 2015-03-07 11:40 Thomas Petazzoni
  2015-03-07 11:40 ` [Buildroot] [PATCH 1/5] libnl: use the backported patch for poll.h issue Thomas Petazzoni
                   ` (5 more replies)
  0 siblings, 6 replies; 10+ messages in thread
From: Thomas Petazzoni @ 2015-03-07 11:40 UTC (permalink / raw)
  To: buildroot

Hello,

This set of patches was triggered by the batctl static linking patch
sent by Jens Zettelmeyer.

It turns out that batctl properly uses pkg-config to know how to link
with libnl, so it's ctually libnl pkg-config that aren't correct. This
is what the first two patches are fixing. This fixes batctl static
linking.

As a follow-up, I reviewed some of the packages that link against
libnl and have special handling for static linking, and did some
related cleanups.

Thomas

Thomas Petazzoni (5):
  libnl: use the backported patch for poll.h issue
  libnl: add patch to add Libs.private in libnl-3.0.pc
  crda: remove static library handling
  ti-utils: simplify static linking case by using pkg-config
  iw: simplify static linking handling

 package/crda/crda.mk                               | 13 ----------
 package/iw/iw.mk                                   |  6 -----
 ...etlink-h-use-poll-h-instead-of-sys-poll-h.patch | 18 -------------
 ...link.h-fix-build-including-poll.h-with-th.patch | 30 ++++++++++++++++++++++
 ...ibs.private-field-in-libnl-pkg-config-fil.patch | 30 ++++++++++++++++++++++
 package/ti-utils/ti-utils.mk                       |  9 ++++---
 6 files changed, 66 insertions(+), 40 deletions(-)
 delete mode 100644 package/libnl/0001-netlink-netlink-h-use-poll-h-instead-of-sys-poll-h.patch
 create mode 100644 package/libnl/0001-netlink-netlink.h-fix-build-including-poll.h-with-th.patch
 create mode 100644 package/libnl/0002-build-add-Libs.private-field-in-libnl-pkg-config-fil.patch

-- 
2.1.0

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

* [Buildroot] [PATCH 1/5] libnl: use the backported patch for poll.h issue
  2015-03-07 11:40 [Buildroot] [PATCH 0/5] Fix libnl static linking Thomas Petazzoni
@ 2015-03-07 11:40 ` Thomas Petazzoni
  2015-03-07 11:40 ` [Buildroot] [PATCH 2/5] libnl: add patch to add Libs.private in libnl-3.0.pc Thomas Petazzoni
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 10+ messages in thread
From: Thomas Petazzoni @ 2015-03-07 11:40 UTC (permalink / raw)
  To: buildroot

Now that J?rg's patch has been merged upstream, let's use the
backported version, in a git format.

Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
---
 ...etlink-h-use-poll-h-instead-of-sys-poll-h.patch | 18 -------------
 ...link.h-fix-build-including-poll.h-with-th.patch | 30 ++++++++++++++++++++++
 2 files changed, 30 insertions(+), 18 deletions(-)
 delete mode 100644 package/libnl/0001-netlink-netlink-h-use-poll-h-instead-of-sys-poll-h.patch
 create mode 100644 package/libnl/0001-netlink-netlink.h-fix-build-including-poll.h-with-th.patch

diff --git a/package/libnl/0001-netlink-netlink-h-use-poll-h-instead-of-sys-poll-h.patch b/package/libnl/0001-netlink-netlink-h-use-poll-h-instead-of-sys-poll-h.patch
deleted file mode 100644
index dd55cd4..0000000
--- a/package/libnl/0001-netlink-netlink-h-use-poll-h-instead-of-sys-poll-h.patch
+++ /dev/null
@@ -1,18 +0,0 @@
-netlink/netlink.h: As the poll() man page recommends include the <poll.h>
-instead of <sys/poll.h>. This removes an error when building libdl against 
-the musl C library.
-
-Signed-off-by: J?rg Krause <jkrause@posteo.de>
-
-diff -purN libnl-3.2.25.orig/include/netlink/netlink.h libnl-3.2.25/include/netlink/netlink.h
---- libnl-3.2.25.orig/include/netlink/netlink.h	2014-09-01 11:42:37.254724124 +0200
-+++ libnl-3.2.25/include/netlink/netlink.h	2014-09-01 11:42:58.254724255 +0200
-@@ -16,7 +16,7 @@
- #include <stdint.h>
- #include <string.h>
- #include <stdlib.h>
--#include <sys/poll.h>
-+#include <poll.h>
- #include <sys/socket.h>
- #include <sys/types.h>
- #include <sys/time.h>
diff --git a/package/libnl/0001-netlink-netlink.h-fix-build-including-poll.h-with-th.patch b/package/libnl/0001-netlink-netlink.h-fix-build-including-poll.h-with-th.patch
new file mode 100644
index 0000000..53a299b
--- /dev/null
+++ b/package/libnl/0001-netlink-netlink.h-fix-build-including-poll.h-with-th.patch
@@ -0,0 +1,30 @@
+From 14128766e80823f79a3b2c97573da1aea5c16ea8 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?J=C3=B6rg=20Krause?= <jkrause@posteo.de>
+Date: Mon, 1 Sep 2014 12:38:10 +0200
+Subject: [PATCH 1/2] netlink/netlink.h: fix build including <poll.h> with the
+ musl C library
+
+https://github.com/thom311/libnl/pull/64
+
+Signed-off-by: Thomas Haller <thaller@redhat.com>
+Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
+---
+ include/netlink/netlink.h | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/include/netlink/netlink.h b/include/netlink/netlink.h
+index 28dba06..61656b3 100644
+--- a/include/netlink/netlink.h
++++ b/include/netlink/netlink.h
+@@ -16,7 +16,7 @@
+ #include <stdint.h>
+ #include <string.h>
+ #include <stdlib.h>
+-#include <sys/poll.h>
++#include <poll.h>
+ #include <sys/socket.h>
+ #include <sys/types.h>
+ #include <sys/time.h>
+-- 
+2.1.0
+
-- 
2.1.0

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

* [Buildroot] [PATCH 2/5] libnl: add patch to add Libs.private in libnl-3.0.pc
  2015-03-07 11:40 [Buildroot] [PATCH 0/5] Fix libnl static linking Thomas Petazzoni
  2015-03-07 11:40 ` [Buildroot] [PATCH 1/5] libnl: use the backported patch for poll.h issue Thomas Petazzoni
@ 2015-03-07 11:40 ` Thomas Petazzoni
  2015-03-09 12:57   ` Gustavo Zacarias
  2015-03-07 11:40 ` [Buildroot] [PATCH 3/5] crda: remove static library handling Thomas Petazzoni
                   ` (3 subsequent siblings)
  5 siblings, 1 reply; 10+ messages in thread
From: Thomas Petazzoni @ 2015-03-07 11:40 UTC (permalink / raw)
  To: buildroot

Having a properly defined Libs.private field allows to make sure
static linking against libnl-3.0 works fine, at least as long as
pkg-config is used.

Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
---
 ...ibs.private-field-in-libnl-pkg-config-fil.patch | 30 ++++++++++++++++++++++
 1 file changed, 30 insertions(+)
 create mode 100644 package/libnl/0002-build-add-Libs.private-field-in-libnl-pkg-config-fil.patch

diff --git a/package/libnl/0002-build-add-Libs.private-field-in-libnl-pkg-config-fil.patch b/package/libnl/0002-build-add-Libs.private-field-in-libnl-pkg-config-fil.patch
new file mode 100644
index 0000000..845a593
--- /dev/null
+++ b/package/libnl/0002-build-add-Libs.private-field-in-libnl-pkg-config-fil.patch
@@ -0,0 +1,30 @@
+From db0d59cd06f3ffd350379847c0885e1bfb85af0f Mon Sep 17 00:00:00 2001
+From: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
+Date: Sat, 7 Mar 2015 11:34:42 +0100
+Subject: [PATCH 2/2] build: add Libs.private field in libnl pkg-config file
+
+In order to support static linking, the libnl pkg-config file should
+indicate in its Libs.private field the libraries that libnl-3.0.a
+requires. The LIBS variable contains the appropriate list of
+libraries: -lm in all cases, and -lpthread when pthread support is
+enabled. This allows to statically link applications against libnl
+properly.
+
+Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
+---
+ libnl-3.0.pc.in | 1 +
+ 1 file changed, 1 insertion(+)
+
+diff --git a/libnl-3.0.pc.in b/libnl-3.0.pc.in
+index b87e3dc..ddbc999 100644
+--- a/libnl-3.0.pc.in
++++ b/libnl-3.0.pc.in
+@@ -7,4 +7,5 @@ Name: libnl
+ Description: Convenience library for netlink sockets
+ Version: @PACKAGE_VERSION@
+ Libs: -L${libdir} -lnl- at MAJ_VERSION@
++Libs.private: @LIBS@
+ Cflags: -I${includedir}/libnl at MAJ_VERSION@
+-- 
+2.1.0
+
-- 
2.1.0

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

* [Buildroot] [PATCH 3/5] crda: remove static library handling
  2015-03-07 11:40 [Buildroot] [PATCH 0/5] Fix libnl static linking Thomas Petazzoni
  2015-03-07 11:40 ` [Buildroot] [PATCH 1/5] libnl: use the backported patch for poll.h issue Thomas Petazzoni
  2015-03-07 11:40 ` [Buildroot] [PATCH 2/5] libnl: add patch to add Libs.private in libnl-3.0.pc Thomas Petazzoni
@ 2015-03-07 11:40 ` Thomas Petazzoni
  2015-03-07 11:52   ` Samuel Martin
  2015-03-07 13:46   ` Thomas Petazzoni
  2015-03-07 11:40 ` [Buildroot] [PATCH 4/5] ti-utils: simplify static linking case by using pkg-config Thomas Petazzoni
                   ` (2 subsequent siblings)
  5 siblings, 2 replies; 10+ messages in thread
From: Thomas Petazzoni @ 2015-03-07 11:40 UTC (permalink / raw)
  To: buildroot

In commit d54418f2bcd9267fd049511d6236fb91c83b94ea ("crda: fix static
build failure"), some static linking handling was added in crda. But
in a later commit, 7c08fa935f55d108e20834e6b4bba664e1d2d408 ("crda:
needs dynamic library support"), crda was marked as not available for
static only builds.

This means that the static linking logic in crda.mk is now just dead
code, so this commit gets rid of it.

Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
---
 package/crda/crda.mk | 13 -------------
 1 file changed, 13 deletions(-)

diff --git a/package/crda/crda.mk b/package/crda/crda.mk
index abfbb8e..24bfd5f 100644
--- a/package/crda/crda.mk
+++ b/package/crda/crda.mk
@@ -12,17 +12,6 @@ CRDA_DEPENDENCIES = host-pkgconf host-python-m2crypto \
 CRDA_LICENSE = ISC
 CRDA_LICENSE_FILES = LICENSE
 
-# libnl-3 needs -lm (for rint) and -lpthread if linking statically.
-# And library order matters hence stick -lnl-3 first since it's appended
-# in the crda Makefiles as in NLLIBS+=-lnl-3 ... thus failing.
-#
-# libgcrypt needs -lgpg-error if linking statically, which is correctly
-# set by the libgcrypt-config script (and in the right order).
-ifeq ($(BR2_STATIC_LIBS),y)
-CRDA_NLLIBS += -lnl-3 -lm -lpthread
-CRDA_LDLIBS += `$(STAGING_DIR)/usr/bin/libgcrypt-config --libs`
-endif
-
 # * key2pub.py currently is not python3 compliant (though python2/python3
 #   compliance could rather easily be achieved.
 # * key2pub.py uses M2Crypto python module, which is only available for
@@ -30,8 +19,6 @@ endif
 #   interpreter, hence the host-python dependency and the PYTHON variable.
 define CRDA_BUILD_CMDS
 	$(TARGET_CONFIGURE_OPTS) \
-		LDLIBS="$(CRDA_LDLIBS)" \
-		NLLIBS="$(CRDA_NLLIBS)" \
 		PYTHON=$(HOST_DIR)/usr/bin/python2 \
 		$(MAKE) all_noverify -C $(@D)
 endef
-- 
2.1.0

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

* [Buildroot] [PATCH 4/5] ti-utils: simplify static linking case by using pkg-config
  2015-03-07 11:40 [Buildroot] [PATCH 0/5] Fix libnl static linking Thomas Petazzoni
                   ` (2 preceding siblings ...)
  2015-03-07 11:40 ` [Buildroot] [PATCH 3/5] crda: remove static library handling Thomas Petazzoni
@ 2015-03-07 11:40 ` Thomas Petazzoni
  2015-03-07 11:40 ` [Buildroot] [PATCH 5/5] iw: simplify static linking handling Thomas Petazzoni
  2015-03-15 17:10 ` [Buildroot] [PATCH 0/5] Fix libnl static linking Thomas Petazzoni
  5 siblings, 0 replies; 10+ messages in thread
From: Thomas Petazzoni @ 2015-03-07 11:40 UTC (permalink / raw)
  To: buildroot

Instead of hardcoding the dependencies of libnl, use pkg-config to
discover them.

Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
---
 package/ti-utils/ti-utils.mk | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/package/ti-utils/ti-utils.mk b/package/ti-utils/ti-utils.mk
index 7ee7afa..3141219 100644
--- a/package/ti-utils/ti-utils.mk
+++ b/package/ti-utils/ti-utils.mk
@@ -6,14 +6,17 @@
 
 TI_UTILS_VERSION = 06dbdb2727354b5f3ad7c723897f40051fddee49
 TI_UTILS_SITE = $(call github,gxk,ti-utils,$(TI_UTILS_VERSION))
-TI_UTILS_DEPENDENCIES = libnl
+TI_UTILS_DEPENDENCIES = libnl host-pkgconf
 TI_UTILS_LICENSE = BSD-3c
 TI_UTILS_LICENSE_FILES = COPYING
 
+TI_UTILS_CFLAGS = $(shell $(PKG_CONFIG_HOST_BINARY) --cflags libnl-genl-3.0)
+TI_UTILS_LIBS = $(shell $(PKG_CONFIG_HOST_BINARY) --libs libnl-genl-3.0)
+
 define TI_UTILS_BUILD_CMDS
 	$(MAKE1) NFSROOT="$(STAGING_DIR)" \
-		CC="$(TARGET_CC) $(TARGET_CFLAGS) $(TARGET_LDFLAGS) -I$(STAGING_DIR)/usr/include/libnl3" \
-		LIBS="-lnl-3 -lnl-genl-3 -lpthread -lm" -C $(@D) all
+		CC="$(TARGET_CC) $(TARGET_CFLAGS) $(TARGET_LDFLAGS) $(TI_UTILS_CFLAGS)" \
+		LIBS="$(TI_UTILS_LIBS)" -C $(@D) all
 endef
 
 define TI_UTILS_INSTALL_TARGET_CMDS
-- 
2.1.0

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

* [Buildroot] [PATCH 5/5] iw: simplify static linking handling
  2015-03-07 11:40 [Buildroot] [PATCH 0/5] Fix libnl static linking Thomas Petazzoni
                   ` (3 preceding siblings ...)
  2015-03-07 11:40 ` [Buildroot] [PATCH 4/5] ti-utils: simplify static linking case by using pkg-config Thomas Petazzoni
@ 2015-03-07 11:40 ` Thomas Petazzoni
  2015-03-15 17:10 ` [Buildroot] [PATCH 0/5] Fix libnl static linking Thomas Petazzoni
  5 siblings, 0 replies; 10+ messages in thread
From: Thomas Petazzoni @ 2015-03-07 11:40 UTC (permalink / raw)
  To: buildroot

Now that libnl pkg-config file is correct, there is no need to have
special handling for static linking in the iw package: it already uses
pkg-config to get the necessary flags to link with libnl.

Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
---
 package/iw/iw.mk | 6 ------
 1 file changed, 6 deletions(-)

diff --git a/package/iw/iw.mk b/package/iw/iw.mk
index df6e257..1286915 100644
--- a/package/iw/iw.mk
+++ b/package/iw/iw.mk
@@ -14,12 +14,6 @@ IW_MAKE_OPTS = CC="$(TARGET_CC)" LD="$(TARGET_LD)" LDFLAGS="$(TARGET_LDFLAGS)"
 IW_MAKE_ENV = PKG_CONFIG="$(HOST_DIR)/usr/bin/pkg-config" \
 	GIT_DIR=$(IW_DIR)
 
-ifeq ($(BR2_STATIC_LIBS),y)
-# libnl needs pthread/m, so we need to explicitly with them when static
-# these need to added AFTER libnl, so we have to override LIBS completely
-IW_MAKE_OPTS += LIBS='-lnl-genl-3 -lnl-3 -lpthread -lm'
-endif
-
 define IW_BUILD_CMDS
 	$(IW_MAKE_ENV) $(MAKE) $(IW_MAKE_OPTS) -C $(@D)
 endef
-- 
2.1.0

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

* [Buildroot] [PATCH 3/5] crda: remove static library handling
  2015-03-07 11:40 ` [Buildroot] [PATCH 3/5] crda: remove static library handling Thomas Petazzoni
@ 2015-03-07 11:52   ` Samuel Martin
  2015-03-07 13:46   ` Thomas Petazzoni
  1 sibling, 0 replies; 10+ messages in thread
From: Samuel Martin @ 2015-03-07 11:52 UTC (permalink / raw)
  To: buildroot

On Sat, Mar 7, 2015 at 12:40 PM, Thomas Petazzoni
<thomas.petazzoni@free-electrons.com> wrote:
> In commit d54418f2bcd9267fd049511d6236fb91c83b94ea ("crda: fix static
> build failure"), some static linking handling was added in crda. But
> in a later commit, 7c08fa935f55d108e20834e6b4bba664e1d2d408 ("crda:
> needs dynamic library support"), crda was marked as not available for
> static only builds.
>
> This means that the static linking logic in crda.mk is now just dead
> code, so this commit gets rid of it.
>
> Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Acked-by: Samuel Martin <s.martin49@gmail.com>

Regards,


-- 
Samuel

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

* [Buildroot] [PATCH 3/5] crda: remove static library handling
  2015-03-07 11:40 ` [Buildroot] [PATCH 3/5] crda: remove static library handling Thomas Petazzoni
  2015-03-07 11:52   ` Samuel Martin
@ 2015-03-07 13:46   ` Thomas Petazzoni
  1 sibling, 0 replies; 10+ messages in thread
From: Thomas Petazzoni @ 2015-03-07 13:46 UTC (permalink / raw)
  To: buildroot

Hello,

On Sat,  7 Mar 2015 12:40:20 +0100, Thomas Petazzoni wrote:
> In commit d54418f2bcd9267fd049511d6236fb91c83b94ea ("crda: fix static
> build failure"), some static linking handling was added in crda. But
> in a later commit, 7c08fa935f55d108e20834e6b4bba664e1d2d408 ("crda:
> needs dynamic library support"), crda was marked as not available for
> static only builds.
> 
> This means that the static linking logic in crda.mk is now just dead
> code, so this commit gets rid of it.
> 
> Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>

Applied.

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

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

* [Buildroot] [PATCH 2/5] libnl: add patch to add Libs.private in libnl-3.0.pc
  2015-03-07 11:40 ` [Buildroot] [PATCH 2/5] libnl: add patch to add Libs.private in libnl-3.0.pc Thomas Petazzoni
@ 2015-03-09 12:57   ` Gustavo Zacarias
  0 siblings, 0 replies; 10+ messages in thread
From: Gustavo Zacarias @ 2015-03-09 12:57 UTC (permalink / raw)
  To: buildroot

On 03/07/2015 08:40 AM, Thomas Petazzoni wrote:

> Having a properly defined Libs.private field allows to make sure
> static linking against libnl-3.0 works fine, at least as long as
> pkg-config is used.
> 
> Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>

Very...
Acked-by: Gustavo Zacarias <gustavo@zacarias.com.ar>

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

* [Buildroot] [PATCH 0/5] Fix libnl static linking
  2015-03-07 11:40 [Buildroot] [PATCH 0/5] Fix libnl static linking Thomas Petazzoni
                   ` (4 preceding siblings ...)
  2015-03-07 11:40 ` [Buildroot] [PATCH 5/5] iw: simplify static linking handling Thomas Petazzoni
@ 2015-03-15 17:10 ` Thomas Petazzoni
  5 siblings, 0 replies; 10+ messages in thread
From: Thomas Petazzoni @ 2015-03-15 17:10 UTC (permalink / raw)
  To: buildroot

Hello,

On Sat,  7 Mar 2015 12:40:17 +0100, Thomas Petazzoni wrote:

> Thomas Petazzoni (5):
>   libnl: use the backported patch for poll.h issue
>   libnl: add patch to add Libs.private in libnl-3.0.pc

Applied.

>   ti-utils: simplify static linking case by using pkg-config
>   iw: simplify static linking handling

Applied.

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

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

end of thread, other threads:[~2015-03-15 17:10 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-03-07 11:40 [Buildroot] [PATCH 0/5] Fix libnl static linking Thomas Petazzoni
2015-03-07 11:40 ` [Buildroot] [PATCH 1/5] libnl: use the backported patch for poll.h issue Thomas Petazzoni
2015-03-07 11:40 ` [Buildroot] [PATCH 2/5] libnl: add patch to add Libs.private in libnl-3.0.pc Thomas Petazzoni
2015-03-09 12:57   ` Gustavo Zacarias
2015-03-07 11:40 ` [Buildroot] [PATCH 3/5] crda: remove static library handling Thomas Petazzoni
2015-03-07 11:52   ` Samuel Martin
2015-03-07 13:46   ` Thomas Petazzoni
2015-03-07 11:40 ` [Buildroot] [PATCH 4/5] ti-utils: simplify static linking case by using pkg-config Thomas Petazzoni
2015-03-07 11:40 ` [Buildroot] [PATCH 5/5] iw: simplify static linking handling Thomas Petazzoni
2015-03-15 17:10 ` [Buildroot] [PATCH 0/5] Fix libnl static linking Thomas Petazzoni

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