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 +}