Skip to content

Commit

Permalink
Add test for Apple's -weak_framework linker argument
Browse files Browse the repository at this point in the history
  • Loading branch information
madsmtm committed Dec 5, 2023
1 parent 317d14a commit ba0a077
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 21 deletions.
21 changes: 0 additions & 21 deletions tests/run-pass-valgrind/osx-frameworks.rs

This file was deleted.

12 changes: 12 additions & 0 deletions tests/ui/linkage-attr/framework.omit.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
error: linking with `cc` failed: exit status: 1
|
= note: [linker command]
= note: ld: warning: search path '$TEST_BUILD_DIR/linkage-attr/framework.omit/auxiliary' not found
ld: Undefined symbols:
_CFRunLoopGetTypeID, referenced from:
framework::main::HASH in framework.framework.HASH-cgu.0.rcgu.o
clang: error: linker command failed with exit code 1 (use -v to see invocation)


error: aborting due to 1 previous error

23 changes: 23 additions & 0 deletions tests/ui/linkage-attr/framework.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// Check linking frameworks on Apple platforms works.
// only-macos
// revisions: omit link weak
// [omit]build-fail
// [link]run-pass
// [weak]run-pass
// normalize-stderr-test: "note: env .*" -> "note: [linker command]"
// 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"

#![cfg_attr(weak, feature(link_arg_attribute))]

#[cfg_attr(link, link(name = "CoreFoundation", kind = "framework"))]
#[cfg_attr(weak, link(name = "-weak_framework", kind = "link-arg", modifiers = "+verbatim"))]
#[cfg_attr(weak, link(name = "CoreFoundation", kind = "link-arg", modifiers = "+verbatim"))]
extern "C" {
fn CFRunLoopGetTypeID() -> core::ffi::c_ulong;
}

pub fn main() {
unsafe {
CFRunLoopGetTypeID();
}
}

0 comments on commit ba0a077

Please sign in to comment.