Reputation: 53
This is with bazel 2.2.0
running in a ubuntu 16.04
. I've implemented a macro to "build" a C++ library and produce .a
and .so
files.
def add_cc_lib(lib, SRCS, HDRS, lib_defines, lib_includes, lib_copts, lib_linkopts, archive_libs_deps, additional_deps):
# Define target to create .a for this library
native.cc_library(
name = lib,
srcs = SRCS,
hdrs = HDRS,
deps = archive_libs_deps + additional_deps,
defines = lib_defines,
includes = lib_includes,
copts = lib_copts,
linkopts = lib_linkopts,
linkstatic = 1,
visibility = ["//visibility:public"]
)
# Define target to also create .so for this library
native.cc_binary(
name = "lib" + lib + ".so",
srcs = [":" + lib] + archive_libs_deps,
deps = additional_deps,
defines = lib_defines,
includes = lib_includes,
copts = lib_copts,
linkopts = lib_linkopts,
linkshared = 1,
linkstatic = 1,
visibility = ["//visibility:public"],
)
where archive_libs_deps
and additional_deps
are list of targets supplied when this add_cc_lib()
macro is used to add a C++ library in my repo.
Issue is that, although this produces libfoo.so
, it doesn't have any of the symbols from foo.a
:
# nm bazel-bin/<path>/libfoo.so
0000000000002008 A __bss_start
0000000000002008 b completed.7594
w __cxa_finalize
0000000000000630 t deregister_tm_clones
00000000000006c0 t __do_global_dtors_aux
0000000000001d40 t __do_global_dtors_aux_fini_array_entry
0000000000002000 d __dso_handle
0000000000001d50 d _DYNAMIC
0000000000002008 A _edata
0000000000002009 A _end
0000000000000730 T _fini
0000000000000700 t frame_dummy
0000000000001d48 t __frame_dummy_init_array_entry
0000000000000780 r __FRAME_END__
0000000000001fd8 d _GLOBAL_OFFSET_TABLE_
w __gmon_start__
00000000000005e0 T _init
w _ITM_deregisterTMCloneTable
w _ITM_registerTMCloneTable
0000000000001d38 d __JCR_END__
0000000000001d38 d __JCR_LIST__
w _Jv_RegisterClasses
0000000000000670 t register_tm_clones
0000000000002008 d __TMC_END__
0000000000002008 d __TMC_LIST__
I've done quite a bit of searching on the internet and tried out few things without success. Am I missing here something? Any help is much appreciated.
Upvotes: 1
Views: 2106