All of lore.kernel.org
 help / color / mirror / Atom feed
* [Buildroot] [PATCH 1/2] package.snappy: fix static builds
@ 2016-10-01 19:04 Yann E. MORIN
  2016-10-01 19:04 ` [Buildroot] [PATCH 2/2] package/snappy: bump version Yann E. MORIN
  2016-10-02 19:19 ` [Buildroot] [PATCH 1/2] package.snappy: fix static builds Peter Korsgaard
  0 siblings, 2 replies; 6+ messages in thread
From: Yann E. MORIN @ 2016-10-01 19:04 UTC (permalink / raw)
  To: buildroot

For some toolchains, libstdc++ uses pthread symbols:

    .../lib/libstdc++.a(eh_alloc.o): In function `__gnu_cxx::__mutex::lock()':
    eh_alloc.cc:(.text._ZN9__gnu_cxx7__mutex4lockEv[_ZN9__gnu_cxx7__mutex4lockEv]+0x2):
    undefined reference to `pthread_mutex_lock'

and a lot of other pthread symbols...

However, when doing a static build, there is no way for the linker what
library to link in, so the build fails miserably if -pthread is not
specified at link time.

Fixes:
    http://autobuild.buildroot.org/results/15e/15ecaa23f0116e8120b3d62e553c838f0303df35/
    http://autobuild.buildroot.org/results/f0a/f0abe301816e39eb4ae26d3e8cd42d90901d5ac5/

Signed-off-by: "Yann E. MORIN" <yann.morin.1998@free.fr>

---
Note: snappy's buildsystem uses libtool, and libsnappy.la does have the
necessary -pthread listed as a "dependency":

   16 # Linker flags that cannot go in dependency_libs.
   17 inherited_linker_flags=' -pthread'

But that is not picked-up by libtool, and I don't know why...
---
 package/snappy/snappy.mk | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/package/snappy/snappy.mk b/package/snappy/snappy.mk
index b00dddf..3e8d603 100644
--- a/package/snappy/snappy.mk
+++ b/package/snappy/snappy.mk
@@ -16,4 +16,12 @@ SNAPPY_INSTALL_STAGING = YES
 # Disable tests
 SNAPPY_CONF_OPTS = --disable-gtest
 
+# libsnappy links with libstdc++. libstdc++ uses pthread symbols. libstdc++
+# does not have a .pc file, and its .la file does not mention -pthread.
+# So, static links to libstdc++ will fail if -pthread is not explicity
+# linked to. Only do that for static builds.
+ifeq ($(BR2_STATIC_LIBS),y)
+SNAPPY_CONF_OPTS += LIBS=-pthread
+endif
+
 $(eval $(autotools-package))
-- 
2.7.4

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

end of thread, other threads:[~2016-10-02 19:52 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-10-01 19:04 [Buildroot] [PATCH 1/2] package.snappy: fix static builds Yann E. MORIN
2016-10-01 19:04 ` [Buildroot] [PATCH 2/2] package/snappy: bump version Yann E. MORIN
2016-10-02 19:31   ` Peter Korsgaard
2016-10-02 19:44     ` Yann E. MORIN
2016-10-02 19:52       ` Peter Korsgaard
2016-10-02 19:19 ` [Buildroot] [PATCH 1/2] package.snappy: fix static builds Peter Korsgaard

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.