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

[7.4.0] Add experimental cc_static_library rule #23392

Merged
merged 1 commit into from
Aug 26, 2024

Conversation

fmeum
Copy link
Collaborator

@fmeum fmeum commented Aug 22, 2024

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

Closes #16954.

PiperOrigin-RevId: 661382285
Change-Id: I972afd1a38d50ab4e48d9b3c189f1662b0096bbf

Closes #23192

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 bazelbuild#1920

Closes bazelbuild#16954.

PiperOrigin-RevId: 661382285
Change-Id: I972afd1a38d50ab4e48d9b3c189f1662b0096bbf
@fmeum fmeum requested a review from a team as a code owner August 22, 2024 10:40
@github-actions github-actions bot added awaiting-review PR is awaiting review from an assigned reviewer team-Rules-CPP Issues for C++ rules labels Aug 22, 2024
@iancha1992 iancha1992 requested a review from comius August 22, 2024 17:30
@iancha1992 iancha1992 enabled auto-merge August 22, 2024 17:31
@iancha1992 iancha1992 added this pull request to the merge queue Aug 26, 2024
Merged via the queue into bazelbuild:release-7.4.0 with commit 84725e5 Aug 26, 2024
52 checks passed
@github-actions github-actions bot removed the awaiting-review PR is awaiting review from an assigned reviewer label Aug 26, 2024
@fmeum fmeum deleted the 23192-cherry branch August 27, 2024 09:04
@dtera
Copy link

dtera commented Nov 11, 2024

[7.4.0-error]: name 'cc_static_library' is not defined. By the way, I've added the --experimental_cc_static_library option

@fmeum
Copy link
Collaborator Author

fmeum commented Nov 11, 2024

How are you trying to use it? Could you post a full BUILD file snippet?

@dtera
Copy link

dtera commented Nov 11, 2024

How are you trying to use it? Could you post a full BUILD file snippet?

cc_library(
    name = "app",
    srcs = ["app.cc"],
    hdrs = ["app.h"],
    deps = [
        ":xxx",
        ":yyy",
    ],
)

cc_static_library(
    name = "app_all",
    deps = [
        ":app",
    ],
    visibility = ["//visibility:public"],
)
bazel build -c opt --experimental_cc_static_library //...

I just use cc_static_library like cc_library, not load anything else. Besides, the official documents about cc_static_library doesn't say what to load.

@fmeum
Copy link
Collaborator Author

fmeum commented Nov 11, 2024

@dtera I can't reproduce this with 7.4.0. Are you certain you are using the correct version of Bazel?

@dtera
Copy link

dtera commented Nov 11, 2024

@dtera I can't reproduce this with 7.4.0. Are you certain you are using the correct version of Bazel?

Yes, the version is in .bazelversion, and I checked with 'bazel --version'. Can you give me a complete example, I'm using WORKSPACE instead of Bzlmod.

@dtera
Copy link

dtera commented Nov 11, 2024

@dtera I can't reproduce this with 7.4.0. Are you certain you are using the correct version of Bazel?

load("@rules_cc//cc:defs.bzl", "cc_library")

@fmeum Do I need to load something, like the example above?

@fmeum
Copy link
Collaborator Author

fmeum commented Nov 11, 2024

You don't. Could you share a zip or git repo with a complete reproducer?

@dtera
Copy link

dtera commented Nov 12, 2024

You don't. Could you share a zip or git repo with a complete reproducer?

https://github.com/dtera/bazel_demo.git
There is no problem using cc_static_library directly in BUILD.bazel, but extending cc_static_library in demo.bzl and loading from it fails.

@fmeum
Copy link
Collaborator Author

fmeum commented Nov 12, 2024

That's the case for all rules natively provided by Bazel: to reference them in a .bzl file, you need to access them as native.cc_static_library.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
team-Rules-CPP Issues for C++ rules
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants