sfackler / rust-openssl

OpenSSL bindings for Rust
1.37k stars 739 forks source link

If openssl is built with zlib, it will fail to link statically #590

Closed farcaller closed 7 years ago

farcaller commented 7 years ago

Given openssl that is configured as:

CC=musl-gcc ./Configure linux-x86_64 --openssldir=/etc/ssl --prefix=/usr/local/musl no-shared zlib no-zlib-dynamic enable-montasm enable-md2 enable-ec_nistp_64_gcc_128

it's not possible to link to it with OPENSSL_STATIC=1 (or otherwise, really), as it requires symbols from libz:

  = note: /src/colorbot/target/x86_64-unknown-linux-musl/release/deps/libopenssl_sys-88869ce7700cbe4c.rlib(c_zlib.o): In function `zlib_stateful_expand_block':
c_zlib.c:(.text+0x59): undefined reference to `inflate'
/src/colorbot/target/x86_64-unknown-linux-musl/release/deps/libopenssl_sys-88869ce7700cbe4c.rlib(c_zlib.o): In function `zlib_stateful_compress_block':
c_zlib.c:(.text+0xea): undefined reference to `deflate'
/src/colorbot/target/x86_64-unknown-linux-musl/release/deps/libopenssl_sys-88869ce7700cbe4c.rlib(c_zlib.o): In function `bio_zlib_free':
c_zlib.c:(.text+0x13e): undefined reference to `inflateEnd'
c_zlib.c:(.text+0x15d): undefined reference to `deflateEnd'
/src/colorbot/target/x86_64-unknown-linux-musl/release/deps/libopenssl_sys-88869ce7700cbe4c.rlib(c_zlib.o): In function `zlib_stateful_finish':
c_zlib.c:(.text+0x1d0): undefined reference to `inflateEnd'
c_zlib.c:(.text+0x1d9): undefined reference to `deflateEnd'
/src/colorbot/target/x86_64-unknown-linux-musl/release/deps/libopenssl_sys-88869ce7700cbe4c.rlib(c_zlib.o): In function `zlib_stateful_init':
c_zlib.c:(.text+0x268): undefined reference to `inflateInit_'
c_zlib.c:(.text+0x2d9): undefined reference to `deflateInit_'
/src/colorbot/target/x86_64-unknown-linux-musl/release/deps/libopenssl_sys-88869ce7700cbe4c.rlib(c_zlib.o): In function `bio_zlib_ctrl':
c_zlib.c:(.text+0x54c): undefined reference to `deflate'
c_zlib.c:(.text+0x5f8): undefined reference to `zError'
/src/colorbot/target/x86_64-unknown-linux-musl/release/deps/libopenssl_sys-88869ce7700cbe4c.rlib(c_zlib.o): In function `bio_zlib_write':
c_zlib.c:(.text+0x819): undefined reference to `deflate'
c_zlib.c:(.text+0x8da): undefined reference to `zError'
c_zlib.c:(.text+0x93d): undefined reference to `deflateInit_'
/src/colorbot/target/x86_64-unknown-linux-musl/release/deps/libopenssl_sys-88869ce7700cbe4c.rlib(c_zlib.o): In function `bio_zlib_read':
c_zlib.c:(.text+0xa0f): undefined reference to `inflate'
c_zlib.c:(.text+0xa7a): undefined reference to `zError'
c_zlib.c:(.text+0xaed): undefined reference to `inflateInit_'
collect2: error: ld returned 1 exit status

I guess another env flag is needed to link to libz.

sfackler commented 7 years ago

I believe zlib is only used for TLS compression which you should not be using. That can be turned off by passing no-comp to Configure.