Buildroot Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [Buildroot] [PATCH v2] rabbitmq-c: link against zlib and libintl
@ 2016-01-28  8:45 Joris Lijssens
  2016-01-28  8:59 ` Thomas Petazzoni
  0 siblings, 1 reply; 4+ messages in thread
From: Joris Lijssens @ 2016-01-28  8:45 UTC (permalink / raw)
  To: buildroot

When building the amqp toolset and static linking is enabled, the
rabbitmq-c library needs to explicity link against zlib and libintl

Fixes:
http://autobuild.buildroot.net/results/2ef/2ef1ed958db8012224f9174334e9c58edace604a/
Signed-off-by: Joris Lijssens <joris.lijssens@gmail.com>
---
 ...bintl-are-needed-when-the-rabbitmq-toolse.patch | 87 ++++++++++++++++++++++
 1 file changed, 87 insertions(+)
 create mode 100644 package/rabbitmq-c/0001-Zlib-and-libintl-are-needed-when-the-rabbitmq-toolse.patch

diff --git a/package/rabbitmq-c/0001-Zlib-and-libintl-are-needed-when-the-rabbitmq-toolse.patch b/package/rabbitmq-c/0001-Zlib-and-libintl-are-needed-when-the-rabbitmq-toolse.patch
new file mode 100644
index 0000000..35facea
--- /dev/null
+++ b/package/rabbitmq-c/0001-Zlib-and-libintl-are-needed-when-the-rabbitmq-toolse.patch
@@ -0,0 +1,87 @@
+From 208bc5adb10c73add19abb70f204951d1ef1b8b8 Mon Sep 17 00:00:00 2001
+From: Joris Lijssens <joris.lijssens@gmail.com>
+Date: Thu, 28 Jan 2016 09:14:24 +0100
+Subject: [PATCH] Zlib and libintl are needed when the rabbitmq toolset is
+ staticaly linked
+
+Signed-off-by: Joris Lijssens <joris.lijssens@gmail.com>
+---
+ CMakeLists.txt             | 11 +++++++++++
+ librabbitmq/CMakeLists.txt |  2 +-
+ tools/CMakeLists.txt       | 10 +++++-----
+ 3 files changed, 17 insertions(+), 6 deletions(-)
+
+diff --git a/CMakeLists.txt b/CMakeLists.txt
+index 9b40a37..c9b1113 100644
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -71,6 +71,7 @@ else()
+   endif()
+ endif()
+ 
++
+ # Detect if we need to link against a socket library:
+ cmake_push_check_state()
+ if (WIN32)
+@@ -263,6 +264,16 @@ option(BUILD_API_DOCS "Build Doxygen API docs" ${DOXYGEN_FOUND})
+ option(ENABLE_SSL_SUPPORT "Enable SSL support" ON)
+ option(ENABLE_THREAD_SAFETY "Enable thread safety when using OpenSSL" ${Threads_FOUND})
+ 
++
++# Zlib and libintl are needed for the static linking of tools
++if (BUILD_STATIC_LIBS)
++  set(ZLIB_LIBRARY "z")
++  set(INTL_LIBRARY "intl")
++else ()
++  set(ZLIB_LIBRARY "")
++  set(INTL_LIBRARY "")
++endif()
++  
+ set(SSL_ENGINE "OpenSSL" CACHE STRING "SSL Backend to use, valid options: OpenSSL, cyaSSL, GnuTLS, PolarSSL")
+ mark_as_advanced(SSL_ENGINE)
+ 
+diff --git a/librabbitmq/CMakeLists.txt b/librabbitmq/CMakeLists.txt
+index 3c86094..46594f3 100644
+--- a/librabbitmq/CMakeLists.txt
++++ b/librabbitmq/CMakeLists.txt
+@@ -87,7 +87,7 @@ if (ENABLE_SSL_SUPPORT)
+         amqp_hostcheck.h
+     )
+     include_directories(${OPENSSL_INCLUDE_DIR})
+-    set(AMQP_SSL_LIBS ${OPENSSL_LIBRARIES})
++    set(AMQP_SSL_LIBS ${OPENSSL_LIBRARIES} ${ZLIB_LIBRARY})
+     if (APPLE)
+       # Apple has deprecated OpenSSL in 10.7+. This disables that warning.
+       set_source_files_properties(${AMQP_SSL_SRCS}
+diff --git a/tools/CMakeLists.txt b/tools/CMakeLists.txt
+index 52e3464..8658ea7 100644
+--- a/tools/CMakeLists.txt
++++ b/tools/CMakeLists.txt
+@@ -19,19 +19,19 @@ set(COMMON_SRCS
+     )
+ 
+ add_executable(amqp-publish publish.c ${COMMON_SRCS})
+-target_link_libraries(amqp-publish ${RMQ_LIBRARY_TARGET} ${POPT_LIBRARY})
++target_link_libraries(amqp-publish ${RMQ_LIBRARY_TARGET} ${POPT_LIBRARY} ${INTL_LIBRARY})
+ 
+ add_executable(amqp-get get.c ${COMMON_SRCS})
+-target_link_libraries(amqp-get ${RMQ_LIBRARY_TARGET} ${POPT_LIBRARY})
++target_link_libraries(amqp-get ${RMQ_LIBRARY_TARGET} ${POPT_LIBRARY} ${INTL_LIBRARY})
+ 
+ add_executable(amqp-consume consume.c ${PLATFORM_DIR}/process.c ${COMMON_SRCS})
+-target_link_libraries(amqp-consume ${RMQ_LIBRARY_TARGET} ${POPT_LIBRARY})
++target_link_libraries(amqp-consume ${RMQ_LIBRARY_TARGET} ${POPT_LIBRARY} ${INTL_LIBRARY})
+ 
+ add_executable(amqp-declare-queue declare_queue.c ${COMMON_SRCS})
+-target_link_libraries(amqp-declare-queue ${RMQ_LIBRARY_TARGET} ${POPT_LIBRARY})
++target_link_libraries(amqp-declare-queue ${RMQ_LIBRARY_TARGET} ${POPT_LIBRARY} ${INTL_LIBRARY})
+ 
+ add_executable(amqp-delete-queue delete_queue.c ${COMMON_SRCS})
+-target_link_libraries(amqp-delete-queue ${RMQ_LIBRARY_TARGET} ${POPT_LIBRARY})
++target_link_libraries(amqp-delete-queue ${RMQ_LIBRARY_TARGET} ${POPT_LIBRARY} ${INTL_LIBRARY})
+ 
+ if (BUILD_TOOLS_DOCS)
+   if (XMLTO_FOUND)
+-- 
+1.8.3.1
+
-- 
1.8.3.1

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

* [Buildroot] [PATCH v2] rabbitmq-c: link against zlib and libintl
  2016-01-28  8:45 [Buildroot] [PATCH v2] rabbitmq-c: link against zlib and libintl Joris Lijssens
@ 2016-01-28  8:59 ` Thomas Petazzoni
  2016-01-28  9:11   ` Joris Lijssens
  0 siblings, 1 reply; 4+ messages in thread
From: Thomas Petazzoni @ 2016-01-28  8:59 UTC (permalink / raw)
  To: buildroot

Dear Joris Lijssens,

On Thu, 28 Jan 2016 09:45:25 +0100, Joris Lijssens wrote:
> When building the amqp toolset and static linking is enabled, the
> rabbitmq-c library needs to explicity link against zlib and libintl
> 
> Fixes:
> http://autobuild.buildroot.net/results/2ef/2ef1ed958db8012224f9174334e9c58edace604a/
> Signed-off-by: Joris Lijssens <joris.lijssens@gmail.com>

Hum, I think I already reviewed a similar patch, and said it wasn't
correct, so I still stand on my position that it isn't correct.

If you look at the failure at
http://autobuild.buildroot.net/results/2ef/2ef1ed958db8012224f9174334e9c58edace604a/build-end.log,
rabbitmq-c is *NOT* using zlib or libintl.

What you are seeing is that:

 * libcrypto is using zlib
 * libpopt is using libintl

So rabbitmq-c should *NOT* be changed to link against zlib or libintl.
It should be changed to query OpenSSL (which provides libcrypto) and
popt to know against which libraries to link to use OpenSSL and popt.

See my previous answer on the matter on:

Subject: Re: [Buildroot] [PATCH] rabbitmq-c: link against zlib and libintl
Date: Wed, 20 Jan 2016 10:41:56 +0100

Thanks!

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

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

* [Buildroot] [PATCH v2] rabbitmq-c: link against zlib and libintl
  2016-01-28  8:59 ` Thomas Petazzoni
