Skip to content

Commit 65bf666

Browse files
katzdmDaniel Katz
authored andcommitted
Avoid deduplicating linkopts of cc_shared_library dependencies.
1 parent 0271bbc commit 65bf666

File tree

4 files changed

+59
-1
lines changed

4 files changed

+59
-1
lines changed

src/main/starlark/builtins_bzl/common/cc/cc_shared_library.bzl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,7 @@ def _wrap_static_library_with_alwayslink(ctx, feature_configuration, cc_toolchai
298298
return cc_common.create_linker_input(
299299
owner = linker_input.owner,
300300
libraries = depset(direct = new_libraries_to_link),
301-
user_link_flags = depset(direct = linker_input.user_link_flags),
301+
user_link_flags = linker_input.user_link_flags,
302302
additional_inputs = depset(direct = linker_input.additional_inputs),
303303
)
304304

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
load("@rules_cc//cc:cc_library.bzl", "cc_library")
2+
load("@rules_cc//cc:cc_shared_library.bzl", "cc_shared_library")
3+
load("@rules_cc//cc:cc_test.bzl", "cc_test")
4+
5+
package(default_visibility = ["//src/main/starlark/tests/builtins_bzl/cc/cc_shared_library:__subpackages__"])
6+
7+
licenses(["notice"])
8+
9+
cc_library(
10+
name = "bar",
11+
srcs = ["bar.cc"],
12+
linkopts = ["-framework", "Security", "-framework", "IOKit"],
13+
)
14+
15+
cc_shared_library(
16+
name = "bar_so",
17+
deps = [":bar"],
18+
)
19+
20+
cc_test(
21+
name = "cc_test",
22+
srcs = ["main.cc"],
23+
dynamic_deps = select({"@platforms//os:macos": [":bar_so"]}),
24+
)
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// Copyright 2024 The Bazel Authors. All rights reserved.
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
int bar() { return 42; }
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// Copyright 2025 The Bazel Authors. All rights reserved.
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
#include <iostream>
15+
16+
17+
int main() {
18+
std::cout << "hello, world!" << std::endl;
19+
return 0;
20+
}

0 commit comments

Comments
 (0)