Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

When not using the builtin zlib, link it before linking libcrypto, as libcrypto depends on zlib. #581

Merged

Conversation

Romain-Geissler-1A
Copy link
Contributor

This prevents "undefined symbol" errors which might arise from libcrypto.a if linking openssl statically.

This happens to me as:

  • I build my own zlib, which is a recent one (1.31)
  • build my own OpenSSL against the above zlib
  • everything is link statically
  • I configure rsync with --with-included-zlib=no.

With this configuration, rsync fails to link with errors like:

gcc -std=gnu11 -I/workdir/src/rsync-3.2.7/popt -O2 -mmmx -msse -msse2 -msse3 -I/opt/1A/toolchain/x86_64-2.6.32-v2.0.102/build-pack/2.0.102.0/include -I/workdir/build/x86_64/build-pack/build-pack-temporary-static-dependencies/install/include -I/workdir/build/x86_64/build-pack/build-pack-temporary-static-dependencies/install/include/ncurses -I/opt/1A/toolchain/x86_64-2.6.32-v2.0.102/build-pack/2.0.102.0/internal-python-only-for-build-pack/include -Wno-error -pthread -DHAVE_CONFIG_H -Wall -W -Wno-unused-parameter -O2 -mmmx -msse -msse2 -msse3 -I/opt/1A/toolchain/x86_64-2.6.32-v2.0.102/build-pack/2.0.102.0/include -I/workdir/build/x86_64/build-pack/build-pack-temporary-static-dependencies/install/include -I/workdir/build/x86_64/build-pack/build-pack-temporary-static-dependencies/install/include/ncurses -I/opt/1A/toolchain/x86_64-2.6.32-v2.0.102/build-pack/2.0.102.0/internal-python-only-for-build-pack/include -L/opt/1A/toolchain/x86_64-2.6.32-v2.0.102/build-pack/2.0.102.0/lib -L/workdir/build/x86_64/build-pack/build-pack-temporary-static-dependencies/install/lib -L/workdir/build/x86_64/build-pack/build-pack-temporary-static-dependencies/install/lib64 -L/opt/1A/toolchain/x86_64-2.6.32-v2.0.102/build-pack/2.0.102.0/internal-python-only-for-build-pack/lib -Wno-error -Wl,--dynamic-linker=/opt/1A/toolchain/x86_64-2.6.32-v2.0.102/lib64/ld-linux-x86-64.so.2 -pthread -o rsync flist.o rsync.o generator.o receiver.o cleanup.o sender.o exclude.o util1.o util2.o main.o checksum.o match.o syscall.o log.o backup.o delete.o options.o io.o compat.o hlink.o token.o uidlist.o socket.o hashtable.o usage.o fileio.o batch.o clientname.o chmod.o acls.o xattrs.o progress.o pipe.o  simd-checksum-x86_64.o  params.o loadparm.o clientserver.o access.o connection.o authenticate.o lib/wildmatch.o lib/compat.o lib/snprintf.o lib/mdfour.o lib/md5.o lib/permstring.o lib/pool_alloc.o lib/sysacls.o lib/sysxattrs.o   popt/findme.o  popt/popt.o  popt/poptconfig.o popt/popthelp.o popt/poptparse.o -lz -lzstd -lcrypto 
/opt/1A/toolchain/x86_64-2.6.32-v2.0.102/lib/gcc/x86_64-1a-linux-gnu/4.9.4/../../../../x86_64-1a-linux-gnu/bin/ld: /workdir/build/x86_64/build-pack/build-pack-temporary-static-dependencies/install/lib64/libcrypto.a(libcrypto-lib-c_zlib.o): in function `zlib_oneshot_expand_block': 
c_zlib.c:(.text+0xc4b): undefined reference to `uncompress' 
/opt/1A/toolchain/x86_64-2.6.32-v2.0.102/lib/gcc/x86_64-1a-linux-gnu/4.9.4/../../../../x86_64-1a-linux-gnu/bin/ld: /workdir/build/x86_64/build-pack/build-pack-temporary-static-dependencies/install/lib64/libcrypto.a(libcrypto-lib-c_zlib.o): in function `zlib_oneshot_compress_block': 
2 
c_zlib.c:(.text+0xcab): undefined reference to `compress' 
collect2: error: ld returned 1 exit status 
make: *** [Makefile:106: rsync] Error 1

To fix fix, make sure we link zlib before we link libcrypto (as zlib may be dependency of libcrypto). This only moves code, without changing anything else.

@tridge
Copy link
Member

tridge commented Apr 6, 2024

@WayneD seems sensible to me, ok to merge?

@tridge tridge force-pushed the link-zlib-before-crypto branch 2 times, most recently from 2a2116e to 10bbdfd Compare April 8, 2024 08:22
@Romain-Geissler-1A
Copy link
Contributor Author

Hi,

I see you have recently cut a release. Would it be possible to consider this small pull request so that we have it included in the next release ? Thanks !

… libcrypto depends on zlib.

This prevents "undefined symbol" errors which might arise from libcrypto.a if linking openssl statically.
@WayneD WayneD merged commit 6f10f12 into RsyncProject:master Nov 20, 2024
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants