diff --git a/tests/run-make/linkage-attr-framework/main.rs b/tests/run-make/linkage-attr-framework/main.rs new file mode 100644 index 00000000000..8efabc83e62 --- /dev/null +++ b/tests/run-make/linkage-attr-framework/main.rs @@ -0,0 +1,17 @@ +#![cfg_attr(any(weak, both), feature(link_arg_attribute))] + +#[cfg_attr(any(link, both), link(name = "CoreFoundation", kind = "framework"))] +#[cfg_attr( + any(weak, both), + link(name = "-weak_framework", kind = "link-arg", modifiers = "+verbatim"), + link(name = "CoreFoundation", kind = "link-arg", modifiers = "+verbatim") +)] +extern "C" { + fn CFRunLoopGetTypeID() -> core::ffi::c_ulong; +} + +fn main() { + unsafe { + CFRunLoopGetTypeID(); + } +} diff --git a/tests/run-make/linkage-attr-framework/rmake.rs b/tests/run-make/linkage-attr-framework/rmake.rs new file mode 100644 index 00000000000..4450350f96e --- /dev/null +++ b/tests/run-make/linkage-attr-framework/rmake.rs @@ -0,0 +1,26 @@ +//! Check that linking frameworks on Apple platforms works. + +//@ only-apple + +use run_make_support::{Rustc, run, rustc}; + +fn compile(cfg: &str) -> Rustc { + let mut rustc = rustc(); + rustc.cfg(cfg).input("main.rs"); + rustc +} + +fn main() { + for cfg in ["link", "weak", "both"] { + compile(cfg).run(); + run("main"); + } + + let errs = compile("omit").run_fail(); + // The linker's exact error output changes between Xcode versions, depends on + // linker invocation details, and the linker sometimes outputs more warnings. + errs.assert_stderr_contains_regex(r"error: linking with `.*` failed"); + errs.assert_stderr_contains_regex(r"(Undefined symbols|ld: symbol[^\s]* not found)"); + errs.assert_stderr_contains_regex(r".?_CFRunLoopGetTypeID.?, referenced from:"); + errs.assert_stderr_contains("clang: error: linker command failed with exit code 1"); +} diff --git a/tests/ui/linkage-attr/framework.omit.stderr b/tests/ui/linkage-attr/framework.omit.stderr deleted file mode 100644 index 23e017cb012..00000000000 --- a/tests/ui/linkage-attr/framework.omit.stderr +++ /dev/null @@ -1,8 +0,0 @@ -error: linking with `LINKER` failed: exit status: 1 - | - ld: Undefined symbols: - _CFRunLoopGetTypeID, referenced from: - clang: error: linker command failed with exit code 1 (use -v to see invocation) - - -error: aborting due to 1 previous error diff --git a/tests/ui/linkage-attr/framework.rs b/tests/ui/linkage-attr/framework.rs deleted file mode 100644 index 08f4394db21..00000000000 --- a/tests/ui/linkage-attr/framework.rs +++ /dev/null @@ -1,32 +0,0 @@ -// Check that linking frameworks on Apple platforms works. -//@ only-apple -//@ revisions: omit link weak both -//@ [omit]build-fail -//@ [link]run-pass -//@ [weak]run-pass -//@ [both]run-pass - -// The linker's exact error output changes between Xcode versions, depends on -// linker invocation details, and the linker sometimes outputs more warnings. -//@ compare-output-lines-by-subset -//@ normalize-stderr-test: "linking with `.*` failed" -> "linking with `LINKER` failed" -//@ normalize-stderr-test: "Undefined symbols for architecture .*" -> "ld: Undefined symbols:" -//@ normalize-stderr-test: "._CFRunLoopGetTypeID.," -> "_CFRunLoopGetTypeID," - -#![cfg_attr(any(weak, both), feature(link_arg_attribute))] - -#[cfg_attr(any(link, both), link(name = "CoreFoundation", kind = "framework"))] -#[cfg_attr( - any(weak, both), - link(name = "-weak_framework", kind = "link-arg", modifiers = "+verbatim"), - link(name = "CoreFoundation", kind = "link-arg", modifiers = "+verbatim") -)] -extern "C" { - fn CFRunLoopGetTypeID() -> core::ffi::c_ulong; -} - -pub fn main() { - unsafe { - CFRunLoopGetTypeID(); - } -}