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

Avoid linking binary with unused libraries #1495

Open
d-uspenskiy opened this issue Jun 6, 2019 · 0 comments
Open

Avoid linking binary with unused libraries #1495

d-uspenskiy opened this issue Jun 6, 2019 · 0 comments
Assignees
Labels
area/docdb YugabyteDB core features kind/enhancement This is an enhancement of an existing feature priority/medium Medium priority issue

Comments

@d-uspenskiy
Copy link
Contributor

d-uspenskiy commented Jun 6, 2019

Jira Link: DB-1441
there are lots of dependencies for each binary in CMakeFile. Here is a list of dependencies for yb-tserver

../../../lib/libyb-cql.so ../../../lib/libyb-redis.so ../../../lib/libmaster.so ../../../../../thirdparty/installed/common/lib/libunwind.so ../../../lib/libql_api.so ../../../lib/libql_sem.so ../../../lib/libql_exec.so ../../../lib/libql_parser.so ../../../lib/libql_ptree.so ../../../lib/libql_util.so ../../../lib/libcql_service_proto.so ../../../../../thirdparty/installed/common/lib/liblz4.a ../../../lib/libredis_service_proto.so ../../../lib/libtserver.so ../../../lib/libtablet.so ../../../lib/libconsensus.so ../../../lib/liblog.so ../../../lib/liblog_proto.so ../../../lib/libyb_docdb.so ../../../lib/libyb_pggate_util.so ../../../lib/libyb_client.so ../../../lib/libtserver_service_proto.so ../../../lib/libremote_bootstrap_proto.so ../../../lib/libconsensus_proto.so ../../../lib/libbackup_proto.so ../../../lib/libtserver_admin_proto.so ../../../lib/libmaster_rpc.so ../../../lib/libserver_process.so ../../../../../thirdparty/installed/uninstrumented/lib/libprofiler.so ../../../lib/libserver_base_proto.so ../../../../../thirdparty/installed/common/lib/libsqueasel.a ../../../lib/libtserver_util.so ../../../lib/libyb_docdb_encoding.so ../../../lib/libserver_common.so ../../../lib/libyb_fs.so ../../../lib/libyb_rocksutil.so ../../../lib/librocksdb.so ../../../../../thirdparty/installed/uninstrumented/lib/libsnappy.so -lbz2 -lz ../../../lib/libmaster_util.so ../../../lib/libmaster_backup_proto.so ../../../lib/libmaster_proto.so ../../../lib/libyb_pgwrapper.so ../../../lib/libyb_pggate_flags.so ../../../lib/libtserver_proto.so ../../../lib/libdocdb_proto.so ../../../lib/libyrpc.so ../../../lib/librpc_introspection_proto.so ../../../../../thirdparty/installed/common/lib/libev.so /home/duspensky/.linuxbrew-yb-build/linuxbrew-20181203T161736/lib/libssl.so ../../../lib/libtablet_proto.so ../../../lib/libyb_common.so ../../../lib/libredis_protocol_proto.so ../../../lib/libpgsql_protocol_proto.so ../../../lib/libql_protocol_proto.so ../../../lib/libyb_bfql.so ../../../lib/libyb_bfpg.so ../../../lib/libyb_util.so ../../../../../thirdparty/installed/uninstrumented/lib/libtcmalloc.so ../../../../../thirdparty/installed/uninstrumented/lib/libboost_system.so ../../../../../thirdparty/installed/uninstrumented/lib/libboost_thread.so ../../../lib/libgutil.so ../../../../../thirdparty/installed/uninstrumented/lib/libglog.so ../../../../../thirdparty/installed/uninstrumented/lib/libgflags.so /home/duspensky/.linuxbrew-yb-build/linuxbrew-20181203T161736/lib/libcrypto.so ../../../../../thirdparty/installed/uninstrumented/lib/libcds.so /home/duspensky/.linuxbrew-yb-build/linuxbrew-20181203T161736/lib/libicui18n.so /home/duspensky/.linuxbrew-yb-build/linuxbrew-20181203T161736/lib/libicuuc.so ../../../../../thirdparty/installed/uninstrumented/lib/libcrcutil.so ../../../../../thirdparty/installed/uninstrumented/lib/libcrypt_blowfish.a ../../../lib/libhistogram_proto.so ../../../lib/libpb_util_proto.so ../../../lib/libencryption_proto.so ../../../../../thirdparty/installed/common/lib/libz.so /home/duspensky/.linuxbrew-yb-build/linuxbrew-20181203T161736/lib/libcrypto.so /home/duspensky/.linuxbrew-yb-build/linuxbrew-20181203T161736/lib/librt.so ../../../../../thirdparty/installed/uninstrumented/lib/libbacktrace.so ../../../../../thirdparty/installed/common/lib/libcurl.so -ldl -luuid ../../../lib/libopid_proto.so ../../../lib/libwire_protocol_proto.so ../../../lib/libconsensus_metadata_proto.so ../../../lib/libyb_common_proto.so ../../../lib/libfs_proto.so ../../../lib/librpc_header_proto.so ../../../lib/libversion_info_proto.so ../../../../../thirdparty/installed/uninstrumented/lib/libprotobuf.so

