All of lore.kernel.org
 help / color / mirror / Atom feed
* [Buildroot] [PATCH] package/libevent: fix static build
@ 2015-02-15 21:33 Romain Naour
  2015-02-23 18:00 ` Thomas Petazzoni
  0 siblings, 1 reply; 6+ messages in thread
From: Romain Naour @ 2015-02-15 21:33 UTC (permalink / raw)
  To: buildroot

For some reason, libevent silently fail to enable openssl support
even when it's explicitly requested.

Somes flags are missing when checking for zlib and openssl.

Fixes:
http://autobuild.buildroot.net/results/713/71362af474461e99b7c188a316aa644a0faaad2e

Signed-off-by: Romain Naour <romain.naour@openwide.fr>
---
 .../0002-Fix-openssl-check-for-static-build.patch  | 93 ++++++++++++++++++++++
 package/libevent/libevent.mk                       |  1 +
 2 files changed, 94 insertions(+)
 create mode 100644 package/libevent/0002-Fix-openssl-check-for-static-build.patch

diff --git a/package/libevent/0002-Fix-openssl-check-for-static-build.patch b/package/libevent/0002-Fix-openssl-check-for-static-build.patch
new file mode 100644
index 0000000..6db0c4d
--- /dev/null
+++ b/package/libevent/0002-Fix-openssl-check-for-static-build.patch
@@ -0,0 +1,93 @@
+From 17e7b2bca663d0f434d35ecc3b3ecead49669ecf Mon Sep 17 00:00:00 2001
+From: Romain Naour <romain.naour@openwide.fr>
+Date: Sun, 15 Feb 2015 19:43:11 +0100
+Subject: [PATCH] Fix openssl check for static build
+
+For some reason, AC_SEARCH_LIBS([inflateEnd], [z] forget to link with -lz
+
+config.log:
+configure:12914: checking for library containing inflateEnd
+configure:12945: Path/to/usr/bin/arm-linux-gcc -o conftest    -Os -g2 -static -Wall -fno-strict-aliasing   -static conftest.c  >&5
+/tmp/cc4iscfI.o: In function `main':
+Path/to/libevent-2.0.22-stable/conftest.c:36: undefined reference to `inflateEnd'
+collect2: error: ld returned 1 exit status
+
+Ditto for AC_SEARCH_LIBS([SSL_new], [ssl] (forget to link with -lssl -lcrypto
+and -lz)
+
+config.log:
+configure:13015: checking for library containing SSL_new
+configure:13046: Path/to/usr/bin/arm-linux-gcc -o conftest    -Os -g2 -static -Wall -fno-strict-aliasing   -static conftest.c  >&5
+/tmp/cc65AA50.o: In function `main':
+Path/to/libevent-2.0.22-stable/conftest.c:38: undefined reference to `SSL_new'
+collect2: error: ld returned 1 exit status
+
+Also add $(ZLIB_LIBS) when linking with ../libevent_openssl.la.
+
+Signed-off-by: Romain Naour <romain.naour@openwide.fr>
+---
+ configure.ac       | 6 +++---
+ sample/Makefile.am | 2 +-
+ test/Makefile.am   | 2 +-
+ 3 files changed, 5 insertions(+), 5 deletions(-)
+
+diff --git a/configure.ac b/configure.ac
+index d42edd8..814bd01 100644
+--- a/configure.ac
++++ b/configure.ac
+@@ -147,7 +147,7 @@ if test "x$ac_cv_header_zlib_h" = "xyes"; then
+ dnl Determine if we have zlib for regression tests
+ dnl Don't put this one in LIBS
+ save_LIBS="$LIBS"
+-LIBS=""
++LIBS="-lz"
+ ZLIB_LIBS=""
+ have_zlib=no
+ AC_SEARCH_LIBS([inflateEnd], [z],
+@@ -175,7 +175,7 @@ AC_CHECK_HEADERS([openssl/bio.h])
+ 
+ if test "$enable_openssl" = "yes"; then
+ save_LIBS="$LIBS"
+-LIBS=""
++LIBS="-lssl -lcrypto $ZLIB_LIBS"
+ OPENSSL_LIBS=""
+ have_openssl=no
+ AC_SEARCH_LIBS([SSL_new], [ssl],
+@@ -183,7 +183,7 @@ AC_SEARCH_LIBS([SSL_new], [ssl],
+ 	OPENSSL_LIBS="$LIBS -lcrypto $EV_LIB_GDI $EV_LIB_WS32 $OPENSSL_LIBADD"
+ 	AC_DEFINE(HAVE_OPENSSL, 1, [Define if the system has openssl])],
+ 	[have_openssl=no],
+-	[-lcrypto $EV_LIB_GDI $EV_LIB_WS32 $OPENSSL_LIBADD])
++	[$ZLIB_LIBS -lcrypto $EV_LIB_GDI $EV_LIB_WS32 $OPENSSL_LIBADD])
+ LIBS="$save_LIBS"
+ AC_SUBST(OPENSSL_LIBS)
+ fi
+diff --git a/sample/Makefile.am b/sample/Makefile.am
+index c926f4e..37329ef 100644
+--- a/sample/Makefile.am
++++ b/sample/Makefile.am
+@@ -21,7 +21,7 @@ http_server_SOURCES = http-server.c
+ if OPENSSL
+ noinst_PROGRAMS += le-proxy
+ le_proxy_SOURCES = le-proxy.c
+-le_proxy_LDADD = $(LDADD) ../libevent_openssl.la -lssl -lcrypto ${OPENSSL_LIBADD}
++le_proxy_LDADD = $(LDADD) ../libevent_openssl.la -lssl -lcrypto ${OPENSSL_LIBADD} $(ZLIB_LIBS)
+ endif
+ 
+ verify:
+diff --git a/test/Makefile.am b/test/Makefile.am
+index 0253a49..5b1998e 100644
+--- a/test/Makefile.am
++++ b/test/Makefile.am
+@@ -72,7 +72,7 @@ regress_LDFLAGS = $(PTHREAD_CFLAGS)
+ 
+ if OPENSSL
+ regress_SOURCES += regress_ssl.c
+-regress_LDADD += ../libevent_openssl.la -lssl -lcrypto ${OPENSSL_LIBADD}
++regress_LDADD += ../libevent_openssl.la -lssl -lcrypto ${OPENSSL_LIBADD} $(ZLIB_LIBS)
+ endif
+ 
+ bench_SOURCES = bench.c
+-- 
+1.9.3
+
diff --git a/package/libevent/libevent.mk b/package/libevent/libevent.mk
index c50b1d2..d469bd2 100644
--- a/package/libevent/libevent.mk
+++ b/package/libevent/libevent.mk
@@ -11,6 +11,7 @@ LIBEVENT_INSTALL_STAGING = YES
 LIBEVENT_LICENSE = BSD-3c, OpenBSD
 LIBEVENT_LICENSE_FILES = LICENSE
 # For 0001-Disable-building-test-programs.patch
+# and 0002-Fix-openssl-check-for-static-build.patch
 LIBEVENT_AUTORECONF = YES
 
 define LIBEVENT_REMOVE_PYSCRIPT
-- 
1.9.3

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

* [Buildroot] [PATCH] package/libevent: fix static build
  2015-02-15 21:33 [Buildroot] [PATCH] package/libevent: fix static build Romain Naour
@ 2015-02-23 18:00 ` Thomas Petazzoni
  2015-02-23 18:11   ` Romain Naour
  0 siblings, 1 reply; 6+ messages in thread
From: Thomas Petazzoni @ 2015-02-23 18:00 UTC (permalink / raw)
  To: buildroot

Dear Romain Naour,

On Sun, 15 Feb 2015 22:33:00 +0100, Romain Naour wrote:
> For some reason, libevent silently fail to enable openssl support
> even when it's explicitly requested.
> 
> Somes flags are missing when checking for zlib and openssl.
> 
> Fixes:
> http://autobuild.buildroot.net/results/713/71362af474461e99b7c188a316aa644a0faaad2e
> 
> Signed-off-by: Romain Naour <romain.naour@openwide.fr>

Do you have a defconfig that exhibits the build failure? I've tried the
following minimal defconfig, and it builds fine here:

BR2_bfin=y
BR2_BINFMT_FLAT=y
BR2_COMPILER_PARANOID_UNSAFE_PATH=y
BR2_TOOLCHAIN_EXTERNAL=y
BR2_INIT_NONE=y
# BR2_PACKAGE_BUSYBOX is not set
BR2_PACKAGE_OPENSSL=y
BR2_PACKAGE_LIBEVENT=y
# BR2_TARGET_ROOTFS_TAR is not set

Thanks,

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

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

* [Buildroot] [PATCH] package/libevent: fix static build
  2015-02-23 18:00 ` Thomas Petazzoni
