Skip to content

Commit

Permalink
Ensure using otool that framework linking actually happened
Browse files Browse the repository at this point in the history
  • Loading branch information
madsmtm committed Dec 12, 2023
1 parent ee6de0c commit 8442f62
Show file tree
Hide file tree
Showing 7 changed files with 42 additions and 0 deletions.
21 changes: 21 additions & 0 deletions tests/run-make/link-framework/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# only-macos
#
# Check that linking to a framework actually makes it to the linker.

include ../tools.mk

all:
$(RUSTC) dep-link-framework.rs
$(RUSTC) dep-link-weak-framework.rs

$(RUSTC) empty.rs
otool -L $(TMPDIR)/no-link | $(CGREP) -v CoreFoundation

$(RUSTC) link-framework.rs
otool -L $(TMPDIR)/link-framework | $(CGREP) CoreFoundation | $(CGREP) -v weak

$(RUSTC) link-weak-framework.rs
otool -L $(TMPDIR)/link-weak-framework | $(CGREP) CoreFoundation | $(CGREP) weak

$(RUSTC) link-both.rs
otool -L $(TMPDIR)/link-both | $(CGREP) CoreFoundation | $(CGREP) weak
4 changes: 4 additions & 0 deletions tests/run-make/link-framework/dep-link-framework.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#![crate_type = "rlib"]

#[link(name = "CoreFoundation", kind = "framework")]
extern "C" {}
6 changes: 6 additions & 0 deletions tests/run-make/link-framework/dep-link-weak-framework.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#![crate_type = "rlib"]
#![feature(link_arg_attribute)]

#[link(name = "-weak_framework", kind = "link-arg", modifiers = "+verbatim")]
#[link(name = "CoreFoundation", kind = "link-arg", modifiers = "+verbatim")]
extern "C" {}
1 change: 1 addition & 0 deletions tests/run-make/link-framework/empty.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
fn main() {}
4 changes: 4 additions & 0 deletions tests/run-make/link-framework/link-both.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
extern crate dep_link_framework;
extern crate dep_link_weak_framework;

fn main() {}
3 changes: 3 additions & 0 deletions tests/run-make/link-framework/link-framework.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
extern crate dep_link_framework;

fn main() {}
3 changes: 3 additions & 0 deletions tests/run-make/link-framework/link-weak-framework.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
extern crate dep_link_weak_framework;

fn main() {}

0 comments on commit 8442f62

Please sign in to comment.