-
Notifications
You must be signed in to change notification settings - Fork 13k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add test for Apple's -weak_framework
linker argument
#118644
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# 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 | ||
|
||
# When linking the framework both normally, and weakly, the weak linking takes preference | ||
|
||
$(RUSTC) link-both.rs | ||
otool -L $(TMPDIR)/link-both | $(CGREP) CoreFoundation | $(CGREP) weak |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#![crate_type = "rlib"] | ||
|
||
#[link(name = "CoreFoundation", kind = "framework")] | ||
extern "C" {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
fn main() {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
extern crate dep_link_framework; | ||
|
||
fn main() {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
extern crate dep_link_weak_framework; | ||
|
||
fn main() {} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
error: linking with `cc` failed: exit status: 1 | ||
| | ||
ld: Undefined symbols: | ||
_CFRunLoopGetTypeID, referenced from: | ||
clang: error: linker command failed with exit code 1 (use -v to see invocation) | ||
|
||
|
||
error: aborting due to 1 previous error |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
// Check that linking frameworks on Apple platforms works. | ||
//@ only-macos | ||
//@ revisions: omit link weak both | ||
//@ [omit]build-fail | ||
//@ [link]run-pass | ||
//@ [weak]run-pass | ||
//@ [both]run-pass | ||
|
||
// The linker's exact error output changes between Xcode versions. | ||
//@ compare-output-lines-by-subset | ||
//@ normalize-stderr-test: "Undefined symbols for architecture .*" -> "ld: Undefined symbols:" | ||
//@ normalize-stderr-test: "._CFRunLoopGetTypeID.," -> "_CFRunLoopGetTypeID," | ||
|
||
#![cfg_attr(any(weak, both), feature(link_arg_attribute))] | ||
|
||
#[cfg_attr(any(link, both), link(name = "CoreFoundation", kind = "framework"))] | ||
#[cfg_attr( | ||
any(weak, both), | ||
link(name = "-weak_framework", kind = "link-arg", modifiers = "+verbatim"), | ||
link(name = "CoreFoundation", kind = "link-arg", modifiers = "+verbatim") | ||
)] | ||
extern "C" { | ||
fn CFRunLoopGetTypeID() -> core::ffi::c_ulong; | ||
} | ||
|
||
pub fn main() { | ||
unsafe { | ||
CFRunLoopGetTypeID(); | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(Since this seems like a new
run-make
test) Does this test need to be written in Makefile? Can it be written inrmake.rs
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It probably could - didn't know about
rmake.rs
, I think I made this PR before that was availableThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, the timing was a bit unfortunate, but that's okay, we added a tidy check now