@ 2015-02-23 18:11   ` Romain Naour
  2015-02-23 19:07     ` Thomas Petazzoni
  0 siblings, 1 reply; 6+ messages in thread
From: Romain Naour @ 2015-02-23 18: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 at buildroot.org
| Envoy?: Lundi 23 F?vrier 2015 19:00:40
| Objet: Re: [Buildroot] [PATCH] package/libevent: fix static build
| 
| Dear Romain Naour,
| 
| On Sun, 15 Feb 2015 22:33:00 +0100, Romain Naour wrote:
| > For some reason, libevent silently fail to enable openssl support
| > even when it's explicitly requested.
| > 
| > Somes flags are missing when checking for zlib and openssl.
| > 
| > Fixes:
| > http://autobuild.buildroot.net/results/713/71362af474461e99b7c188a316aa644a0faaad2e
| > 
| > Signed-off-by: Romain Naour <romain.naour@openwide.fr>
| 
| Do you have a defconfig that exhibits the build failure? I've tried
| the
| following minimal defconfig, and it builds fine here:
| 

Can you try to build libwebsock with your config ?

Sorry, I meant libwebsock fix static build.

libevent break libwebsock's build because libevent_openssl.pc is not
installed.

Best regards,
Romain

| BR2_bfin=y
| BR2_BINFMT_FLAT=y
| BR2_COMPILER_PARANOID_UNSAFE_PATH=y
| BR2_TOOLCHAIN_EXTERNAL=y
| BR2_INIT_NONE=y
| # BR2_PACKAGE_BUSYBOX is not set
| BR2_PACKAGE_OPENSSL=y
| BR2_PACKAGE_LIBEVENT=y
| # BR2_TARGET_ROOTFS_TAR is not set
| 
| Thanks,
| 
| Thomas
| --
| Thomas Petazzoni, CTO, Free Electrons
| Embedded Linux, Kernel and Android engineering
| http://free-electrons.com
| 

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

* [Buildroot] [PATCH] package/libevent: fix static build
  2015-02-23 18:11   ` Romain Naour
@ 2015-02-23 19:07     ` Thomas Petazzoni
  2015-02-23 21:55       ` Romain Naour
  0 siblings, 1 reply; 6+ messages in thread
From: Thomas Petazzoni @ 2015-02-23 19:07 UTC (permalink / raw)
  To: buildroot

Dear Romain Naour,

On Mon, 23 Feb 2015 19:11:53 +0100 (CET), Romain Naour wrote:

> Can you try to build libwebsock with your config ?
> 
> Sorry, I meant libwebsock fix static build.
> 
> libevent break libwebsock's build because libevent_openssl.pc is not
> installed.

Ah, right, now I can reproduce the problem. Instead of trying to get
AC_SEARCH_LIB to work properly with static libraries, how about using
PKG_CHECK_MODULES() instead to rely on pkg-config? Something like:

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

* [Buildroot] [PATCH] package/libevent: fix static build
  2015-02-23 19:07     ` Thomas Petazzoni
@ 2015-02-23 21:55       ` Romain Naour
  2015-02-27 22:39         ` Romain Naour
  0 siblings, 1 reply; 6+ messages in thread
From: Romain Naour @ 2015-02-23 21:55 UTC (permalink / raw)
  To: buildroot

Hi Thomas,

Le 23/02/2015 20:07, Thomas Petazzoni a ?crit :
> Dear Romain Naour,
> 
> On Mon, 23 Feb 2015 19:11:53 +0100 (CET), Romain Naour wrote:
> 
>> Can you try to build libwebsock with your config ?
>>
>> Sorry, I meant libwebsock fix static build.
>>
>> libevent break libwebsock's build because libevent_openssl.pc is not
>> installed.
> 
> Ah, right, now I can reproduce the problem. Instead of trying to get
> AC_SEARCH_LIB to work properly with static libraries, how about using
> PKG_CHECK_MODULES() instead to rely on pkg-config? Something like:
> 
> From c603940f3d54189a3ef4a430580166cfdda468d0 Mon Sep 17 00:00:00 2001
> From: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
> Date: Mon, 23 Feb 2015 19:58:21 +0100
> Subject: [PATCH 2/2] Use pkg-config to discover openssl and zlib
> 
> Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>

It's much better, thanks.
I was not really happy with my patch, but at least it fixed the build.

Build tested from scratch with your patch and the same config.
Can you add my:
Tested-by: Romain Naour <romain.naour@openwide.fr>

Best regards,
Romain
> ---
>  configure.ac       | 25 ++-----------------------
>  sample/Makefile.am |  2 +-
>  test/Makefile.am   |  2 +-
>  3 files changed, 4 insertions(+), 25 deletions(-)
> 
> diff --git a/configure.ac b/configure.ac
> index d42edd8..da5bc49 100644
> --- a/configure.ac
> +++ b/configure.ac
> @@ -146,16 +146,7 @@ AC_CHECK_HEADERS([zlib.h])
>  if test "x$ac_cv_header_zlib_h" = "xyes"; then
>  dnl Determine if we have zlib for regression tests
>  dnl Don't put this one in LIBS
> -save_LIBS="$LIBS"
> -LIBS=""
> -ZLIB_LIBS=""
> -have_zlib=no
> -AC_SEARCH_LIBS([inflateEnd], [z],
> -	[have_zlib=yes
> -	ZLIB_LIBS="$LIBS"
> -	AC_DEFINE(HAVE_LIBZ, 1, [Define if the system has zlib])])
> -LIBS="$save_LIBS"
> -AC_SUBST(ZLIB_LIBS)
> +    PKG_CHECK_MODULES([ZLIB], [zlib], [have_zlib=yes])
>  fi
>  AM_CONDITIONAL(ZLIB_REGRESS, [test "$have_zlib" = "yes"])
>  
> @@ -169,23 +160,11 @@ else
>  fi
>  AC_SUBST(EV_LIB_WS32)
>  AC_SUBST(EV_LIB_GDI)
> -AC_SUBST(OPENSSL_LIBADD)
>  
>  AC_CHECK_HEADERS([openssl/bio.h])
>  
>  if test "$enable_openssl" = "yes"; then
> -save_LIBS="$LIBS"
> -LIBS=""
> -OPENSSL_LIBS=""
> -have_openssl=no
> -AC_SEARCH_LIBS([SSL_new], [ssl],
> -	[have_openssl=yes
> -	OPENSSL_LIBS="$LIBS -lcrypto $EV_LIB_GDI $EV_LIB_WS32 $OPENSSL_LIBADD"
> -	AC_DEFINE(HAVE_OPENSSL, 1, [Define if the system has openssl])],
> -	[have_openssl=no],
> -	[-lcrypto $EV_LIB_GDI $EV_LIB_WS32 $OPENSSL_LIBADD])
> -LIBS="$save_LIBS"
> -AC_SUBST(OPENSSL_LIBS)
> +   PKG_CHECK_MODULES([OPENSSL], [openssl], [have_openssl=yes], [have_openssl=no])
>  fi
>  
>  dnl Checks for header files.
> diff --git a/sample/Makefile.am b/sample/Makefile.am
> index c926f4e..a986b18 100644
> --- a/sample/Makefile.am
> +++ b/sample/Makefile.am
> @@ -21,7 +21,7 @@ http_server_SOURCES = http-server.c
>  if OPENSSL
>  noinst_PROGRAMS += le-proxy
>  le_proxy_SOURCES = le-proxy.c
> -le_proxy_LDADD = $(LDADD) ../libevent_openssl.la -lssl -lcrypto ${OPENSSL_LIBADD}
> +le_proxy_LDADD = $(LDADD) ../libevent_openssl.la -lssl -lcrypto $(OPENSSL_LIBS)
>  endif
>  
>  verify:
> diff --git a/test/Makefile.am b/test/Makefile.am
> index 0253a49..4ab6ae5 100644
> --- a/test/Makefile.am
> +++ b/test/Makefile.am
> @@ -72,7 +72,7 @@ regress_LDFLAGS = $(PTHREAD_CFLAGS)
>  
>  if OPENSSL
>  regress_SOURCES += regress_ssl.c
> -regress_LDADD += ../libevent_openssl.la -lssl -lcrypto ${OPENSSL_LIBADD}
> +regress_LDADD += ../libevent_openssl.la -lssl -lcrypto $(OPENSSL_LIBS)
>  endif
>  
>  bench_SOURCES = bench.c
> 

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

* [Buildroot] [PATCH] package/libevent: fix static build
  2015-02-23 21:55       ` Romain Naour
@ 2015-02-27 22:39         ` Romain Naour
  0 siblings, 0 replies; 6+ messages in thread
From: Romain Naour @ 2015-02-27 22:39 UTC (permalink / raw)
  To: buildroot

Hi Thomas,