@ 2016-01-28  9:11   ` Joris Lijssens
  2016-01-28 11:06     ` Thomas Petazzoni
  0 siblings, 1 reply; 4+ messages in thread
From: Joris Lijssens @ 2016-01-28  9:11 UTC (permalink / raw)
  To: buildroot

Hello Thomas,

I know that libcrypto is using zlib and libpopt is using libintl, but i
have no idea how to query opensll and popt in cmake. Can you give some
pointers?

regards,
Joris

On 28 January 2016 at 09:59, Thomas Petazzoni <
thomas.petazzoni@free-electrons.com> wrote:

> Dear Joris Lijssens,
>
> On Thu, 28 Jan 2016 09:45:25 +0100, Joris Lijssens wrote:
> > When building the amqp toolset and static linking is enabled, the
> > rabbitmq-c library needs to explicity link against zlib and libintl
> >
> > Fixes:
> >
> http://autobuild.buildroot.net/results/2ef/2ef1ed958db8012224f9174334e9c58edace604a/
> > Signed-off-by: Joris Lijssens <joris.lijssens@gmail.com>
>
> Hum, I think I already reviewed a similar patch, and said it wasn't
> correct, so I still stand on my position that it isn't correct.
>
> If you look at the failure at
>
> http://autobuild.buildroot.net/results/2ef/2ef1ed958db8012224f9174334e9c58edace604a/build-end.log
> ,
> rabbitmq-c is *NOT* using zlib or libintl.
>
> What you are seeing is that:
>
>  * libcrypto is using zlib
>  * libpopt is using libintl
>
> So rabbitmq-c should *NOT* be changed to link against zlib or libintl.
> It should be changed to query OpenSSL (which provides libcrypto) and
> popt to know against which libraries to link to use OpenSSL and popt.
>
> See my previous answer on the matter on:
>
> Subject: Re: [Buildroot] [PATCH] rabbitmq-c: link against zlib and libintl
> Date: Wed, 20 Jan 2016 10:41:56 +0100
>
> Thanks!
>
> Thomas
> --
> Thomas Petazzoni, CTO, Free Electrons
> Embedded Linux, Kernel and Android engineering
> http://free-electrons.com
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.busybox.net/pipermail/buildroot/attachments/20160128/2f82d3f0/attachment.html>

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

