Skip to content

Commit

Permalink
add test demonstrating link flags causing downstream crate compile fail
Browse files Browse the repository at this point in the history
  • Loading branch information
dae committed Oct 16, 2020
1 parent 0af0f7a commit 1a25ac0
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 0 deletions.
34 changes: 34 additions & 0 deletions test/transitive_lib/BUILD
Original file line number Diff line number Diff line change
@@ -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",
],
)
3 changes: 3 additions & 0 deletions test/transitive_lib/build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
fn main() {
println!("cargo:rustc-link-lib=alias:shell32");
}
5 changes: 5 additions & 0 deletions test/transitive_lib/dll_user.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#[link(name = "alias")]
extern "C" {
// random symbol from shell32
pub fn LocalFree(ptr: *mut std::os::raw::c_void);
}
5 changes: 5 additions & 0 deletions test/transitive_lib/dll_user_user.rs
Original file line number Diff line number Diff line change
@@ -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
}

0 comments on commit 1a25ac0

Please sign in to comment.