Skip to content

Commit

Permalink
Fix
Browse files Browse the repository at this point in the history
  • Loading branch information
hlopko committed Mar 3, 2021
1 parent 57dbc03 commit f885169
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 19 deletions.
6 changes: 4 additions & 2 deletions rust/private/rustc.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -688,8 +688,10 @@ 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 if CcInfo in dep]
cc_infos.append(CcInfo(linking_context = linking_context))
cc_infos = [ CcInfo(linking_context = linking_context) ]
for dep in ctx.attr.deps:
if CcInfo in dep:
cc_infos.append(dep[CcInfo])

return [cc_common.merge_cc_infos(cc_infos = cc_infos)]

Expand Down
20 changes: 3 additions & 17 deletions test/unit/interleaved_cc_info/interleaved_cc_info_test.bzl
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""Unittests for rust rules."""

load("@bazel_skylib//lib:unittest.bzl", "analysistest", "asserts")
load("//rust:defs.bzl", "rust_common", "rust_library")
load("//rust:defs.bzl", "rust_library")
load("@rules_cc//cc:defs.bzl", "cc_library")

def _interleaving_cc_link_order_test_impl(ctx):
Expand All @@ -25,15 +25,7 @@ def _interleaving_cc_link_order_test_impl(ctx):

interleaving_cc_link_order_test = analysistest.make(_interleaving_cc_link_order_test_impl)

def _interleaving_rust_link_order_test_impl(ctx):
env = analysistest.begin(ctx)
tut = analysistest.target_under_test(env)
dep_info = tut[rust_common.dep_info]
return analysistest.end(env)

interleaving_rust_link_order_test = analysistest.make(_interleaving_rust_link_order_test_impl)

def _interleaving_cc_link_order_test():
def _interleaving_link_order_test():
rust_library(
name = "a",
srcs = ["a.rs"],
Expand Down Expand Up @@ -65,23 +57,17 @@ def _interleaving_cc_link_order_test():
target_under_test = ":a",
)

interleaving_rust_link_order_test(
name = "interleaving_rust_link_order_test",
target_under_test = ":a",
)

def interleaved_cc_info_test_suite(name):
"""Entry-point macro called from the BUILD file.
Args:
name: Name of the macro.
"""
_interleaving_cc_link_order_test()
_interleaving_link_order_test()

native.test_suite(
name = name,
tests = [
":interleaving_cc_link_order_test",
":interleaving_rust_link_order_test",
],
)

0 comments on commit f885169

Please sign in to comment.