Buildroot Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [Buildroot] [PATCH] package/sconeserver: fix static link with openssl
@ 2015-05-30 14:19 Yann E. MORIN
  2015-05-31  8:38 ` Thomas Petazzoni
  0 siblings, 1 reply; 3+ messages in thread
From: Yann E. MORIN @ 2015-05-30 14:19 UTC (permalink / raw)
  To: buildroot

When linking statically, the order of libraries on the linker command
line is important, and sconeserver got it wrong.

Also, isconeserver does not use pkg-config, so it misses the private
libs of -lcrypto, which is linking with -lz.

Fix that:
  - add a patch to configure.in to fix the order of libraries;
  - forcibly pass -lz when lkinking statically with openssl.

Note: we were already reconfiguring sconeserver, because it comes from
the github repository.

Fixes:
    http://autobuild.buildroot.org/results/403/403eac974ecdaacdb66b8241fbdcf19ec5e07480

Signed-off-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
---
 .../sconeserver/0001-fix-ssl-libs-ordering.patch   | 36 ++++++++++++++++++++++
 package/sconeserver/sconeserver.mk                 |  3 ++
 2 files changed, 39 insertions(+)
 create mode 100644 package/sconeserver/0001-fix-ssl-libs-ordering.patch

diff --git a/package/sconeserver/0001-fix-ssl-libs-ordering.patch b/package/sconeserver/0001-fix-ssl-libs-ordering.patch
new file mode 100644
index 0000000..f1f25b9
--- /dev/null
+++ b/package/sconeserver/0001-fix-ssl-libs-ordering.patch
@@ -0,0 +1,36 @@
+configure: re-order SSL libs when linking
+
+When doing static builds, the ordering of libs is important, as the
+linker does not back-pedal to previous libraries specified on the
+command line to find missing symbols, and only searches for those
+missing symbols in the following libs.
+
+Thus, as -lssl needs symbols from -lcrypto, it needs to come before
+-lcrypto.
+
+And globally, we do *not* append new libraries, we prepend them.
+
+Signed-off-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
+
+diff -durN a/configure.in b/configure.in
+--- a/configure.in	2014-10-16 11:12:08.000000000 +0200
++++ b/configure.in	2015-05-30 15:44:25.540329788 +0200
+@@ -133,12 +133,14 @@
+     [AC_MSG_ERROR([header file <openssl/ssl.h> is required for OpenSSL, use --with-openssl-path=PATH])]
+   )
+   AC_CHECK_LIB([crypto],[CRYPTO_new_ex_data],
+-    [SSL_LIBADD="$SSL_LIBADD -lcrypto"],
+-    [AC_MSG_ERROR([library 'crypto' is required for OpenSSL])]
++    [SSL_LIBADD="-lcrypto $SSL_LIBADD"],
++    [AC_MSG_ERROR([library 'crypto' is required for OpenSSL])],
++    [$SSL_LIBADD]
+   )
+   AC_CHECK_LIB([ssl],[SSL_library_init],
+-    [SSL_LIBADD="$SSL_LIBADD -lssl"],
+-    [AC_MSG_ERROR([library 'ssl' is required for OpenSSL])]
++    [SSL_LIBADD="-lssl $SSL_LIBADD"],
++    [AC_MSG_ERROR([library 'ssl' is required for OpenSSL])],
++    [$SSL_LIBADD]
+   )
+   AC_SUBST(SSL_LIBADD)
+ fi
diff --git a/package/sconeserver/sconeserver.mk b/package/sconeserver/sconeserver.mk
index 3ff891b..beca926 100644
--- a/package/sconeserver/sconeserver.mk
+++ b/package/sconeserver/sconeserver.mk
@@ -24,6 +24,9 @@ endif
 ifeq ($(BR2_PACKAGE_OPENSSL),y)
 SCONESERVER_DEPENDENCIES += openssl
 SCONESERVER_CONF_OPTS += --with-ssl
+ifeq ($(BR2_STATIC_LIBS),y)
+SCONESERVER_CONF_ENV += SSL_LIBADD=-lz
+endif
 else
 SCONESERVER_CONF_OPTS += --without-ssl
 endif
-- 
1.9.1

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

* [Buildroot] [PATCH] package/sconeserver: fix static link with openssl
  2015-05-30 14:19 [Buildroot] [PATCH] package/sconeserver: fix static link with openssl Yann E. MORIN
@ 2015-05-31  8:38 ` Thomas Petazzoni
  2015-05-31  8:55   ` Yann E. MORIN
  0 siblings, 1 reply; 3+ messages in thread
From: Thomas Petazzoni @ 2015-05-31  8:38 UTC (permalink / raw)
  To: buildroot

Dear Yann E. MORIN,

On Sat, 30 May 2015 16:19:11 +0200, Yann E. MORIN wrote:
> When linking statically, the order of libraries on the linker command
> line is important, and sconeserver got it wrong.
> 
> Also, isconeserver does not use pkg-config, so it misses the private

        ^^ typo

> libs of -lcrypto, which is linking with -lz.
> 
> Fix that:
>   - add a patch to configure.in to fix the order of libraries;
>   - forcibly pass -lz when lkinking statically with openssl.

                             ^^^ typo

Applied with those two typos fixed. It's really a pity that pkg-config
isn't more widely used :-/ If openssl grows another dependency, we
would have to fix this again...

Best regards,

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

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

* [Buildroot] [PATCH] package/sconeserver: fix static link with openssl
  2015-05-31  8:38 ` Thomas Petazzoni
@ 2015-05-31  8:55   ` Yann E. MORIN
  0 siblings, 0 replies; 3+ messages in thread
From: Yann E. MORIN @ 2015-05-31  8:55 UTC (permalink / raw)
  To: buildroot

Thomas, All,

On 2015-05-31 10:38 +0200, Thomas Petazzoni spake thusly:
> On Sat, 30 May 2015 16:19:11 +0200, Yann E. MORIN wrote:
> > When linking statically, the order of libraries on the linker command
> > line is important, and sconeserver got it wrong.
> > 
> > Also, isconeserver does not use pkg-config, so it misses the private
> 
>         ^^ typo
> 
> > libs of -lcrypto, which is linking with -lz.
> > 
> > Fix that:
> >   - add a patch to configure.in to fix the order of libraries;
> >   - forcibly pass -lz when lkinking statically with openssl.
> 
>                              ^^^ typo
> 
> Applied with those two typos fixed. 

Thanks! :-)

>It's really a pity that pkg-config
> isn't more widely used :-/ If openssl grows another dependency, we
> would have to fix this again...

For 2015.05, I only 'fixed' sconeserver with the patch you applied, but
for upstream, I submitted a more involved patch that makes use of
pkg-config, which upstream seems to be happy with so far (but have not
yet merged):
    https://github.com/sconemad/sconeserver/pull/1

Regards,
Yann E. MORIN.

-- 
.-----------------.--------------------.------------------.--------------------.
|  Yann E. MORIN  | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software  Designer | \ / CAMPAIGN     |  ___               |
| +33 223 225 172 `------------.-------:  X  AGAINST      |  \e/  There is no  |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL    |   v   conspiracy.  |
'------------------------------^-------^------------------^--------------------'

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

end of thread, other threads:[~2015-05-31  8:55 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-05-30 14:19 [Buildroot] [PATCH] package/sconeserver: fix static link with openssl Yann E. MORIN
2015-05-31  8:38 ` Thomas Petazzoni
2015-05-31  8:55   ` Yann E. MORIN

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