Skip to content

Commit

Permalink
Block LINKABLE_MORE_THAN_ONCE internally
Browse files Browse the repository at this point in the history
We can make it available later if it turns out to be needed.

RELNOTES:none
PiperOrigin-RevId: 513204074
Change-Id: I53f0227ea63aa60a7e0dae198df8477afdf41099
  • Loading branch information
oquenchil authored and copybara-github committed Mar 1, 2023
1 parent 9f83956 commit 05d8a6f
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 6 deletions.
2 changes: 2 additions & 0 deletions src/main/starlark/builtins_bzl/common/cc/cc_library.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ cc_internal = _builtins.internal.cc_internal
def _cc_library_impl(ctx):
cc_helper.check_srcs_extensions(ctx, ALLOWED_SRC_FILES, "cc_library", True)

semantics.check_cc_shared_library_tags(ctx)

common = cc_internal.create_common(ctx = ctx)
cc_toolchain = cc_helper.find_cpp_toolchain(ctx)
cc_helper.report_invalid_options(cc_toolchain, ctx.fragments.cpp)
Expand Down
4 changes: 4 additions & 0 deletions src/main/starlark/builtins_bzl/common/cc/semantics.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,9 @@ def _get_nocopts_attr():
def _get_experimental_link_static_libraries_once(ctx):
return ctx.fragments.cpp.experimental_link_static_libraries_once()

def _check_cc_shared_library_tags(ctx):
pass

semantics = struct(
ALLOWED_RULES_IN_DEPS = [
"cc_library",
Expand Down Expand Up @@ -215,4 +218,5 @@ semantics = struct(
get_proto_aspects = _get_proto_aspects,
get_nocopts_attr = _get_nocopts_attr,
get_experimental_link_static_libraries_once = _get_experimental_link_static_libraries_once,
check_cc_shared_library_tags = _check_cc_shared_library_tags,
)
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ load(

LINKABLE_MORE_THAN_ONCE = "LINKABLE_MORE_THAN_ONCE"

NO_BUILD_TAGS = [
"manual",
"nobuilder",
]

licenses(["notice"])

package(
Expand Down Expand Up @@ -79,7 +84,7 @@ cc_shared_library(
name = "diamond2_so",
dynamic_deps = [":a_so"],
features = ["windows_export_all_symbols"],
deps = [":qux2"],
deps = [":bar"],
)

cc_binary(
Expand Down Expand Up @@ -143,10 +148,12 @@ cc_library(
"baz",
# Not exported.
"qux",
"qux2",
"prebuilt",
"//src/main/starlark/tests/builtins_bzl/cc/cc_shared_library/test_cc_shared_library3:diff_pkg"
],
] + select({
":is_bazel": ["qux2"],
"//conditions:default": [],
}),
)

cc_library(
Expand All @@ -173,7 +180,7 @@ cc_library(
name = "qux2",
srcs = ["qux2.cc"],
hdrs = ["qux2.h"],
tags = [LINKABLE_MORE_THAN_ONCE],
tags = [LINKABLE_MORE_THAN_ONCE] + NO_BUILD_TAGS,
)

config_setting(
Expand Down Expand Up @@ -225,8 +232,10 @@ cc_library(
hdrs = ["bar.h"],
deps = [
"barX",
"qux2",
],
] + select({
":is_bazel": ["qux2"],
"//conditions:default": [],
}),
)

cc_library(
Expand Down

0 comments on commit 05d8a6f

Please sign in to comment.