Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: remove duplicate objects #26

Merged
merged 2 commits into from
Jan 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cpp/private/common.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def collect_module_objects(deps):

for dep in deps:
if CppModuleInfo in dep:
obj_files.extend(dep[CppModuleInfo].objs)
obj_files.append(dep[CppModuleInfo].objs)

return obj_files

Expand Down
14 changes: 7 additions & 7 deletions cpp/private/target_rules.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def shlib_impl(ctx):
modules = collect_modules(ctx.attr.deps)

obj_files = cpp_compile(ctx.files.srcs, all_headers, includes, modules, features, toolchain)
obj_files = cpp_strip_objects(obj_files, features, toolchain) + collect_module_objects(ctx.attr.deps)
obj_files = depset(cpp_strip_objects(obj_files, features, toolchain), transitive = collect_module_objects(ctx.attr.deps))

shlib = ctx.actions.declare_file(ctx.attr.lib_prefix + ctx.attr.name + ctx.attr.lib_suffix)
compile_output = shlib
Expand All @@ -61,7 +61,7 @@ def shlib_impl(ctx):

link_flags, lib_inputs = resolve_linker_arguments(ctx, toolchain, features, compile_output.path, True)

for obj in obj_files:
for obj in obj_files.to_list():
link_flags.append(obj.path)

linker = cc_common.get_tool_for_action(
Expand All @@ -71,7 +71,7 @@ def shlib_impl(ctx):

ctx.actions.run(
outputs = [compile_output],
inputs = depset(obj_files, transitive = [lib_inputs, toolchain.all_files]),
inputs = depset(obj_files.to_list(), transitive = [lib_inputs, toolchain.all_files]),
executable = linker,
arguments = link_flags,
mnemonic = "CppLinkSharedLibrary",
Expand Down Expand Up @@ -165,7 +165,7 @@ def module_impl(ctx):
)

obj_files = cpp_compile(ctx.files.srcs + [pcm], headers, includes, modules, features, toolchain, module_srcs = ctx.files.interface)
obj_files = cpp_strip_objects(obj_files, features, toolchain) + collect_module_objects(ctx.attr.deps + ctx.attr.partitions)
obj_files = depset(cpp_strip_objects(obj_files, features, toolchain), transitive = collect_module_objects(ctx.attr.deps + ctx.attr.partitions))

return CppModuleInfo(
module_name = ctx.attr.module_name,
Expand Down Expand Up @@ -197,7 +197,7 @@ def binary_impl(ctx):
modules = collect_modules(ctx.attr.deps)

obj_files = cpp_compile(ctx.files.srcs, all_headers, includes, modules, features, toolchain)
obj_files = cpp_strip_objects(obj_files, features, toolchain) + collect_module_objects(ctx.attr.deps)
obj_files = depset(cpp_strip_objects(obj_files, features, toolchain), transitive = collect_module_objects(ctx.attr.deps))

bin = ctx.actions.declare_file(ctx.attr.name + ctx.attr.bin_suffix)
compile_output = bin
Expand All @@ -206,7 +206,7 @@ def binary_impl(ctx):

link_flags, lib_inputs = resolve_linker_arguments(ctx, toolchain, features, compile_output.path, False)

for obj in obj_files:
for obj in obj_files.to_list():
link_flags.append(obj.path)

linker = cc_common.get_tool_for_action(
Expand All @@ -216,7 +216,7 @@ def binary_impl(ctx):

ctx.actions.run(
outputs = [compile_output],
inputs = depset(obj_files, transitive = [lib_inputs, toolchain.all_files]),
inputs = depset(obj_files.to_list(), transitive = [lib_inputs, toolchain.all_files]),
executable = linker,
arguments = link_flags,
mnemonic = "CppLinkExecutable",
Expand Down