Skip to content

Commit ba0a077

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

File tree

3 files changed

+35
-21
lines changed

3 files changed

+35
-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

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// Check linking frameworks on Apple platforms works.
2+
// only-macos
3+
// revisions: omit link weak
4+
// [omit]build-fail
5+
// [link]run-pass
6+
// [weak]run-pass
7+
// normalize-stderr-test: "note: env .*" -> "note: [linker command]"
8+
// 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"
9+
10+
#![cfg_attr(weak, feature(link_arg_attribute))]
11+
12+
#[cfg_attr(link, link(name = "CoreFoundation", kind = "framework"))]
13+
#[cfg_attr(weak, link(name = "-weak_framework", kind = "link-arg", modifiers = "+verbatim"))]
14+
#[cfg_attr(weak, link(name = "CoreFoundation", kind = "link-arg", modifiers = "+verbatim"))]
15+
extern "C" {
16+
fn CFRunLoopGetTypeID() -> core::ffi::c_ulong;
17+
}
18+
19+
pub fn main() {
20+
unsafe {
21+
CFRunLoopGetTypeID();
22+
}
23+
}

0 commit comments

Comments
 (0)