-
Notifications
You must be signed in to change notification settings - Fork 402
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add test demonstrating link flags causing downstream crate compile fail
- Loading branch information
Showing
4 changed files
with
47 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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", | ||
], | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
fn main() { | ||
println!("cargo:rustc-link-lib=alias:shell32"); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} |