diff --git a/rust/private/rustc.bzl b/rust/private/rustc.bzl index 4c08f30bd2..146766e3e8 100644 --- a/rust/private/rustc.bzl +++ b/rust/private/rustc.bzl @@ -724,15 +724,10 @@ def _create_extra_input_args(ctx, file, build_info, dep_info): if build_info: out_dir = build_info.out_dir.path build_env_file = build_info.rustc_env.path - - # out_dir will be added as input by the transitive_build_infos loop below. build_flags_files.append(build_info.flags.path) - - # This should probably only actually be exposed to actions which link. - for dep_build_info in dep_info.transitive_build_infos.to_list(): - input_files.append(dep_build_info.out_dir) - build_flags_files.append(dep_build_info.link_flags.path) - input_files.append(dep_build_info.link_flags) + build_flags_files.append(build_info.link_flags.path) + input_files.append(build_info.out_dir) + input_files.append(build_info.link_flags) return input_files, out_dir, build_env_file, build_flags_files diff --git a/test/transitive_lib/BUILD b/test/transitive_lib/BUILD new file mode 100644 index 0000000000..b7e96891d6 --- /dev/null +++ b/test/transitive_lib/BUILD @@ -0,0 +1,34 @@ +load( + "@io_bazel_rules_rust//cargo:cargo_build_script.bzl", + "cargo_build_script", +) +load("@io_bazel_rules_rust//rust:rust.bzl", "rust_binary", "rust_library") + +# sets link alias +cargo_build_script( + name = "buildscript", + srcs = ["build.rs"], + crate_root = "build.rs", + edition = "2018", +) + +# links to a symbol in shell32 +rust_library( + name = "dll_user", + srcs = ["dll_user.rs"], + crate_type = "lib", + edition = "2018", + deps = [ + ":buildscript", + ], +) + +# does not link to any symbol in shell32 +rust_binary( + name = "dll_user_user", + srcs = ["dll_user_user.rs"], + edition = "2018", + deps = [ + ":dll_user", + ], +) diff --git a/test/transitive_lib/build.rs b/test/transitive_lib/build.rs new file mode 100644 index 0000000000..c3e700116c --- /dev/null +++ b/test/transitive_lib/build.rs @@ -0,0 +1,3 @@ +fn main() { + println!("cargo:rustc-link-lib=alias:shell32"); +} diff --git a/test/transitive_lib/dll_user.rs b/test/transitive_lib/dll_user.rs new file mode 100644 index 0000000000..890590f1d9 --- /dev/null +++ b/test/transitive_lib/dll_user.rs @@ -0,0 +1,5 @@ +#[link(name = "alias")] +extern "C" { + // random symbol from shell32 + pub fn LocalFree(ptr: *mut std::os::raw::c_void); +} diff --git a/test/transitive_lib/dll_user_user.rs b/test/transitive_lib/dll_user_user.rs new file mode 100644 index 0000000000..575676014f --- /dev/null +++ b/test/transitive_lib/dll_user_user.rs @@ -0,0 +1,5 @@ +fn main() { + // this file does not link to any shell32 symbols directly, and + // will thus cause a compile error if -lalias:shell32 + // is present in the link flags +}