[...]
>>
>> From c603940f3d54189a3ef4a430580166cfdda468d0 Mon Sep 17 00:00:00 2001
>> From: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
>> Date: Mon, 23 Feb 2015 19:58:21 +0100
>> Subject: [PATCH 2/2] Use pkg-config to discover openssl and zlib
>>
>> Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
> 
[...]
>> ---
>>  configure.ac       | 25 ++-----------------------
>>  sample/Makefile.am |  2 +-
>>  test/Makefile.am   |  2 +-
>>  3 files changed, 4 insertions(+), 25 deletions(-)
>>
>> diff --git a/configure.ac b/configure.ac
>> index d42edd8..da5bc49 100644
>> --- a/configure.ac
>> +++ b/configure.ac
>> @@ -146,16 +146,7 @@ AC_CHECK_HEADERS([zlib.h])
>>  if test "x$ac_cv_header_zlib_h" = "xyes"; then
>>  dnl Determine if we have zlib for regression tests
>>  dnl Don't put this one in LIBS
>> -save_LIBS="$LIBS"
>> -LIBS=""
>> -ZLIB_LIBS=""
>> -have_zlib=no
>> -AC_SEARCH_LIBS([inflateEnd], [z],
>> -	[have_zlib=yes
>> -	ZLIB_LIBS="$LIBS"
>> -	AC_DEFINE(HAVE_LIBZ, 1, [Define if the system has zlib])])
>> -LIBS="$save_LIBS"
>> -AC_SUBST(ZLIB_LIBS)
>> +    PKG_CHECK_MODULES([ZLIB], [zlib], [have_zlib=yes])
>>  fi
>>  AM_CONDITIONAL(ZLIB_REGRESS, [test "$have_zlib" = "yes"])

The first part of your patch can be upstreamed easily.

>>  
>> @@ -169,23 +160,11 @@ else
>>  fi
>>  AC_SUBST(EV_LIB_WS32)
>>  AC_SUBST(EV_LIB_GDI)
>> -AC_SUBST(OPENSSL_LIBADD)
>>  
>>  AC_CHECK_HEADERS([openssl/bio.h])
>>  
>>  if test "$enable_openssl" = "yes"; then
>> -save_LIBS="$LIBS"
>> -LIBS=""
>> -OPENSSL_LIBS=""
>> -have_openssl=no
>> -AC_SEARCH_LIBS([SSL_new], [ssl],
>> -	[have_openssl=yes
>> -	OPENSSL_LIBS="$LIBS -lcrypto $EV_LIB_GDI $EV_LIB_WS32 $OPENSSL_LIBADD"
>> -	AC_DEFINE(HAVE_OPENSSL, 1, [Define if the system has openssl])],
>> -	[have_openssl=no],
>> -	[-lcrypto $EV_LIB_GDI $EV_LIB_WS32 $OPENSSL_LIBADD])
>> -LIBS="$save_LIBS"
>> -AC_SUBST(OPENSSL_LIBS)
>> +   PKG_CHECK_MODULES([OPENSSL], [openssl], [have_openssl=yes], [have_openssl=no])
>>  fi
>>  

The second part doesn't apply since the following patch has been merged:

"Provide the autoconf m4 macros for the new OpenSSL via pkg-config stuff"
https://github.com/libevent/libevent/commit/674dc3d34ed0e46890f9db35402841527f2432f3

"Use pkg-config (if available) to handle OpenSSL"
https://github.com/libevent/libevent/commit/1c63860758f5ddb0bd00e9d3c841d488779be1bd

It seems that upstream want to make pkg-config optional and fall back to legacy way if
it's not found.
So, the PKG_CHECK_MODULES for zlib needs to be reworked to check if pkg-config is
available...

I'm not convinced about with/without pkg-config handling, the legacy way is still
broken for some corner case.
But from Buildroot point of view, it doesn't matter since pkg-config is always
available.

For the last part of the patch, sample/Makefile.am and test/Makefile.am has been
removed/renamed upstream.

What do you suggest ?

Best regards,
Romain

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

end of thread, other threads:[~2015-02-27 22:39 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-02-15 21:33 [Buildroot] [PATCH] package/libevent: fix static build Romain Naour
2015-02-23 18:00 ` Thomas Petazzoni
2015-02-23 18:11   ` Romain Naour
2015-02-23 19:07     ` Thomas Petazzoni
2015-02-23 21:55       ` Romain Naour
2015-02-27 22:39         ` Romain Naour

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.