File tree 5 files changed +101
-0
lines changed
src/test/run-make/symbol-visibility
5 files changed +101
-0
lines changed Original file line number Diff line number Diff line change
1
+ include ../tools.mk
2
+
3
+ all :
4
+ $(RUSTC ) an_rlib.rs
5
+ $(RUSTC ) a_cdylib.rs
6
+ $(RUSTC ) a_rust_dylib.rs
7
+ $(RUSTC ) an_executable.rs
8
+
9
+ # Check that a cdylib exports its public #[no_mangle] functions
10
+ [ "$$(nm -D $(TMPDIR)/liba_cdylib.so | grep -c public_c_function_from_cdylib)" -eq "1" ]
11
+ # Check that a cdylib exports the public #[no_mangle] functions of dependencies
12
+ [ "$$(nm -D $(TMPDIR)/liba_cdylib.so | grep -c public_c_function_from_rlib)" -eq "1" ]
13
+ # Check that a cdylib DOES NOT export any public Rust functions
14
+ [ "$$(nm -D $(TMPDIR)/liba_cdylib.so | grep -c _ZN.*h.*E)" -eq "0" ]
15
+
16
+ # Check that a Rust dylib exports its monomorphic functions
17
+ [ "$$(nm -D $(TMPDIR)/liba_rust_dylib.so | grep -c public_c_function_from_rust_dylib)" -eq "1" ]
18
+ [ "$$(nm -D $(TMPDIR)/liba_rust_dylib.so | grep -c _ZN.*public_rust_function_from_rust_dylib.*E)" -eq "1" ]
19
+
20
+ # Check that a Rust dylib exports the monomorphic functions from its dependencies
21
+ [ "$$(nm -D $(TMPDIR)/liba_rust_dylib.so | grep -c public_c_function_from_rlib)" -eq "1" ]
22
+ [ "$$(nm -D $(TMPDIR)/liba_rust_dylib.so | grep -c public_rust_function_from_rlib)" -eq "1" ]
23
+
24
+ # Check that an executable does not export any dynamic symbols
25
+ [ "$$(nm -D $(TMPDIR)/an_executable | grep -c public_c_function_from_rlib)" -eq "0" ]
26
+ [ "$$(nm -D $(TMPDIR)/an_executable | grep -c public_rust_function_from_exe)" -eq "0" ]
Original file line number Diff line number Diff line change
1
+ // Copyright 2016 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
+ #![ crate_type="cdylib" ]
12
+
13
+ extern crate an_rlib;
14
+
15
+ // This should not be exported
16
+ pub fn public_rust_function_from_cdylib ( ) { }
17
+
18
+ // This should be exported
19
+ #[ no_mangle]
20
+ pub extern "C" fn public_c_function_from_cdylib ( ) {
21
+ an_rlib:: public_c_function_from_rlib ( ) ;
22
+ }
Original file line number Diff line number Diff line change
1
+ // Copyright 2016 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
+ #![ crate_type="dylib" ]
12
+
13
+ extern crate an_rlib;
14
+
15
+ // This should be exported
16
+ pub fn public_rust_function_from_rust_dylib ( ) { }
17
+
18
+ // This should be exported
19
+ #[ no_mangle]
20
+ pub extern "C" fn public_c_function_from_rust_dylib ( ) { }
Original file line number Diff line number Diff line change
1
+ // Copyright 2016 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
+ #![ crate_type="bin" ]
12
+
13
+ extern crate an_rlib;
14
+
15
+ pub fn public_rust_function_from_exe ( ) { }
16
+
17
+ fn main ( ) { }
Original file line number Diff line number Diff line change
1
+ // Copyright 2016 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
+ #![ crate_type="rlib" ]
12
+
13
+ pub fn public_rust_function_from_rlib ( ) { }
14
+
15
+ #[ no_mangle]
16
+ pub extern "C" fn public_c_function_from_rlib ( ) { }
You can’t perform that action at this time.
0 commit comments