* [Buildroot] [PATCH v2] rabbitmq-c: link against zlib and libintl
  2016-01-28  9:11   ` Joris Lijssens
@ 2016-01-28 11:06     ` Thomas Petazzoni
  0 siblings, 0 replies; 4+ messages in thread
From: Thomas Petazzoni @ 2016-01-28 11:06 UTC (permalink / raw)
  To: buildroot

Joris,

(Please don't top post, this is considered bad practice on most mailing
list.)

I'm adding Samuel Martin in Cc, he is our CMake expert :)

On Thu, 28 Jan 2016 10:11:21 +0100, Joris Lijssens wrote:

> I know that libcrypto is using zlib and libpopt is using libintl, but i
> have no idea how to query opensll and popt in cmake. Can you give some
> pointers?

So, for the libcrypto -> zlib case, I had a look. rabbitmq-c properly
uses find_package(OpenSSL), which uses pkg-config internally, and there
knows about the -lz dependency. Building the rabbitmq-c library (in the
librabbitmq/ directory) works fine.

However, the problem occurs when linking the tools (in the tools/
directory): they are linked against the librabbitmq library. They know
that they should link with -lssl -lcrypto (and I couldn't figure out
how) but they don't know they should link with -lz.

Samuel, what is the usual solution for such situations with CMake ?

If you want to reproduce by yourself, here is a minimal defconfig:

BR2_arm=y
BR2_STATIC_LIBS=y
BR2_TOOLCHAIN_EXTERNAL=y
BR2_TOOLCHAIN_EXTERNAL_CUSTOM=y
BR2_TOOLCHAIN_EXTERNAL_DOWNLOAD=y
BR2_TOOLCHAIN_EXTERNAL_URL="http://autobuild.buildroot.org/toolchains/tarballs/br-arm-full-static-2015.11-rc1-71-g90d1299.tar.bz2"
BR2_TOOLCHAIN_EXTERNAL_GCC_4_9=y
BR2_TOOLCHAIN_EXTERNAL_HEADERS_3_14=y
BR2_TOOLCHAIN_EXTERNAL_LOCALE=y
# BR2_TOOLCHAIN_EXTERNAL_HAS_THREADS_DEBUG is not set
BR2_TOOLCHAIN_EXTERNAL_INET_RPC=y
BR2_TOOLCHAIN_EXTERNAL_CXX=y
BR2_INIT_NONE=y
BR2_SYSTEM_BIN_SH_NONE=y
# BR2_PACKAGE_BUSYBOX is not set
BR2_PACKAGE_OPENSSL=y
BR2_PACKAGE_RABBITMQ_C=y
BR2_PACKAGE_POPT=y
# BR2_TARGET_ROOTFS_TAR is not set

(This one produces only the libcrypto -> zlib problem. To produce the
popt problem, you need to add BR2_PACKAGE_GETTEXT=y).

The popt problem is exactly the same: pkg-config is used to detect
popt,  popt.pc contains -lintl, but it isn't used when linking the
tools.

Samuel, help :-)

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

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

end of thread, other threads:[~2016-01-28 11:06 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-01-28  8:45 [Buildroot] [PATCH v2] rabbitmq-c: link against zlib and libintl Joris Lijssens
2016-01-28  8:59 ` Thomas Petazzoni
2016-01-28  9:11   ` Joris Lijssens
2016-01-28 11:06     ` Thomas Petazzoni

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