File tree 3 files changed +51
-0
lines changed
tests/run-make/msvc-lld-thinlto-imp-symbols
3 files changed +51
-0
lines changed Original file line number Diff line number Diff line change
1
+ use std:: sync:: atomic:: { AtomicPtr , Ordering } ;
2
+
3
+ #[ inline( always) ]
4
+ pub fn memrchr ( ) {
5
+ fn detect ( ) { }
6
+
7
+ static CROSS_CRATE_STATIC_ITEM : AtomicPtr < ( ) > = AtomicPtr :: new ( detect as * mut ( ) ) ;
8
+
9
+ unsafe {
10
+ let fun = CROSS_CRATE_STATIC_ITEM . load ( Ordering :: SeqCst ) ;
11
+ std:: mem:: transmute :: < * mut ( ) , fn ( ) > ( fun) ( )
12
+ }
13
+ }
Original file line number Diff line number Diff line change
1
+ extern crate issue_81408;
2
+
3
+ fn main ( ) {
4
+ issue_81408:: memrchr ( ) ;
5
+ }
Original file line number Diff line number Diff line change
1
+ // This is a non-regression test for issue #81408 involving an lld bug and ThinLTO, on windows.
2
+ // MSVC's link.exe doesn't need any workarounds in rustc, but lld does, so we'll check that the
3
+ // binary runs successfully instead of using a codegen test.
4
+
5
+ //@ only-x86_64-pc-windows-msvc
6
+ //@ needs-rust-lld
7
+ //@ ignore-cross-compile: the built binary is executed
8
+
9
+ use run_make_support:: { run, rustc} ;
10
+
11
+ fn test_with_linker ( linker : & str ) {
12
+ rustc ( ) . input ( "issue_81408.rs" ) . crate_name ( "issue_81408" ) . crate_type ( "lib" ) . opt ( ) . run ( ) ;
13
+ rustc ( )
14
+ . input ( "main.rs" )
15
+ . crate_type ( "bin" )
16
+ . arg ( "-Clto=thin" )
17
+ . opt ( )
18
+ . arg ( & format ! ( "-Clinker={linker}" ) )
19
+ . extern_ ( "issue_81408" , "libissue_81408.rlib" )
20
+ . run ( ) ;
21
+
22
+ // To make possible failures clearer, print an intro that will only be shown if the test does
23
+ // fail when running the binary.
24
+ eprint ! ( "Running binary linked with {linker}... " ) ;
25
+ run ( "main" ) ;
26
+ eprintln ! ( "ok" ) ;
27
+ }
28
+
29
+ fn main ( ) {
30
+ // We want the reproducer to work when linked with both linkers.
31
+ test_with_linker ( "link" ) ;
32
+ test_with_linker ( "rust-lld" ) ;
33
+ }
You can’t perform that action at this time.
0 commit comments