Skip to content

Commit ec5c8fe

Browse files
committed
Add test for Apple's -weak_framework linker argument
1 parent a47d390 commit ec5c8fe

File tree

3 files changed

+38
-21
lines changed

3 files changed

+38
-21
lines changed

tests/run-pass-valgrind/osx-frameworks.rs

-21
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
error: linking with `cc` failed: exit status: 1
2+
|
3+
ld: Undefined symbols:
4+
_CFRunLoopGetTypeID, referenced from:
5+
clang: error: linker command failed with exit code 1 (use -v to see invocation)
6+
7+
8+
error: aborting due to 1 previous error

tests/ui/linkage-attr/framework.rs

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
// Check that linking frameworks on Apple platforms works.
2+
//@ only-macos
3+
//@ revisions: omit link weak both
4+
//@ [omit]build-fail
5+
//@ [link]run-pass
6+
//@ [weak]run-pass
7+
//@ [both]run-pass
8+
9+
// The linker's exact error output changes between Xcode versions.
10+
//@ compare-output-lines-by-subset
11+
//@ normalize-stderr-test: "Undefined symbols for architecture .*" -> "ld: Undefined symbols:"
12+
//@ normalize-stderr-test: "._CFRunLoopGetTypeID.," -> "_CFRunLoopGetTypeID,"
13+
14+
#![cfg_attr(any(weak, both), feature(link_arg_attribute))]
15+
16+
#[cfg_attr(any(link, both), link(name = "CoreFoundation", kind = "framework"))]
17+
#[cfg_attr(
18+
any(weak, both),
19+
link(name = "-weak_framework", kind = "link-arg", modifiers = "+verbatim"),
20+
link(name = "CoreFoundation", kind = "link-arg", modifiers = "+verbatim")
21+
)]
22+
extern "C" {
23+
fn CFRunLoopGetTypeID() -> core::ffi::c_ulong;
24+
}
25+
26+
pub fn main() {
27+
unsafe {
28+
CFRunLoopGetTypeID();
29+
}
30+
}

0 commit comments

Comments
 (0)