forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add non-regression test for issue 81408
- Loading branch information
Showing
3 changed files
with
51 additions
and
0 deletions.
There are no files selected for viewing
13 changes: 13 additions & 0 deletions
13
tests/run-make/msvc-lld-thinlto-imp-symbols/issue_81408.rs
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,13 @@ | ||
use std::sync::atomic::{AtomicPtr, Ordering}; | ||
|
||
#[inline(always)] | ||
pub fn memrchr() { | ||
fn detect() {} | ||
|
||
static CROSS_CRATE_STATIC_ITEM: AtomicPtr<()> = AtomicPtr::new(detect as *mut ()); | ||
|
||
unsafe { | ||
let fun = CROSS_CRATE_STATIC_ITEM.load(Ordering::SeqCst); | ||
std::mem::transmute::<*mut (), fn()>(fun)() | ||
} | ||
} |
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 @@ | ||
extern crate issue_81408; | ||
|
||
fn main() { | ||
issue_81408::memrchr(); | ||
} |
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,33 @@ | ||
// This is a non-regression test for issue #81408 involving an lld bug and ThinLTO, on windows. | ||
// MSVC's link.exe doesn't need any workarounds in rustc, but lld does, so we'll check that the | ||
// binary runs successfully instead of using a codegen test. | ||
|
||
//@ only-x86_64-pc-windows-msvc | ||
//@ needs-rust-lld | ||
//@ ignore-cross-compile: the built binary is executed | ||
|
||
use run_make_support::{run, rustc}; | ||
|
||
fn test_with_linker(linker: &str) { | ||
rustc().input("issue_81408.rs").crate_name("issue_81408").crate_type("lib").opt().run(); | ||
rustc() | ||
.input("main.rs") | ||
.crate_type("bin") | ||
.arg("-Clto=thin") | ||
.opt() | ||
.arg(&format!("-Clinker={linker}")) | ||
.extern_("issue_81408", "libissue_81408.rlib") | ||
.run(); | ||
|
||
// To make possible failures clearer, print an intro that will only be shown if the test does | ||
// fail when running the binary. | ||
eprint!("Running binary linked with {linker}... "); | ||
run("main"); | ||
eprintln!("ok"); | ||
} | ||
|
||
fn main() { | ||
// We want the reproducer to work when linker with both linkers. | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong. |
||
test_with_linker("link"); | ||
test_with_linker("rust-lld"); | ||
} |
Should probably be "when linked with both linkers"