bazel icon indicating copy to clipboard operation
bazel copied to clipboard

Add experimental `cc_static_library` rule

Open fmeum opened this issue 3 years ago • 10 comments

RELNOTES: The new cc_static_library rule produces a static library that bundles given targets and all their transitive dependencies. It has to be enabled via --experimental_cc_static_library.

Implements https://docs.google.com/document/d/1jN0LUmp6_-rV9_f-Chx-Cs6t_5iOm3fziOklzBGjGIg/edit

Fixes #1920

fmeum avatar Dec 07 '22 21:12 fmeum

@fmeum I made a pull request for your fork. Could you merge https://github.com/fmeum/bazel/pull/1 to this branch so that it is updated? It is behind 2114 commits.

https://github.com/bazelbuild/bazel/issues/1920

aminya avatar Nov 06 '23 11:11 aminya

@fmeum Any update on my comments?

https://github.com/bazelbuild/bazel/pull/16954#issuecomment-1794574206

aminya avatar Jan 03 '24 21:01 aminya

@aminya and @fmeum any updates on the status / timeline for this? We (as in, my company) are considering moving off Bazel partially or completely and lack of transitive static libraries is one of the major factors in making such decisions. We need to understand our timeline and resource allocation should be and that hinges on this MR + issue thread.

Algomorph avatar Mar 07 '24 19:03 Algomorph

Sorry for the lack of response, other efforts kept needing priority over the one. I'm planning to get back to it in April.

@Algomorph If you really just want to build transitive static libraries, then you could really use any of the Starlark rules proposed on the original issue without being blocked on me. Do you have any special requirements that only my design would address?

fmeum avatar Mar 08 '24 08:03 fmeum

@fmeum thanks for getting back to me so promptly and sharing the plan. April will probably work for us. I got the general sense from reading through the thread that people are running into issues with the proposed rules, but granted, I haven't personally tried any of them yet. We will review further at our next planning session and reevaluate, perhaps even assist -- if we can allocate the resources for it.

Algomorph avatar Mar 08 '24 14:03 Algomorph

We (as in, my company) are considering moving off Bazel partially or completely and lack of transitive static libraries

Unfortunately, one of my dependencies uses Bazel, and I am stuck in the walled garden of Bazel without a way out. Having static libraries is the only way that allows us to build the dependency in isolation and use it in other projects without the fragile and bulky alternative of whole archive shared libraries. https://github.com/RobotLocomotion/drake/issues/16882

Do you have any special requirements that only my design would address?

I tried all the proposed rules, and only this PR seems to partially work for me except for the errors I mentioned here https://github.com/bazelbuild/bazel/pull/16954#discussion_r1383347818

I'm planning to get back to it in April.

@fmeum Could you at least update the branch via https://github.com/fmeum/bazel/pull/1?

aminya avatar Mar 08 '24 19:03 aminya

Could you at least update the branch via https://github.com/fmeum/bazel/pull/1?

@aminya Sorry, I didn't want to merge it directly due to its size and then forgot about it. I just rebased the current PR, please let me know if anything broke due to that.

fmeum avatar Mar 08 '24 19:03 fmeum

what versions of bazel will this be available on?

joelberkeley avatar Mar 30 '24 14:03 joelberkeley

What is the current status of this MR / any blockers holding up the review from @comius? Is there anything I can do to help speed up the process?

Algomorph avatar Apr 24 '24 19:04 Algomorph

cc @pzembrod

meisterT avatar Jun 13 '24 19:06 meisterT

@bazel-io fork 7.3.0

fmeum avatar Jul 29 '24 10:07 fmeum

@fmeum Please add docstring in src/main/starlark/tests/builtins_bzl/cc/cc_static_library/test_cc_static_library/mock_toolchain.bzl for mock_cc_toolchain

iancha1992 avatar Jul 30 '24 04:07 iancha1992

@fmeum Please add docstring in src/main/starlark/tests/builtins_bzl/cc/cc_static_library/test_cc_static_library/mock_toolchain.bzl for mock_cc_toolchain

@iancha1992 Done. Despite the src/main prefix, this file is actually test code. Unless test code also requires doc strings, it could make sense to exclude src/main/starlark/tests from the linter.

fmeum avatar Jul 30 '24 12:07 fmeum

@fmeum Please add docstring in src/main/starlark/tests/builtins_bzl/cc/cc_static_library/test_cc_static_library/mock_toolchain.bzl for mock_cc_toolchain

@iancha1992 Done. Despite the src/main prefix, this file is actually test code. Unless test code also requires doc strings, it could make sense to exclude src/main/starlark/tests from the linter.

@comius WDYT? The internal CL is still blocked because of it.

iancha1992 avatar Jul 30 '24 21:07 iancha1992

@comius WDYT? The internal CL is still blocked because of it.

I added a doc string, do I need to do anything else to unblock it?

fmeum avatar Aug 01 '24 12:08 fmeum

@comius WDYT? The internal CL is still blocked because of it.

I added a doc string, do I need to do anything else to unblock it?

@fmeum The function "mock_cc_toolchain" has no docstring. Looks like from line 101, the def mock_cc_toolchain(name, provide_validate_static_library = True)

iancha1992 avatar Aug 01 '24 17:08 iancha1992

@comius WDYT? The internal CL is still blocked because of it.

I added a doc string, do I need to do anything else to unblock it?

@fmeum The function "mock_cc_toolchain" has no docstring. Looks like from line 101, the def mock_cc_toolchain(name, provide_validate_static_library = True)

@iancha1992 Should be fixed now, could you run the linter again?

fmeum avatar Aug 01 '24 19:08 fmeum

@bazel-io fork 7.4.0

fmeum avatar Aug 01 '24 20:08 fmeum

@comius WDYT? The internal CL is still blocked because of it.

I added a doc string, do I need to do anything else to unblock it?

@fmeum The function "mock_cc_toolchain" has no docstring. Looks like from line 101, the def mock_cc_toolchain(name, provide_validate_static_library = True)

@iancha1992 Should be fixed now, could you run the linter again?

I think also adding a docstring at the first statement of the file is needed. This will do. @fmeum

iancha1992 avatar Aug 01 '24 20:08 iancha1992

@iancha1992 Added!

fmeum avatar Aug 01 '24 21:08 fmeum