Skip to content

Commit c1718e3

Browse files
committed
Add test for Apple's -weak_framework linker argument
1 parent 317d14a commit c1718e3

File tree

3 files changed

+39
-21
lines changed

3 files changed

+39
-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,12 @@
1+
error: linking with `cc` failed: exit status: 1
2+
|
3+
= note: [linker command]
4+
= note: ld: warning: search path '$TEST_BUILD_DIR/linkage-attr/framework.omit/auxiliary' not found
5+
ld: Undefined symbols:
6+
_CFRunLoopGetTypeID, referenced from:
7+
framework::main::HASH in framework.framework.HASH-cgu.0.rcgu.o
8+
clang: error: linker command failed with exit code 1 (use -v to see invocation)
9+
10+
11+
error: aborting due to 1 previous error
12+

tests/ui/linkage-attr/framework.rs

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
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+
// normalize-stderr-test: "note: env .*" -> "note: [linker command]"
9+
// normalize-stderr-test: "framework::main::\w* in framework\.framework\.\w*-cgu\.0\.rcgu\.o" -> "framework::main::HASH in framework.framework.HASH-cgu.0.rcgu.o"
10+
11+
#![cfg_attr(any(weak, both), feature(link_arg_attribute))]
12+
13+
#[cfg_attr(any(link, both), link(name = "CoreFoundation", kind = "framework"))]
14+
#[cfg_attr(
15+
any(weak, both),
16+
link(name = "-weak_framework", kind = "link-arg", modifiers = "+verbatim"),
17+
link(name = "CoreFoundation", kind = "link-arg", modifiers = "+verbatim")
18+
)]
19+
extern "C" {
20+
fn CFRunLoopGetTypeID() -> core::ffi::c_ulong;
21+
}
22+
23+
pub fn main() {
24+
unsafe {
25+
CFRunLoopGetTypeID();
26+
}
27+
}

0 commit comments

Comments
 (0)