Skip to content

Commit

Permalink
Skip linking for clippy aspect (#526)
Browse files Browse the repository at this point in the history
  • Loading branch information
djmarcin committed Dec 5, 2020
1 parent aa7c693 commit bc05787
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 13 deletions.
1 change: 1 addition & 0 deletions rust/private/clippy.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ def _clippy_aspect_impl(target, ctx):
build_flags_files = build_flags_files,
maker_path = clippy_marker.path,
aspect = True,
emit = ["dep-info", "metadata"],
)

# Deny the default-on clippy warning levels.
Expand Down
30 changes: 17 additions & 13 deletions rust/private/rustc.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,8 @@ def construct_arguments(
build_env_file,
build_flags_files,
maker_path = None,
aspect = False):
aspect = False,
emit = ["dep-info", "link"]):
"""Builds an Args object containing common rustc flags
Args:
Expand All @@ -416,6 +417,7 @@ def construct_arguments(
build_flags_files (list): The output files of a `cargo_build_script` actions containing rustc build flags
maker_path (File): An optional clippy marker file
aspect (bool): True if called in an aspect context.
emit (list): Values for the --emit flag to rustc.
Returns:
tuple: A tuple of the following items
Expand Down Expand Up @@ -497,7 +499,7 @@ def construct_arguments(
args.add("--codegen=opt-level=" + compilation_mode.opt_level)
args.add("--codegen=debuginfo=" + compilation_mode.debug_info)

args.add("--emit=dep-info,link")
args.add("--emit=" + ",".join(emit))
args.add("--color=always")
args.add("--target=" + toolchain.target_triple)
if hasattr(ctx.attr, "crate_features"):
Expand All @@ -516,17 +518,19 @@ def construct_arguments(
add_edition_flags(args, crate_info)

# Link!

# Rust's built-in linker can handle linking wasm files. We don't want to attempt to use the cc
# linker since it won't understand.
if toolchain.target_arch != "wasm32":
rpaths = _compute_rpaths(toolchain, output_dir, dep_info)
ld, link_args, link_env = get_linker_and_args(ctx, cc_toolchain, feature_configuration, rpaths)
env.update(link_env)
args.add("--codegen=linker=" + ld)
args.add_joined("--codegen", link_args, join_with = " ", format_joined = "link-args=%s")

add_native_link_flags(args, dep_info)
if "link" in emit:
# Rust's built-in linker can handle linking wasm files. We don't want to attempt to use the cc
# linker since it won't understand.
if toolchain.target_arch != "wasm32":
rpaths = _compute_rpaths(toolchain, output_dir, dep_info)
ld, link_args, link_env = get_linker_and_args(ctx, cc_toolchain, feature_configuration, rpaths)
env.update(link_env)
args.add("--codegen=linker=" + ld)
args.add_joined("--codegen", link_args, join_with = " ", format_joined = "link-args=%s")

add_native_link_flags(args, dep_info)

# These always need to be added, even if not linking this crate.
add_crate_link_flags(args, dep_info)

if crate_info.type == "proc-macro" and crate_info.edition != "2015":
Expand Down

0 comments on commit bc05787

Please sign in to comment.