without --as-needed flag all of these shared library will be linked to binary even in case they are not used.
This can be checked by

[duspensky@centos bin]$ ldd -u -r yb-tserver 
Unused direct dependencies:
    /home/duspensky/.linuxbrew-yb-build/linuxbrew-20181203T161736-xxxxxxxxxxxxxxxxxxxxxxx/lib/libatomic.so.1
    /home/duspensky/code/yugabyte/build/debug-gcc-dynamic-enterprise/bin/./../../../thirdparty/installed/common/lib/libunwind.so.8
    /home/duspensky/code/yugabyte/build/debug-gcc-dynamic-enterprise/bin/./../lib/libql_api.so
    /home/duspensky/code/yugabyte/build/debug-gcc-dynamic-enterprise/bin/./../lib/libql_sem.so
    /home/duspensky/code/yugabyte/build/debug-gcc-dynamic-enterprise/bin/./../lib/libql_exec.so
    /home/duspensky/code/yugabyte/build/debug-gcc-dynamic-enterprise/bin/./../lib/libql_parser.so
    /home/duspensky/code/yugabyte/build/debug-gcc-dynamic-enterprise/bin/./../lib/libql_ptree.so
    /home/duspensky/code/yugabyte/build/debug-gcc-dynamic-enterprise/bin/./../lib/libql_util.so
    /home/duspensky/code/yugabyte/build/debug-gcc-dynamic-enterprise/bin/./../lib/libcql_service_proto.so
...
    /home/duspensky/code/yugabyte/build/debug-gcc-dynamic-enterprise/bin/./../lib/libyb_pggate_flags.so
...

but in case '--as-needed' is specified resulting binary will not contain unused dependencies (this will speedup loading process)

@d-uspenskiy d-uspenskiy added kind/enhancement This is an enhancement of an existing feature area/docdb YugabyteDB core features labels Jun 6, 2019
@omkar-yb omkar-yb added this to Backlog in YBase features Jan 21, 2022
mbautin added a commit that referenced this issue May 6, 2022
Summary: Do not link yb_util with libatomic. Third-party libraries could still be linked with libatomic but we will address that separately.

Test Plan: Jenkins: compile only

Reviewers: timur

Reviewed By: timur

Subscribers: ybase

Differential Revision: https://phabricator.dev.yugabyte.com/D16824
@yugabyte-ci yugabyte-ci added the priority/medium Medium priority issue label Jun 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/docdb YugabyteDB core features kind/enhancement This is an enhancement of an existing feature priority/medium Medium priority issue
Projects
YBase features
  
Backlog
Development

No branches or pull requests

3 participants