I'm using bazel to build a shared libary, but the output so file size is much bigger than expected; For comparision I also build a binary with same deps and srcs in BUILD file, the binary ouput size is much smaller; Code sample:
cc_binary(
name = "server",
srcs = ["server.cc"],
deps = [...]
) # the binary
cc_binary(
name = "libs.so",
srcs = ["server.cc"],
deps = [...],
linkshared = 1
) # the shared library
libs.so
is about 5 times larger than server
; It seems linkshared option packs all symbols in deps
to the shared library, including unused functions, variables(nm
shows libs.so
contains much more symbols than server
); How can I just link needed symbols to my shared library?