Skip to content

Commit f41a008

Browse files
authored
Do not add CcInfo from dependencies that don't have them (#369)
The current code is failing for any cdylib or staticlib with a rust dependency (without CcInfo provider). Fixes #368.
1 parent 83962c9 commit f41a008

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

examples/hello_lib/BUILD

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,26 @@ rust_library(
4545
crate_type = "staticlib",
4646
)
4747

48+
# Regression test for #368: static lib with dependencies fail.
49+
rust_library(
50+
name = "hello_test_staticlib",
51+
srcs = [
52+
"tests/greeting.rs",
53+
],
54+
deps = [":hello_lib"],
55+
crate_type = "staticlib",
56+
)
57+
58+
# Regression test for #368: cdylib lib with dependencies fail.
59+
rust_library(
60+
name = "hello_test_cdylib",
61+
srcs = [
62+
"tests/greeting.rs",
63+
],
64+
deps = [":hello_lib"],
65+
crate_type = "cdylib",
66+
)
67+
4868
rust_test(
4969
name = "hello_lib_test",
5070
crate = ":hello_lib",

rust/private/rustc.bzl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -548,7 +548,7 @@ def establish_cc_info(ctx, crate_info, toolchain, cc_toolchain, feature_configur
548548
linker_inputs = depset([link_input]),
549549
)
550550

551-
cc_infos = [dep[CcInfo] for dep in ctx.attr.deps]
551+
cc_infos = [dep[CcInfo] for dep in ctx.attr.deps if CcInfo in dep]
552552
cc_infos.append(CcInfo(linking_context = linking_context))
553553

554554
return [cc_common.merge_cc_infos(cc_infos = cc_infos)]

0 commit comments

Comments
 (0)