]> git.lizzy.rs Git - rust.git/blob - src/test/codegen/dllimports/main.rs
Auto merge of #76580 - rokob:iss76011, r=estebank
[rust.git] / src / test / codegen / dllimports / main.rs
1 // This test is for *-windows-msvc only.
2 // ignore-android
3 // ignore-dragonfly
4 // ignore-emscripten
5 // ignore-freebsd
6 // ignore-gnu
7 // ignore-haiku
8 // ignore-ios
9 // ignore-linux
10 // ignore-macos
11 // ignore-netbsd
12 // ignore-openbsd
13 // ignore-solaris
14 // ignore-sgx no dynamic linking
15
16 // aux-build:dummy.rs
17 // aux-build:wrapper.rs
18
19 extern crate wrapper;
20
21 // Check that external symbols coming from foreign dylibs are adorned with 'dllimport',
22 // whereas symbols coming from foreign staticlibs are not. (RFC-1717)
23
24 // CHECK: @dylib_global1 = external dllimport local_unnamed_addr global i32
25 // CHECK: @dylib_global2 = external dllimport local_unnamed_addr global i32
26 // CHECK: @static_global1 = external local_unnamed_addr global i32
27 // CHECK: @static_global2 = external local_unnamed_addr global i32
28
29 // CHECK: declare dllimport i32 @dylib_func1(i32)
30 // CHECK: declare dllimport i32 @dylib_func2(i32)
31 // CHECK: declare i32 @static_func1(i32)
32 // CHECK: declare i32 @static_func2(i32)
33
34 #[link(name = "dummy", kind="dylib")]
35 extern "C" {
36     pub fn dylib_func1(x: i32) -> i32;
37     pub static dylib_global1: i32;
38 }
39
40 #[link(name = "dummy", kind="static")]
41 extern "C" {
42     pub fn static_func1(x: i32) -> i32;
43     pub static static_global1: i32;
44 }
45
46 fn main() {
47     unsafe {
48         dylib_func1(dylib_global1);
49         wrapper::dylib_func2(wrapper::dylib_global2);
50
51         static_func1(static_global1);
52         wrapper::static_func2(wrapper::static_global2);
53     }
54 }