Skip to content

Commit

Permalink
Do not add CcInfo from dependencies that don't have them (#369)
Browse files Browse the repository at this point in the history
The current code is failing for any cdylib or staticlib with
a rust dependency (without CcInfo provider).

Fixes #368.
  • Loading branch information
damienmg committed Jul 3, 2020
1 parent 83962c9 commit f41a008
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
20 changes: 20 additions & 0 deletions examples/hello_lib/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,26 @@ rust_library(
crate_type = "staticlib",
)

# Regression test for #368: static lib with dependencies fail.
rust_library(
name = "hello_test_staticlib",
srcs = [
"tests/greeting.rs",
],
deps = [":hello_lib"],
crate_type = "staticlib",
)

# Regression test for #368: cdylib lib with dependencies fail.
rust_library(
name = "hello_test_cdylib",
srcs = [
"tests/greeting.rs",
],
deps = [":hello_lib"],
crate_type = "cdylib",
)

rust_test(
name = "hello_lib_test",
crate = ":hello_lib",
Expand Down
2 changes: 1 addition & 1 deletion rust/private/rustc.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -548,7 +548,7 @@ def establish_cc_info(ctx, crate_info, toolchain, cc_toolchain, feature_configur
linker_inputs = depset([link_input]),
)

cc_infos = [dep[CcInfo] for dep in ctx.attr.deps]
cc_infos = [dep[CcInfo] for dep in ctx.attr.deps if CcInfo in dep]
cc_infos.append(CcInfo(linking_context = linking_context))

return [cc_common.merge_cc_infos(cc_infos = cc_infos)]
Expand Down

0 comments on commit f41a008

Please sign in to comment.