nicolov
nicolov

Reputation: 131

How to avoid building C++ static libraries in Bazel

I've tried various combinations of --dynamic_mode=fully in the command line and linkstatic = 0 in cc_library and cc_binary rules, but haven't managed to avoid building static libraries (.a) when building Bazel projects. While binaries are indeed linked dynamically, the .a files are built nonetheless, taking up a lot of time and space (on the shared cache).

Am I missing something?

Upvotes: 1

Views: 1183

Answers (1)

nicolov
nicolov

Reputation: 131

Answering my own question: it seems that the problem was the wildcard build //.... It triggers linking both the static and the dynamic library of each cc_library rule. If you add tags = ["manual"] to the libraries, and build with --dynamic_mode=fully, static .a libraries won't build automatically anymore, but .so will still be created as depended on by cc_binary targets.

Upvotes: 3

Related Questions