about summary refs log tree commit diff
path: root/tests/ui/lto/weak-works.rs
blob: 1ff47ca602d24407205f3c6215d8bfa50b046c9c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
//@ run-pass

//@ compile-flags: -C codegen-units=8 -Z thinlto
//@ ignore-i686-pc-windows-gnu
//@ ignore-x86_64-pc-windows-gnu

#![feature(linkage)]

pub mod foo {
    #[linkage = "weak"]
    #[no_mangle]
    pub extern "C" fn FOO() -> i32 {
        0
    }
}

mod bar {
    extern "C" {
        fn FOO() -> i32;
    }

    pub fn bar() -> i32 {
        unsafe { FOO() }
    }
}

fn main() {
    bar::bar();
}