]> git.lizzy.rs Git - rust.git/blob - tests/codegen/dllimports/main.rs
Rollup merge of #107190 - fmease:fix-81698, r=compiler-errors
[rust.git] / tests / codegen / dllimports / main.rs
1  // This test is for *-windows-msvc only.
2 // only-windows
3 // ignore-gnu
4
5 // aux-build:dummy.rs
6 // aux-build:wrapper.rs
7
8 extern crate wrapper;
9
10 // Check that external symbols coming from foreign dylibs are adorned with 'dllimport',
11 // whereas symbols coming from foreign staticlibs are not. (RFC-1717)
12
13 // CHECK: @dylib_global1 = external dllimport local_unnamed_addr global i32
14 // CHECK: @dylib_global2 = external dllimport local_unnamed_addr global i32
15 // CHECK: @static_global1 = external local_unnamed_addr global i32
16 // CHECK: @static_global2 = external local_unnamed_addr global i32
17
18 // CHECK: declare dllimport noundef i32 @dylib_func1(i32 noundef)
19 // CHECK: declare dllimport noundef i32 @dylib_func2(i32 noundef)
20 // CHECK: declare noundef i32 @static_func1(i32 noundef)
21 // CHECK: declare noundef i32 @static_func2(i32 noundef)
22
23 #[link(name = "dummy", kind="dylib")]
24 extern "C" {
25     pub fn dylib_func1(x: i32) -> i32;
26     pub static dylib_global1: i32;
27 }
28
29 #[link(name = "dummy", kind="static")]
30 extern "C" {
31     pub fn static_func1(x: i32) -> i32;
32     pub static static_global1: i32;
33 }
34
35 fn main() {
36     unsafe {
37         dylib_func1(dylib_global1);
38         wrapper::dylib_func2(wrapper::dylib_global2);
39
40         static_func1(static_global1);
41         wrapper::static_func2(wrapper::static_global2);
42     }
43 }