diff --git a/tests/run-make/link-framework/Makefile b/tests/run-make/link-framework/Makefile new file mode 100644 index 0000000000000..f33347ac7f8f5 --- /dev/null +++ b/tests/run-make/link-framework/Makefile @@ -0,0 +1,23 @@ +# only-macos +# +# Check that linking to a framework actually makes it to the linker. + +include ../tools.mk + +all: + $(RUSTC) dep-link-framework.rs + $(RUSTC) dep-link-weak-framework.rs + + $(RUSTC) empty.rs + otool -L $(TMPDIR)/no-link | $(CGREP) -v CoreFoundation + + $(RUSTC) link-framework.rs + otool -L $(TMPDIR)/link-framework | $(CGREP) CoreFoundation | $(CGREP) -v weak + + $(RUSTC) link-weak-framework.rs + otool -L $(TMPDIR)/link-weak-framework | $(CGREP) CoreFoundation | $(CGREP) weak + +# When linking the framework both normally, and weakly, the weak linking takes preference + + $(RUSTC) link-both.rs + otool -L $(TMPDIR)/link-both | $(CGREP) CoreFoundation | $(CGREP) weak diff --git a/tests/run-make/link-framework/dep-link-framework.rs b/tests/run-make/link-framework/dep-link-framework.rs new file mode 100644 index 0000000000000..9bdeb2052d255 --- /dev/null +++ b/tests/run-make/link-framework/dep-link-framework.rs @@ -0,0 +1,4 @@ +#![crate_type = "rlib"] + +#[link(name = "CoreFoundation", kind = "framework")] +extern "C" {} diff --git a/tests/run-make/link-framework/dep-link-weak-framework.rs b/tests/run-make/link-framework/dep-link-weak-framework.rs new file mode 100644 index 0000000000000..d3e1cf9c98f5f --- /dev/null +++ b/tests/run-make/link-framework/dep-link-weak-framework.rs @@ -0,0 +1,6 @@ +#![crate_type = "rlib"] +#![feature(link_arg_attribute)] + +#[link(name = "-weak_framework", kind = "link-arg", modifiers = "+verbatim")] +#[link(name = "CoreFoundation", kind = "link-arg", modifiers = "+verbatim")] +extern "C" {} diff --git a/tests/run-make/link-framework/empty.rs b/tests/run-make/link-framework/empty.rs new file mode 100644 index 0000000000000..f328e4d9d04c3 --- /dev/null +++ b/tests/run-make/link-framework/empty.rs @@ -0,0 +1 @@ +fn main() {} diff --git a/tests/run-make/link-framework/link-both.rs b/tests/run-make/link-framework/link-both.rs new file mode 100644 index 0000000000000..31fc79e1929ac --- /dev/null +++ b/tests/run-make/link-framework/link-both.rs @@ -0,0 +1,4 @@ +extern crate dep_link_framework; +extern crate dep_link_weak_framework; + +fn main() {} diff --git a/tests/run-make/link-framework/link-framework.rs b/tests/run-make/link-framework/link-framework.rs new file mode 100644 index 0000000000000..e33e830248ebe --- /dev/null +++ b/tests/run-make/link-framework/link-framework.rs @@ -0,0 +1,3 @@ +extern crate dep_link_framework; + +fn main() {} diff --git a/tests/run-make/link-framework/link-weak-framework.rs b/tests/run-make/link-framework/link-weak-framework.rs new file mode 100644 index 0000000000000..f0557f8013a43 --- /dev/null +++ b/tests/run-make/link-framework/link-weak-framework.rs @@ -0,0 +1,3 @@ +extern crate dep_link_weak_framework; + +fn main() {}