diff options
| author | bors <bors@rust-lang.org> | 2017-02-04 21:13:07 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2017-02-04 21:13:07 +0000 |
| commit | ea7a6486a26af085862cd7a5596bb69e83d85e12 (patch) | |
| tree | 4d191736bf2197b11ba614b62612fa1636533066 /src/test | |
| parent | eb5cb9545cfa4f1e90c92266b802edc4690f584a (diff) | |
| parent | 7504897e6b4b1121191bc6612bcbcce1f70f5f06 (diff) | |
| download | rust-ea7a6486a26af085862cd7a5596bb69e83d85e12.tar.gz rust-ea7a6486a26af085862cd7a5596bb69e83d85e12.zip | |
Auto merge of #38426 - vadimcn:nobundle, r=alexcrichton
Implement kind="static-nobundle" (RFC 1717) This implements the "static-nobundle" library kind (last item from #37403). Rustc handles "static-nobundle" libs very similarly to dylibs, except that on Windows, uses of their symbols do not get marked with "dllimport". Which is the whole point of this feature.
Diffstat (limited to 'src/test')
| -rw-r--r-- | src/test/compile-fail/feature-gate-static-nobundle.rs | 13 | ||||
| -rw-r--r-- | src/test/run-make/static-nobundle/Makefile | 21 | ||||
| -rw-r--r-- | src/test/run-make/static-nobundle/aaa.c | 11 | ||||
| -rw-r--r-- | src/test/run-make/static-nobundle/bbb.rs | 23 | ||||
| -rw-r--r-- | src/test/run-make/static-nobundle/ccc.rs | 23 | ||||
| -rw-r--r-- | src/test/run-make/static-nobundle/ddd.rs | 17 |
6 files changed, 108 insertions, 0 deletions
diff --git a/src/test/compile-fail/feature-gate-static-nobundle.rs b/src/test/compile-fail/feature-gate-static-nobundle.rs new file mode 100644 index 00000000000..bc0025c7c95 --- /dev/null +++ b/src/test/compile-fail/feature-gate-static-nobundle.rs @@ -0,0 +1,13 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#[link(name="foo", kind="static-nobundle")] +//~^ ERROR: kind="static-nobundle" is feature gated +extern {} diff --git a/src/test/run-make/static-nobundle/Makefile b/src/test/run-make/static-nobundle/Makefile new file mode 100644 index 00000000000..3eac12f5cc9 --- /dev/null +++ b/src/test/run-make/static-nobundle/Makefile @@ -0,0 +1,21 @@ +-include ../tools.mk + +# aaa is a native static library +# bbb is a rlib +# ccc is a dylib +# ddd is an executable + +all: $(call NATIVE_STATICLIB,aaa) + $(RUSTC) bbb.rs --crate-type=rlib + + # Check that bbb does NOT contain the definition of `native_func` + nm $(TMPDIR)/libbbb.rlib | (! grep "T _*native_func") + nm $(TMPDIR)/libbbb.rlib | grep "U _*native_func" + + # Check that aaa gets linked (either as `-l aaa` or `aaa.lib`) when building ccc. + $(RUSTC) ccc.rs -C prefer-dynamic --crate-type=dylib -Z print-link-args | grep -e "-l[\" ]*aaa" -e "aaa.lib" + + # Check that aaa does NOT get linked when building ddd. + $(RUSTC) ddd.rs -Z print-link-args | (! grep -e "-l[\" ]*aaa" -e "aaa.lib") + + $(call RUN,ddd) diff --git a/src/test/run-make/static-nobundle/aaa.c b/src/test/run-make/static-nobundle/aaa.c new file mode 100644 index 00000000000..806ef878c70 --- /dev/null +++ b/src/test/run-make/static-nobundle/aaa.c @@ -0,0 +1,11 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +void native_func() {} diff --git a/src/test/run-make/static-nobundle/bbb.rs b/src/test/run-make/static-nobundle/bbb.rs new file mode 100644 index 00000000000..2bd69c99327 --- /dev/null +++ b/src/test/run-make/static-nobundle/bbb.rs @@ -0,0 +1,23 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_type = "rlib"] +#![feature(static_nobundle)] + +#[link(name = "aaa", kind = "static-nobundle")] +extern { + pub fn native_func(); +} + +pub fn wrapped_func() { + unsafe { + native_func(); + } +} diff --git a/src/test/run-make/static-nobundle/ccc.rs b/src/test/run-make/static-nobundle/ccc.rs new file mode 100644 index 00000000000..bd34753a00d --- /dev/null +++ b/src/test/run-make/static-nobundle/ccc.rs @@ -0,0 +1,23 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_type = "dylib"] + +extern crate bbb; + +pub fn do_work() { + unsafe { bbb::native_func(); } + bbb::wrapped_func(); +} + +pub fn do_work_generic<T>() { + unsafe { bbb::native_func(); } + bbb::wrapped_func(); +} diff --git a/src/test/run-make/static-nobundle/ddd.rs b/src/test/run-make/static-nobundle/ddd.rs new file mode 100644 index 00000000000..f7d23a899f7 --- /dev/null +++ b/src/test/run-make/static-nobundle/ddd.rs @@ -0,0 +1,17 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +extern crate ccc; + +fn main() { + ccc::do_work(); + ccc::do_work_generic::<i16>(); + ccc::do_work_generic::<i32>(); +} |
