]> git.proxmox.com Git - rustc.git/blame - src/test/run-pass/linkage1.rs
Imported Upstream version 1.0.0~beta
[rustc.git] / src / test / run-pass / linkage1.rs
CommitLineData
1a4d82fc
JJ
1// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
2// file at the top-level directory of this distribution and at
3// http://rust-lang.org/COPYRIGHT.
4//
5// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8// option. This file may not be copied, modified, or distributed
9// except according to those terms.
10
11// ignore-windows
1a4d82fc
JJ
12// ignore-macos
13// aux-build:linkage1.rs
14
15#![feature(linkage)]
16
c34b1796 17extern crate linkage1 as other;
1a4d82fc
JJ
18
19extern {
20 #[linkage = "extern_weak"]
c34b1796 21 static foo: *const isize;
1a4d82fc 22 #[linkage = "extern_weak"]
c34b1796 23 static something_that_should_never_exist: *mut isize;
1a4d82fc
JJ
24}
25
26fn main() {
27 // It appears that the --as-needed flag to linkers will not pull in a dynamic
28 // library unless it satisfies a non weak undefined symbol. The 'other' crate
29 // is compiled as a dynamic library where it would only be used for a
30 // weak-symbol as part of an executable, so the dynamic library would be
31 // discarded. By adding and calling `other::bar`, we get around this problem.
32 other::bar();
33
34 assert!(!foo.is_null());
35 assert_eq!(unsafe { *foo }, 3);
36 assert!(something_that_should_never_exist.is_null());
37}